简体   繁体   中英

Ocaml parser “unterminated action” error

I am new to OCaml and I am trying to create a Parser for a specific language using a parser generator - ocamllex, ocamlyacc. When i'm trying to compile my parser.mly file, I am getting the following error:

Error (with mark at =) :

File "parser.mly", line 94: unterminated action
| id = IDENTIFIER { identifier id }
;

The following is an extract from the parser.mly file:

%{
  open Ast

  let identifier name = {
    Identifier.name = name;
  }
%}

%token <int> INT
%token <string> IDENTIFIER

%start monitor
%type <Ast.Expression.t> monitor

%%

ident:
  | id = IDENTIFIER { identifier id }
;

Ocamlyacc does not support giving names to the parts of a rule like this. You'll either need to use $1 etc. or switch to Menhir, which does support this feature.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM