[antlr-interest] Lexer rules

Marwan Ajraoui marwan.alephn at gmail.com
Sat Aug 15 08:47:20 PDT 2009


Hi;

Now it works when I added the rule tipo with this rules.

tipo  : (ENTERO_V | REAL_V | DOBLE_V | CARACTER_V | CADENA_V | LOGICO_V) ;

ENTERO_V: ENTERO_T(CORCHE_ABRE CORCHE_CIERE)*;

fragment ENTERO_T: 'integer';

...

Now I will try my tree matcher Jim;

Many thx for your help guys;

Cheers.




2009/8/15 Jim Idle <jimi at temporal-wave.com>:
> Sam Barnett-Cormack wrote:
>
> Marwan Ajraoui wrote:
>
>
> Hi everybody;
>
> Having this lexer rules, parsing the input doesn't recognize 'integer'
> as a type, only recognize types vector of integer as a token like
> integer[] or integet[][][].
>
> CORCHE_CIERE:']';
>
> CORCHE_ABRE: '[';
>
> fragment ENTERO_T: 'integer';
>
> ENTERO_V: ENTERO_T(CORCHE_ABRE CORCHE_CIERE)*;
>
> Am i missing something; I did try without fragment, and the same result.
>
>
> Off the top of my head, it should match any of 'integer', 'integer[]'
> and 'interger[][][]' as ENTERO_V tokens.
>
> I think there's some rethinking wants to be done between what is in the
> lexer and what is in the parser. For example, isn't '[]' really an
> operator, or modifier, and wants to be dealt with in the parser, not
> bundled into the same token?
>
>
>
> ENTERO_T needs to be a non-fragment, ENTERO_V needs to be a parser rule, you
> need to cater for whitespace and so on...
>
> CORCHE_CIERE : ']';
>
> CORCHE_ABRE  : '[';
>
> ENTERO_T     : 'integer';
>
>
> entero_v     : ENTERO_T (CORCHE_ABRE CORCHE_CIERE)* EOF;
>
>
> Jim
>
>
>
>
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>



-- 
Marouane


More information about the antlr-interest mailing list