Convert a ocamlyacc's Parser.mly file to fsyacc's Parser.fsy got " End of file on lexing stream" error

21 views Asked by At

Parser.fsy:

%{
  //let env=Hashtbl.create 10
%}
%token  INT
%token SUB
%token EOL
%token EQUAL
%token NAME
%left SUB

%start main             /* the entry point */
%type  main
%%
 main:
  statement_list EOL                { $1 }

statement_list:
  {}
  |statement statement_list {}

statement:
 assign_statement{}
 |print_statement{}

assign_statement:
 var EQUAL expr {//Hashtbl.add env $1 $3}

print_statement:
 var {//Printf.printf "%d\n" (Hashtbl.find env $1)}

expr:
   INT                     { $1} 
  | expr SUB expr           { $1 - $3}
  | var {//Hashtbl.find env $1}
  
var:NAME {$1}

this file is convert from Parser.mly,I only change the filename and comment out the line which use the ocaml's lib.using:

fsyacc --module Parser Parser.fsy

got

parser.fsy(36,13): error: End of file on lexing stream

(if the cursor is at end of line 36,the error is at the end of line 36;if the cursor is at the begin of new line 37,the error is at line 37)

so what's the error mean?I can find very few doc of fsyacc.Thanks!

0

There are 0 answers