I wrote a simple expression evaluator that accept and evaluate strings such as
"1 + 4 * 2 / 3". The part of grammar is
expr1:
NUMBER
| expr1 '*' NUMBER
{
$$.numval = $1.numval * $3.numval
finalval = $$.numval
}
| expr1 '/' NUMBER
{
$$.numval = $1.numval / $3.numval
finalval = $$.numval
}
Then it reports the following error:
y.go:61: syntax error: unexpected $
when I went to the y.go
61: YYVAL.numval = YYS[yypt-2].numval / $3.numval
$3 is not changed into YYS[yypt-3], seems there are somthing wrong. "/" was
considered as the begining of comment in one line. however if $3.number is
at different line with "$$.numval = $1.numval /" the program is OK
i think this is because goyacc is a transliteration of the limbo yacc,
and in limbo the comment character is a single #.
the translation converted # to / but missed the doubling.
by superisaac.ke:
Attachments: