[AL] Validate AST node names in AL source files

Summary: This will prevent trivial errors like misspelling node names, e.g. when those are typed as part of the operators `IN-NODE <node-name>` or `HOLDS-IN-NODE <node-name>`

Reviewed By: dulmarod

Differential Revision: D5680411

fbshipit-source-id: e241c1c
master
Martino Luca 7 years ago committed by Facebook Github Bot
parent dd51a2e22b
commit e247492901

@ -28,6 +28,11 @@
raise (CTLExceptions.ALParserInvariantViolationException
("ERROR: Variable '" ^ id ^ "' is undefined"))
let is_valid_astnode node_name =
if Clang_ast_proj.is_valid_astnode_kind node_name then ()
else
raise (CTLExceptions.ALParserInvariantViolationException ("Invalid AST node " ^ node_name))
%}
%token EU
@ -97,8 +102,8 @@ var_list:
;
node_list:
| identifier { [ALVar.Const $1] }
| identifier COMMA node_list { ALVar.Const($1) :: $3 }
| identifier { is_valid_astnode $1; [ALVar.Const $1] }
| identifier COMMA node_list { is_valid_astnode $1; ALVar.Const($1) :: $3 }
;
formal_params:

Loading…
Cancel
Save