[antlr-interest] nesting rules, getting rule text

Anthony Youngman Anthony.Youngman at ECA-International.com
Thu Mar 11 02:19:40 PST 2004


What I'm doing at the moment, is trying to get the basics of my grammar
in place. Precedence of mathematical operations. How do you lex (and
parse) the difference between an array and a function-reference (I know
- treat an array as if it's a function :-). How do you parse a token
when semantics depends on syntax?

(My example is, for example, "a = b < c" and "a = b < c >". The former
is a logical comparison, the latter is using <> as a special sort of
array-reference parenthesis. Monty knows *exactly* what I'm talking
about :-)

Parsing "if then else" constructs, and those damn ambiguity warnings! I
feel pressured to treat EOL as white space, but especially with "if then
else", they are actually syntactically crucial ...

I've come across various references to emitters, but have yet to come
across one. I'm trying to write a tree parser that emits object code.
Severely hampered by my lack of knowledge of Java :-)

Don't worry about any of this at the moment, but if I can get this
*functionally* complete, with 90% of the keywords missing, then I think
it would make a very good, simple, teaching grammar. My thinking is
strongly influenced by the Prime FTN compiler which, when I saw how it
worked, about all it did was convert my complex source into a symbol
table and bunch of CALL statements, using them to do almost everything
even down to the "assign a variable" level! By leaving out 99% of the
instances of "convert language statement to function call" we'll end up
with a grammar that is almost 100% teaching material and very little
repetition. Consisting of a lexer, parser, and treeparse/emitter :-)

Cheers,
Wol

-----Original Message-----
From: Terence Parr [mailto:parrt at cs.usfca.edu] 
Sent: 09 March 2004 19:05
To: antlr-interest at yahoogroups.com
Subject: Re: [antlr-interest] nesting rules, getting rule text

Hi Anthony,

As monty said, it'd be great to get a list of those questions... Can  
you summarize your thoughts?  I promise to use them appropriately even  
if it takes me a bit.

Have you seen the "add C++ style templates to Java" USF CS652 project  
with solution?  That could be useful.  There are a number of projects  
and labs on my USF site that perhaps are not visible enough.

Have you seen the really cool PS interpreter and viewer lab?  All my  
labs are bite-size chunks designed to be finished in 1:45.  There is a  
cool byte-code interpreter lab as well.  Have you checked these out?   
See my next email about the new project. :)

Ter

On Mar 9, 2004, at 3:19 AM, Anthony Youngman wrote:

> The problem I find is actually FINDING all this stuff. I have a bit of
> an aversion to hypertext, much prefer a linear hard copy in front of  
> me,
> and find RMS's addiction to "info" for GNU documentation highly
> offensive ...
>
> Anyway, enough of the rant ... and I know - the rule is "if you want  
> it,
> why don't you write it", but a FAQ, clearly signposted, that consists

> of
> a mildly complicated, highly documented, teaching grammar would be
well
> received. There are some wonderful resources out there, but IME it's
> been a case of either pointers to "get you started" stuff, or a case
of
> "look at the supplied grammars" (but which one do I want to study for
a
> "teach yourself" course?).
>
> I'm not saying there isn't anything out there, but I am frustrated
time
> and time again in that I seem to find either elementary stuff aimed at
> newbies, or reference stuff aimed at experts. It's almost impossible
to
> find stuff aimed at the "I know you're experienced but have never met
> this before" level guy. When I started programming in C I went on a
> "Beginning C for experienced programmers" course - the prerequisite
> being you had to know one - any - computer language well but were
> presumed to know nothing about C at all. Where do you find stuff like
> that?
>
> Cheers,
> Wol
>
> -----Original Message-----
> From: mzukowski at yci.com [mailto:mzukowski at yci.com]
> Sent: 04 March 2004 17:57
> To: antlr-interest at yahoogroups.com
> Subject: RE: [antlr-interest] nesting rules, getting rule text
>
> Yeah, it seems people need a guide to reading the code sometimes.
This
> stuff is in Ter's lectures, but maybe something that pointed out
> techniques
> used in the examples would be helpful too for those of you who just
> start
> hacking away?
>
> Monty
>


***********************************************************************************

This transmission is intended for the named recipient only. It may contain private and confidential information. If this has come to you in error you must not act on anything disclosed in it, nor must you copy it, modify it, disseminate it in any way, or show it to anyone. Please e-mail the sender to inform us of the transmission error or telephone ECA International immediately and delete the e-mail from your information system.

Telephone numbers for ECA International offices are: Sydney +61 (0)2 9911 7799, Hong Kong + 852 2121 2388, London +44 (0)20 7351 5000 and New York +1 212 582 2333.

***********************************************************************************



 
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