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

Matt Benson gudnabrsam at yahoo.com
Thu Feb 28 10:50:31 PST 2008


--- Andy Tripp <antlr at jazillian.com> wrote:

> Matt Benson wrote:
> >
> > I don't think it's correct to say that a syntactic
> > predicate is a type of semantic predicate.  I
> think
> > the nomenclature here directly reflects the
> difference
> > between syntax and semantics:  respectively, the
> > legality of the communication medium vs. the
> > sensicality (?) of the content.
> I don't think that's right. When we have a syntactic
> predicate:
> (X) => Y
> ...it's not saying anything about the legality of
> the input nor
> whether X is semantically legal.
> 
> With the traditional case of just a lexer and a
> parser, syntax is
> "how does the input characters sequence map to a
> Token stream?"
> And semantics is "how does the input Token stream
> map to an AST"?
> 
> Terrence has this general mechanism that he's
> calling "predicates"
> which checks the structure of the input. That input
> can be a stream
> of characters (for lexer), tokens (for parser), or
> ASTs for treewalker.
> 
> Now that I think about it, maybe a better name for
> "syntactic predicate"
> would be "input pattern predicate" or something like
> that. The term
> "syntactic", to me, is a bit misleading because it
> makes
> me think of input characters.
> 
> Saying "my treewalker has a
> syntactic predicate, which of course checks the
> shape of the input
> AST" seems a bit odd. I may just be stuck in an old
> way of thinking,
> but I just checked dictionary.com and wikipedia, and
> they're agreeing
> with me :)

I'm not sure what entries you've checked, so I'm not
sure what in particular on dictionary.com/wikipedia is
in agreement with you.  I think we're ultimately on
the same page, but my (and I think Ter's)
understanding of the syntax issue is that a lexer sees
syntax in terms of characters, while a parser sees
syntax in terms of tokens.  You just have to expand
your definitions a little.  A good example might be in
the case of e.g. a Java parser.  Let's say, at an
arbitrary point in the parse, the following token
sequence is a simple, syntactically valid, option:

DOT IDENTIFIER LPAREN RPAREN

We know this token sequence represents a no-arg method
call, right?  But in the case of a simple interpreter
(for instant gratification wrt semantic predicates)
the semantic check would involve checking whether the
IDENTIFIER specified is actually resolvable to an
existing no-arg method on whatever object is active in
our current context.

That's how I see it, anyway.

-Matt

> 
> Andy
> 
> 



      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 



More information about the antlr-interest mailing list