I'm bringing myself up to speed on lemon.  I have a few questions.  Take
this example code:

%type multiselect_op {int}
multiselect_op(A) ::= UNION(OP).             {A = @OP;}
multiselect_op(A) ::= UNION ALL.             {A = TK_ALL;}
multiselect_op(A) ::= EXCEPT|INTERSECT(OP).  {A = @OP;}

1. What does the '@' symbol mean?  At first glance I thought it meant,
'give me the literal string,' but 'A' is an integer, so that doesn't
work.  How is {A = @OP;} different from {A = OP;}?
2. If TK_ALL is a token, what are the other all-caps literals?  I assume
they are literal text, i.e. 'UNION' is a keyword in sql.  However, SQL
is not case sensitive, so explain how case is handled with these
literals.  I don't think sqlite upcases all text sent to the parser, so
there must be some rule that controls the case sensitivity.  Or maybe
these are also tokens?
3. Lemon prefixes all tokens with TK_ (or whatever you define
%token_prefix).  But there are some other literals that I can find no
definition for, e.g. SEMI, COMMA, etc.  I think my confusion here is
related to my previous question and my next question.
4. I don't see any documention on using a lexer (e.g. flex) with lemon.
There are some helps on the internet, but the obvous ommission leads me
to believe I don't need a lexer.  Does lemon take on some of the
functionality of a lexer?  If I need to define tokens as regular
expressions can I do that in lemon or do I need a lexer?

Forgive me - I'm an engineer and I'm learning lemon in a vacuum.  I want
to write a parser in eVC4.2 to handle commands from another device via
RS-232.  I could write a nasty nest of switch-case-if-else-if, or I
could learn something new.

Help?

PS.  If I read another lemon/bison/yacc example for a calculator I'll
scream.  I need to parse an ascii command protocol with a fixed header
size, a variable length body (comma delim), 4 character crc, and \r
terminator.

Ron Wilson, Senior Engineer, MPR Associates, 518.831.7546

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to