Closed daiyam closed 8 years ago
I really don't know what I'm doing wrong... :tired_face:
I'm doing a parser for template strings but I'm getting the same kind of error...
Parse error on line 1:
`hello $(name)`
---------------^
Expecting ',', ')', got 'EOF'
with the text:
`hello $(name)`
and the syntax
%lex
%x template
%%
\s+ /* skip whitespace */
<template>'`' this.popState();return 'END'
<template>'$(' this.begin('');return '$('
<template>. return 'TEMPLATE_VALUE'
'`' this.begin('template');return 'BEGIN'
'(' this.begin('');return '('
')' this.popState();return ')'
',' return ','
[-_$A-Za-z]\w* return 'IDENTIFIER'
<<EOF>> return 'EOF'
. return 'INVALID'
/lex
%start Expression
%%
Arguments
: Arguments ',' Expression
| Expression
;
Expression
: Identifier '(' Arguments ')'
| Identifier
| Template
;
Identifier
: 'IDENTIFIER'
;
Template
: 'BEGIN' TemplateValues 'END'
;
TemplateValues
: TemplateValues 'TEMPLATE_VALUE'
| TemplateValues '$(' Expression ')'
| 'TEMPLATE_VALUE'
;
%%
@daiyam
Your lexer recognizes 'EOF' but you never use it in parser productions, you must take into account that every source has 'EOF', so, try to change the start condition to some rule that regards 'EOF', example:
...
%start Program
%%
Program
: Expression EOF
...
please, let me know if this solves your problem.
@yosbelms Thanks you.
Just need to remove the <<EOF>> return 'EOF'
and everything is fine.
Sometimes it's so much in your face that you don't see it...
Hello,
I'm stuck on a should be simple parser. Without any conflicts.
I'm getting the error
Expecting ')', ',', 'NEWLINE', got 'EOF'
. It's as if the parser consumes all the data but revert to an invalid status.Here my Jison file:
and my test file:
Thx Daiyam