Commit Graph

6 Commits

Author SHA1 Message Date
Glen Whitney 06938ec494 Implement a find() macro
This macro looks at each cell along some stride through the sheet,
  returning the location of the first cell encountered at which a given
  expression evaluates to true, or boolean false otherwise.

  To make this more useful, this change also revamps the handling of
  boolean values, making them much more permissive and coercing to boolean type
  in fewer circumstances. It adds the bool() type conversion for explicitly
  coercing to boolean type, and fixes a small issue with reading hex-formatted
  floating-point values ('p' can be used as an exponent indicator).

  Closes #64.
2019-08-28 12:40:50 -07:00
Glen Whitney 892fdcdb75 Add BOOL token_type, macros, and boolean operators
For clarity, it is valuable for the results of comparisons to show as "true"
  and "false" rather than "1" and "0". This change implements a BOOL type
  to facilitate that. Since we want logical operators to short-circuit, this
  change also obliges the introduction of macros, which are just like functions
  except their arguments are not evaluated before control is passed to the
  routine implementing the macro.
2019-08-26 23:56:19 -07:00
Glen Whitney 7e0ba7370d Add functions for unit displacements in the siz cardinal directions
This change is the "easy" part of #64, but to reduce the amount of duplicated
   code, this change also modifies the internals of implementing a function.
   The function identifier is now passed to the implementation as well, allowing
   many implementations of similar functions to be collapsed more easily.
2019-08-25 23:19:34 -07:00
Glen Whitney a56efa0c91 Prepare for parsing expressions into parse trees
Prior to this change, every evaluation re-parses the expression. The
  intermediate form as a parse tree is never stored anywhere. This change
  adds a new token type, FUNCALL, which acts as a node in a parse tree, and
  adds an (untested) evaluation method which returns the unevaluated parse tree
  as opposed to evaluating as it goes.

  This is preparation for a following step in which rather than storing a token
  sequence for each variety of content, teapot will store a single token
  representing the parse tree, allowing for quicker evaluation when the time
  comes; no actual parsing will have to occur on evaluation.
2019-08-05 16:45:04 -04:00
Glen Whitney 341b12ba04 Implement a relative reference robust to source and reference moving
The new function is X(SRC,REF), which briefly for a cell in the neighborhood
   of REF returns the corresponding cell in the neighborhood in SRC. For
   further details, see the updated documention.

   In developing and documenting this function, I refined some of the
   existing error messages (e.g. showing the coordinates when there is an
   attempt to obtain a cell with a negative coordinate) and improved the
   error propagation to increase the chance that the innermost error will
   percolate to the top level.
2019-07-30 15:07:54 -04:00
Glen Whitney ea230efc23 Move source code into subdirectory
Also removed a stray copy of the automatically generated config.h which
  had somehow gotten into the distribution. Closes #36.
2019-07-27 01:35:44 -04:00