[antlr-interest] Lexing colons again (consume and getColumn)

Robert Colquhoun rjc at trump.net.au
Mon May 17 03:16:14 PDT 2004


Hello Anthony,

At 12:54 AM 15/05/2004, Anthony Youngman wrote:
>Cracked it! It looks like the bit of code you quoted was lifted pretty
>much from your grammar ... but I was correct in saying "consume" added
>the consumed token to the text. And the reason I was seeing it was
>because the label "123" matches the INT rule, not the IDENT rule. Your
>get/set length code was never getting touched because of the "start in
>column 1" guard rule I'd implemented.

If you continue to use getColumn() it would probably be neater to do it as 
a syntactic predicate to separate labels/ints and idents/ints.  Or possibly 
somehow tack it on to the end of the EOL rule as the label always follows 
'\r' or '\n'

>Anyway, I've now modified my INT rule to add a colon if it's a label and
>there's no colon, and I've taken out the get and set length lines in the
>IDENT rule. That means all user-defined labels must, internally, end in
>colons (so I'll have to fix GOTO and GOSUB to add them if the user
>doesn't :-). And all my internally generated labels don't end in a colon
>so I'm guaranteed separate namespaces :-)
>
>So here's to GOTO, and then on to argument lists. And isn't there a
>function that uses ';' instead of ',' somewhere? Yuck :-(

There are many issues, it has taken 5 years to get my compiler and runtime 
working for the wide array of programs out there.  It is pretty funny to 
think i had my first basic programs compiling(ie PRINT "HELLO WORLD") 
within a couple of weeks of picking up antlr, i thought i was nearly done, 
how little i realized what was to come.


>Anyway, what's wrong with COBOL (which I've never used?). It's far
>better than spaghetti (if you're programming, that is), though not
>better than pizzas in most peoples' minds, I expect :-)

The column position stuff was forced on cobol and fortran and other 
languages of the era by the limitations in machines of the time(ie 8kb 
total memory) and having to encode the program on fixed length 
cards.  Except for museums nobody much cares about cards today, the 
constraint has been completely removed.

>  As I said, the
>Pr1me rule is "implement the good stuff, not the braindead stuff :-)

As opposed to say the Postel rule : "be liberal in what you accept and 
conservative in what you send."

How many live prime systems would be left running real applications in the 
world?  surely < 100 by now.

  - Robert



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
     antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list