Re: [abc-users] grammar help

From: Eric Bodden <eric.bodden_at_mail.mcgill.ca>
Date: Thu, 19 Mar 2009 09:16:03 -0400

Yes that makes sense. If this works for you and everything gets parsed
correctly then you should be fine.

Eric

2009/3/19 Amjad Nusayr <anusayr_at_cs.nmsu.edu>:
> Yes, that is the case. I wrote the following in my AbcExtension
>
> lexer.addPointcutKeyword("firstNum", new LexerAction_c(new
> Integer(abc.bbs.parse.sym.PC_FIRSTNUM),new
> Integer(lexer.pointcutifexpr_state())));
>
> I used the lexer.pointcutifexpr_state(). I did not get any problem in
> passing the INT to my aspectinfo.FirstNum class
>
> Should I create my own state or can continue using the one above.
>
> Thanks
> Amjad
>
>
> Eric Bodden wrote:
>>
>> 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 Thu Mar 19 2009 - 13:16:08 GMT

This archive was generated by hypermail 2.2.0 : Tue Mar 31 2009 - 15:20:11 BST