I would like to define keyword_tablewhich displays some rows for some tokens, and I would like to make this table visible to both parser.mly, and for lexer.mll.
It seems that the table should be defined in parser.mly,
%{
open Utility (* where hash_table is defined to make a table from a list *)
let keyword_table = hash_table [
"Call", CALL; "Case", CASE; "Close", CLOSE; "Const", CONST;
"Declare", DECLARE; "DefBool", DEFBOOL; "DefByte", DEFBYTE ]
%}
However, I could not use it in lexer.mll, for example
{
open Parser
let x = keyword_table (* doesn't work *)
let x = Parser.keyword_table (* doesn't work *)
let x = Parsing.keyword_table (* doesn't work *)
}
As this comment , menhirhas a solution for this, can anyone tell me any details?
source
share