parser state



>   Date: Wed, 27 Nov 2013 18:36:16 -0500
>   From: Stavros Macrakis <macrakis at alum.mit.edu>
>
>
>   What problem are you trying to solve? Is there a bug you're trying to fix?
>   A change/extension you'd like to program? Or are you just trying to
>   understand the system?
>
>	       -s

Good questions. I am writing code that processes a source file
containing blocks of Maxima code enclosed in special delimited blocks,
evaluates the Maxima code and replaces the blocks with output from the
computation. These steps are controlled by a function associated with
the block.

While this may seem simple, like a job for awk/perl &co., the longer I
think about doing the job well, the more it looks like one needs to
write a Maxima parser in that scripting language. Aside from the fact
that there are a number of such efforts out there (pmaxima,
doc/info/update_examples, etc.), it seems advantageous to do the job
in Maxima.

Here are some other related applications, ideas:

-the parser tokenizes the input stream, which could be fed back to do
 syntax highlighting on the fly--if the parser were keeping track of
 its state

-currently, an empty input line

;

causes an error. I'd like to change this, but the naive thing to do
means that

(x:1,);

no longer causes a syntax error.

-At the moment, syntax errors are reported through parse-synerr. It
 does a relatively poor job, because the parser's state is not
 well-known. For example, it does not report line numbers in the input
 source, just the file-position.

Leo