[erlang-questions] Question of yecc

Solomon <>
Fri Nov 16 02:27:52 CET 2012


Thanks, you are right. Maybe I should try to write a xrl file to do the lexical
analysis.


2012/11/16 Álvaro <>

> Hi,
>
> I think the problem is that yecc does not recognize the terminal 'num'.
> The default scanner recognizes 'integer' and 'float'.
> Change your 'num' for 'integer' and try again.
>
> Best,
> Álvaro
>
> 2012/11/15 Solomon <>
>
>> I want to write a parser to parse the string like this:
>>   a.id = b.id
>>   a.id = 10
>>
>> My yrl file like this:
>> *Nonterminals
>>     val expr alias field.
>>
>> Terminals
>>     '=' '>' '>=' '<=' '<' '!=' '.' 'atom'
>>     'num'.
>>
>> Rootsymbol
>>     expr.
>>
>> expr->val '=' val:['$1', '$3', {'opt', '='}].
>> expr->val '>' val:['$1', '$3', {'opt', '>'}].
>> expr->val '>=' val:['$1', '$3', {'opt', '>='}].
>> expr->val '<' val:['$1', '$3', {'opt', '<'}].
>> expr->val '<=' val:['$1', '$3', {'opt', '<='}].
>> expr->val '!=' val:['$1', '$3', {'opt', '!='}].
>>
>> val->alias '.' field:{'$1', '$3'}.
>> val->num:{'num', '$1'}.
>>
>> alias->atom:{'alias', '$1'}.
>> field->atom:{'field', '$1'}.*
>>
>> it is ok for "a.id=b.id":
>> *{ok,[{{alias,{atom,1,a}},{field,{atom,1,id}}},
>>      {{alias,{atom,1,b}},{field,{atom,1,id}}},
>>      {opt,'='}]}*
>>
>> and it is ok for "a.id=b":*
>> {ok,[{{alias,{atom,1,a}},{field,{atom,1,id}}},
>>      {num,{atom,1,a}},
>>      {opt,'='}]}*
>>
>> but it error for "a.id=12":
>> *{error,{1,my_parser,["syntax error before: ","12"]}}*
>>
>> what is wrong with my yrl file?
>>
>> _______________________________________________
>> erlang-questions mailing list
>> 
>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20121116/dca4b54c/attachment.html>


More information about the erlang-questions mailing list