SmaCC ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

SmaCC ?

Keith Hodges-2
Can anyone help me to work out why this is not working.

Scanner:

<anyLetter> : [A-Z a-z _ 0-9] ;
<upperLetter>: [A-Z] ;
<lowerLetter> : [a-z_0-9] ;

Parser:

Test : <upperLetter>+ <lowerLetter>+ <upperLetter> <anyLetter> ;

Test String:
HelloWorld

I was expecting the parser to at least get past the 'o' in world.

many thanks in advance

Keith

Send instant messages to your online friends http://uk.messenger.yahoo.com 

Reply | Threaded
Open this post in threaded view
|

Re: SmaCC ?

Diego Fernández
Remove the token <anyLetter>, I think that it confuses the parser, ie: HelloW --> o is a <anyLetter> or <lowerLetter>?.
SmaCC is not smart enough to see the difference. You can change it to:

Scanner:
<upperLetter>: [A-Z] ;
<lowerLetter> : [a-z_0-9] ;

Parser:
Test : <upperLetter>+ <lowerLetter>+ <upperLetter> AnyLetter+ ;

AnyLetter: <upperLetter>
    | <lowerLetter> ;


On 6/2/06, Keith Hodges <[hidden email]> wrote:
Can anyone help me to work out why this is not working.

Scanner:

<anyLetter> : [A-Z a-z _ 0-9] ;
<upperLetter>: [A-Z] ;
<lowerLetter> : [a-z_0-9] ;

Parser:

Test : <upperLetter>+ <lowerLetter>+ <upperLetter> <anyLetter> ;

Test String:
HelloWorld

I was expecting the parser to at least get past the 'o' in world.

many thanks in advance

Keith

Send instant messages to your online friends http://uk.messenger.yahoo.com




Reply | Threaded
Open this post in threaded view
|

Re: SmaCC ?

Alain Plantec
In reply to this post by Keith Hodges-2
hi,

maybe

Scanner
<upperLetter>: [A-Z] ;
<lowerLetter> : [a-z_0-9] ;
<whitespace>        :        \s+ ;  <-- eat whitespaces

Test
AAbAA aAaaffffaa AjfdH


alain




Keith Hodges a écrit :

> Can anyone help me to work out why this is not working.
>
> Scanner:
>
> <anyLetter> : [A-Z a-z _ 0-9] ;
> <upperLetter>: [A-Z] ;
> <lowerLetter> : [a-z_0-9] ;
>
> Parser:
>
> Test : <upperLetter>+ <lowerLetter>+ <upperLetter> <anyLetter> ;
>
> Test String:
> HelloWorld
>
> I was expecting the parser to at least get past the 'o' in world.
>
> many thanks in advance
>
> Keith
>
> Send instant messages to your online friends
> http://uk.messenger.yahoo.com
>
>