[antlr-interest] "An Introduction to ANTLR" presentation slides
Terence Parr
parrt at cs.usfca.edu
Thu Feb 28 11:23:15 PST 2008
On Feb 28, 2008, at 10:39 AM, Andy Tripp 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"?
syntax is the grammatical structure. Semantics deals with the symbols
(IDs).
int x = "foo";
is syntactically ok but semantically wrong.
> 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.
why? i've never seen nor heard this way of thinking about it.
> Saying "my treewalker has a
> syntactic predicate, which of course checks the shape of the input
> AST" seems a bit odd.
Not sure why.
> 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 :)
not possible. syntax is grammatical structure. i wrote the sem pred
wikiped things so they must agree with me ;)
Ter
More information about the antlr-interest
mailing list