Hi,<br><br>I think the problem is that yecc does not recognize the terminal 'num'.<br>The default scanner recognizes 'integer' and 'float'. <br>Change your 'num' for 'integer' and try again.<br>
<br>Best,<br>Álvaro<br><br><div class="gmail_quote">2012/11/15 Solomon <span dir="ltr"><<a href="mailto:solomon.wzs@gmail.com" target="_blank">solomon.wzs@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I want to write a parser to parse the string like this:<br> <a href="http://a.id" target="_blank">a.id</a> = <a href="http://b.id" target="_blank">b.id</a><br> <a href="http://a.id" target="_blank">a.id</a> = 10<br><br>
My yrl file like this:<br><i>Nonterminals<br> val expr alias field.<br>
<br>Terminals<br> '=' '>' '>=' '<=' '<' '!=' '.' 'atom'<br> 'num'.<br><br>Rootsymbol<br> expr.<br><br>expr->val '=' val:['$1', '$3', {'opt', '='}].<br>
expr->val '>' val:['$1', '$3', {'opt', '>'}].<br>expr->val '>=' val:['$1', '$3', {'opt', '>='}].<br>expr->val '<' val:['$1', '$3', {'opt', '<'}].<br>
expr->val '<=' val:['$1', '$3', {'opt', '<='}].<br>expr->val '!=' val:['$1', '$3', {'opt', '!='}].<br><br>val->alias '.' field:{'$1', '$3'}.<br>
val->num:{'num', '$1'}.<br><br>alias->atom:{'alias', '$1'}.<br>field->atom:{'field', '$1'}.</i><br><br>it is ok for "<a href="http://a.id" target="_blank">a.id</a>=<a href="http://b.id" target="_blank">b.id</a>":<br>
<i>{ok,[{{alias,{atom,1,a}},{field,{atom,1,id}}},<br> {{alias,{atom,1,b}},{field,{atom,1,id}}},<br> {opt,'='}]}</i><br><br>and it is ok for "<a href="http://a.id" target="_blank">a.id</a>=b":<i><br>
{ok,[{{alias,{atom,1,a}},{field,{atom,1,id}}},<br>
{num,{atom,1,a}},<br> {opt,'='}]}</i><br><br>but it error for "<a href="http://a.id" target="_blank">a.id</a>=12":<br><i>{error,{1,my_parser,["syntax error before: ","12"]}}</i><br>
<br>what is wrong with my yrl file?<br>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br>