[erlang-questions] Question of yecc
Álvaro
avalormaquedano@REDACTED
Thu Nov 15 17:35:27 CET 2012
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 <solomon.wzs@REDACTED>
> 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
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20121115/11f3abf7/attachment.htm>
More information about the erlang-questions
mailing list