Commit e6a4a9c7 authored by POTTIER Francois's avatar POTTIER Francois
Browse files

Keep token aliases instead of dropping them when joining partial grammars.

parent 425ec7ba
......@@ -259,6 +259,7 @@ module Terminal = struct
tk_is_declared = true;
tk_position = Positions.dummy;
tk_attributes = [];
tk_alias = None;
}
in
Array.init n (fun tok ->
......
......@@ -36,9 +36,9 @@ let join_declaration filename (grammar : grammar) decl =
difficult by the fact that %token and %left-%right-%nonassoc
declarations are independent. *)
(* Declarations of token aliases are lost at this point. *)
(* If a token carries an alias, it is recorded in the field [tk_alias]. *)
| DToken (ocamltype, terminal, _alias, attributes) ->
| DToken (ocamltype, terminal, alias, attributes) ->
let token_property =
try
......@@ -64,6 +64,7 @@ let join_declaration filename (grammar : grammar) decl =
tk_filename = filename;
tk_position = decl.position;
tk_attributes = attributes;
tk_alias = alias;
}
with Not_found ->
......@@ -77,7 +78,8 @@ let join_declaration filename (grammar : grammar) decl =
tk_precedence = UndefinedPrecedence;
tk_position = decl.position;
tk_attributes = attributes;
tk_is_declared = true
tk_is_declared = true;
tk_alias = None
}
in
......@@ -121,6 +123,7 @@ let join_declaration filename (grammar : grammar) decl =
tk_precedence = prec;
tk_is_declared = false;
tk_attributes = [];
tk_alias = None;
(* Will be updated later. *)
tk_position = decl.position;
} in
......
......@@ -44,7 +44,10 @@ type symbol =
terminal symbols very early on during the joining of the partial grammars;
see the module [ExpandTokenAliases].
In a complete grammar, there are no token aliases any longer. *)
In a complete grammar, there are no token aliases any longer. That is,
we keep track of the aliases that have been declared (they can be found
via the field [tk_alias]), but we never use them, since they have been
eliminated up front. *)
type alias =
string option
......@@ -123,6 +126,7 @@ type token_properties =
tk_filename : filename;
tk_ocamltype : Stretch.ocamltype option;
tk_position : Positions.t;
tk_alias : alias;
tk_attributes : attributes;
mutable tk_associativity : token_associativity;
mutable tk_precedence : precedence_level;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment