[antlr-interest] "An Introduction to ANTLR" presentation slides

Loring Craymer lgcraymer at yahoo.com
Fri Feb 29 14:10:38 PST 2008


Anything that can be described by a formal grammar is a language; formal grammars specify syntax.  From the Wikipedia definition of Grammar:
"
In formal language theory, a branch of mathematics used in both computer science and linguistics, a grammar is a precise description of a language – that is, of a set of strings over some alphabet.In other words, a grammar describes which of the possible sequences ofsymbols (strings) in a language actually constitute valid words orstatements in that language, but it does not describe their semantics (i.e. what they mean)."

Lexer grammars specify the (character) syntax through which legal symbols are formed; parser and tree grammars recognize sequences of tokens.

While ANTLR and other recognition packages begin with context free grammars, they can be expanded to support context-dependent syntax; ANTLR does this with "semantic" predicates.  ANTLR's semantic predicates do not by themselves deal with semantics--the most common case, for example, is to ask "was this symbol defined in a 'declaration'" (i. e., was it stored in a symbol table)  somewhere else in the input stream?

Syntactic predicates specify lookahead and can invoke semantic predicates to recognize context-dependencies.

--Loring


----- Original Message ----
> From: Andy Tripp <antlr at jazillian.com>
> To: Gerald B. Rosenberg <gbr at newtechlaw.com>
> Cc: antlr-interest <antlr-interest at antlr.org>
> Sent: Friday, February 29, 2008 1:08:05 PM
> Subject: Re: [antlr-interest] "An Introduction to ANTLR" presentation slides
> 
> Gerald B. Rosenberg wrote:
> >
> > Even if they were represented as the same sub-tree, whether it could 
> > be unrolled or further transformed in some other way could be 
> > dependent on surrounding syntax.  Or, for that matter, dependent on 
> > the internal syntax of the X sub-tree.
> 
> >
> > So, it would be entirely valid for a syntactic predicate to consider 
> > the surrounding or internal syntax of a sub-tree in deciding on a 
> > "correct" production, even in a treewalker.
> Ah... I see...you're casually referring to AST structure as "syntax" to 
> give Terrence something convenient to site
> and show that he's not the only one who uses the word "syntax" that way ;)
> 
> Sorry, that doesn't count ;)
> No retroactive immunity allowed.
> You're just confusing people by referring to AST structure as 
> "surrounding syntax" and "internal syntax".
> Better to stick with the tried-and-true "tree structure" nomenclature.
> 
> Andy
> 




      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs


More information about the antlr-interest mailing list