Re: [abc-users] grammar help

From: Eric Bodden <eric.bodden_at_mail.mcgill.ca>
Date: Wed, 18 Mar 2009 14:43:34 -0400

The problem may be that the lexer thab abc uses is stateful. In
particular it has a special pointcut state, in which INTEGER_LITERAL
may not be an allowed token. You should be able to find this out by
looking at the lexer definition (the .flex file). Then either modify
and re-generate the lexer, or switch to an appropriate state when
PC_FIRSTNUM is seen (you do the latter in
AbcExtension.initLexerKeywords(AbcLexer)).

Eric

2009/3/18 Amjad Nusayr <anusayr_at_cs.nmsu.edu>:
> Hi Eric
> It seems it is not working for me, here is what I have in my ppg file
>
> PC_FIRSTNUM:x LPAREN INTEGER_LITERAL:i RPAREN:y
>       {:
>           Grm.parserTrace("FIRSTNUM pointcut");
>           RESULT =
> parser.nf.PCFirstNum(parser.pos(x,y),i.getValue().intValue());
>       :}
>
> When I run abc with my extension I get the following:
>
> World.aj:29: Illegal character "1"
>  before()  : firstNum(1000)                       ^
>
> World.aj:29: Illegal character "0"
>  before()  : firstNum(1000)                        ^
>
> World.aj:29: Illegal character "0"
>  before()  : firstNum(1000)                         ^
>
> World.aj:29: Illegal character "0"
>  before()  : firstNum(1000)                          ^
>
> World.aj:29: Syntax error: unexpected operator ).
>  before()  : firstNum(1000)                           ^
>
> Yes, I'm using polyglot, and I would really be happy if you can tell me how
> to access the int number from the literal?
>
> Thanks
> Amjad
>
> Eric Bodden wrote:
>>
>> Yes, that should be the right one. I am not sure what you mean by "how
>> should I use it". Do you mean how to access the int number from the
>> literal? If so, that depends on the frontend you are using. Are you
>> using JastAdd or Polyglot? They both use different parser generators.
>>
>> Eric
>>
>> 2009/3/18 Amjad Nusayr <anusayr_at_cs.nmsu.edu>:
>>
>>>
>>> Hello
>>> I want to extend the grammar in abc to something very simple. I want to
>>> introduce a new PC that takes a parameter as an decimal integer literal.
>>> Something like NewPC(1000). I dont want an identifier nor an expression ,
>>> just a simple INT literal.
>>> I'm looking at the java12.cup file and found an INTEGER_LITERAL, will
>>> that
>>> help, if so, how should I use it?
>>>
>>> Thanks
>>> Amjad
>>>
>>>
>>>
>>
>>
>>
>>
>
>
>

-- 
Eric Bodden
Sable Research Group, McGill University
Montréal, Québec, Canada
Received on Wed Mar 18 2009 - 18:43:38 GMT

This archive was generated by hypermail 2.2.0 : Thu Mar 19 2009 - 06:00:11 GMT