Skip to content

Commit

Permalink
[asl] Annotate internal parse nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
IGGeorgiev committed Jan 23, 2025
1 parent 8958e2e commit 6941721
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions asllib/Parser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@
- In some cases, rules ending with <> are not implemented in the AST yet.
*)

(*
Paresr Attributes:
* [@internal: bool] - marks which parse nodes, productions or symbols are not
a documented part of the ASL language.
Notes:
* While attributes can be attached to productions, this appears to
not aloways propagate when a production is wrapped by a
parametarized production. In such cases the attribute has been
attached to an arbitrary symbol inside the production as a
workaround as those remain after the inlining completes.
*)

(* ------------------------------------------------------------------------
Parser Config
Expand Down Expand Up @@ -186,7 +199,7 @@ let nlist(x) :=

let end_semicolon ==
| END; SEMI_COLON; <>
| END; {
| END [@internal true]; {
if not Config.allow_no_end_semicolon then
Error.fatal_here $startpos $endpos @@ Error.ObsoleteSyntax "Missing ';' after 'end' keyword.";
}
Expand Down Expand Up @@ -238,7 +251,7 @@ let binop ==
| POW ; { POW }
| COLON_COLON ; { BV_CONCAT }
| unimplemented_binop(
| CONCAT; <>
| CONCAT [@internal true]; <>
)

(* ------------------------------------------------------------------------
Expand Down Expand Up @@ -541,7 +554,7 @@ let stmt :=
{ desugar_elided_parameter LDK_Var lhs ty call}
| PRINTLN; args=plist(expr); { S_Print { args; newline = true; debug = false } }
| PRINT; args=plist(expr); { S_Print { args; newline = false; debug = false } }
| DEBUG; args=plist(expr); { S_Print { args; newline = true; debug = true } }
| DEBUG [@internal true]; args=plist(expr); { S_Print { args; newline = true; debug = true } }
| UNREACHABLE; LPAR; RPAR; { S_Unreachable }
| REPEAT; ~=stmt_list; UNTIL; ~=expr; ~=loop_limit; < S_Repeat >
| ARROBASE_LOOPLIMIT; looplimit=pared(expr); REPEAT; body=stmt_list; UNTIL; cond=expr;
Expand Down Expand Up @@ -690,7 +703,7 @@ let decl :=
let spec := terminated(list(decl), EOF)
(* End *)

let opn := body=stmt; EOF;
let opn [@internal true] := body=stmt; EOF;
{
[
D_Func
Expand All @@ -708,4 +721,4 @@ let opn := body=stmt; EOF;
]
}

let stmts := terminated(stmt_list,EOF)
let stmts [@internal true] := terminated(stmt_list,EOF)

0 comments on commit 6941721

Please sign in to comment.