Skip to content

Commit

Permalink
[compile] Add a context field to ast_pragma
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulBone committed Aug 22, 2024
1 parent 3cbd140 commit da4ad72
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/ast.m
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,8 @@
:- type ast_pragma
---> ast_pragma(
astp_name :: string,
astp_args :: list(ast_pragma_arg)
astp_args :: list(ast_pragma_arg),
astp_context :: context
).

:- type ast_pragma_arg
Expand Down
2 changes: 1 addition & 1 deletion src/foreign.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
:- pred find_foreign_include_pragma(ast_pragma::in,
list(foreign_include)::in, list(foreign_include)::out) is det.

find_foreign_include_pragma(ast_pragma(Name, Args), !Includes) :-
find_foreign_include_pragma(ast_pragma(Name, Args, _Context), !Includes) :-
( if Name = "foreign_include" then
( if Args = [ast_pragma_arg(String)] then
Include = foreign_include(String),
Expand Down
3 changes: 2 additions & 1 deletion src/parse.m
Original file line number Diff line number Diff line change
Expand Up @@ -1612,6 +1612,7 @@
is det.

parse_pragma(Result, !Tokens) :-
get_context(!.Tokens, Context),
match_token(pragma_, MatchPragma, !Tokens),
match_token(ident, MatchIdent, !Tokens),
within(l_paren, zero_or_more_delimited(comma, parse_pragma_arg),
Expand All @@ -1621,7 +1622,7 @@
MatchIdent = ok(Ident),
MatchArgs = ok(Args)
then
Result = ok(ast_pragma(ast_pragma(Ident, Args)))
Result = ok(ast_pragma(ast_pragma(Ident, Args, Context)))
else
Result = combine_errors_3(MatchPragma, MatchIdent, MatchArgs)
).
Expand Down

0 comments on commit da4ad72

Please sign in to comment.