Rule priority problem
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Vulcun_Louis
Posted On:   Tuesday, November 6, 2001 05:28 AM

hello, i am working on HTML grammar, and i've got a problem with rules in scanner : In the Scanner : OPEN_TAG : ' <' ; OSCRIPT : " WORD: ('a'..'z' | '0'..'9') ('a'..'z' | '0'..'9' | '.')* ; The problem is when i have ' is asking for a 'c'. And i can't have an other open tag which start with s, I really don't see the problem, i have try with k = 1,2...10, it's the same problem. ]]> ]]>    More>>

hello,


i am working on HTML grammar,
and i've got a problem with rules
in scanner :


In the Scanner :


OPEN_TAG : ' <' ;


OSCRIPT : "

   <<Less

Re: Rule priority problem

Posted By:   Monty_Zukowski  
Posted On:   Wednesday, November 7, 2001 06:34 AM

This is the same as when you parse numbers. With an LL scanner you have to combine common prefixes into one rule. You would want something like:



OPEN_TAG : '<' ("script" {$setType(OSCRIPT);})?

WORD: ('a'..'z' | '0'..'9') ('a'..'z' | '0'..'9' | '.')* ;



And you would want OSCRIPT defined somewhere--either referenced in your parser or declared in your "tokens" section.

What's happening is if we only find '<' then the type is the default for ther rule, in this case OPEN_TAG. Otherwise if we see '<' "script" then we set the type appropriately.
About | Sitemap | Contact