[antlr-interest] ANTLR 3.1.2: Simplest action

Bart Kiers bkiers at gmail.com
Wed Jul 13 13:23:05 PDT 2011


Oh, and since `DIGIT` is called from `INTEGER`, the `$text` from `DIGIT`
references `$INTEGER.text`.

Regards,

Bart.


On Wed, Jul 13, 2011 at 10:18 PM, Udo Weik <WeikEngOff at aol.com> wrote:

> Hello Bart and others,
>
> yep, thanks, it works...
>
>
>  Try:
>>
>>    INTEGER
>>       :  DIGIT+ { print($text) }
>>       ;
>>
>
> 1. Why do I not need the name, here INTEGER, like $INTEGER.text?
> 2. With 12345 the result is
>   L: (DIGIT): 1
>   L: (DIGIT): 12
>   L: (DIGIT): 123
>   L: (DIGIT): 1234
>   L: (DIGIT): 12345
>   L: (INTEGER): 12345
>
>   I expected
>   L: (DIGIT): 1
>   L: (DIGIT): 2
>   L: (DIGIT): 3
>   L: (DIGIT): 4
>   L: (DIGIT): 5
>   L: (INTEGER): 12345
>
>
> Many thanks and greetings
> Udo
>
>
>
>  On Wed, Jul 13, 2011 at 9:57 PM, Udo Weik <WeikEngOff at aol.com <mailto:
>> WeikEngOff at aol.com>> wrote:
>>
>>    Hello,
>>
>>    I just want to access the attributes of INTEGER
>>    and DIGIT - but how?
>>
>>    INTEGER: DIGIT+ { print( "L: (INTEGER): " ) } ;
>>
>>    fragment
>>    DIGIT: '0'..'9' { print( "L: (DIGIT): " ) } ;
>>
>>
>>    Thanks and greetings
>>    Udo
>>
>
>


More information about the antlr-interest mailing list