Skip to content

Commit

Permalink
RakuAST: Actually implement the "just set" pragmas
Browse files Browse the repository at this point in the history
  • Loading branch information
niner committed Dec 3, 2022
1 parent 0b6e76f commit 877a08b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 16 deletions.
54 changes: 39 additions & 15 deletions src/Raku/ast/statements.rakumod
Expand Up @@ -1133,21 +1133,33 @@ class RakuAST::Statement::No is RakuAST::Statement is RakuAST::BeginTime
}

method IMPL-DO-PRAGMA(RakuAST::Resolver $resolver, Mu $arglist) {
# pragmas without args that just set_pragma to true
my %just_set_pragma := nqp::hash(
'internals', 1,
'MONKEY-TYPING', 1,
'MONKEY-SEE-NO-EVAL', 1,
'MONKEY-BRAINS', 1,
'MONKEY-GUTS', 1,
'MONKEY-BUSINESS', 1,
'MONKEY-TRAP', 1,
'MONKEY-SHINE', 1,
'MONKEY-WRENCH', 1,
'MONKEY-BARS', 1,
'nqp', 1,
'trace', 1,
'worries', 1,
);

return False unless $!module-name.is-identifier;
my str $name := self.IMPL-UNWRAP-LIST($!module-name.parts)[0].name;
if $name eq 'lib' {
$resolver.build-exception('X::Pragma::CannotWhat', :what<no>, :$name).throw;
}
elsif $name eq 'MONKEY-SEE-NO-EVAL' {
True
}
elsif $name eq 'MONKEY-GUTS' {
True
}
elsif $name eq 'nqp' {
elsif $name eq 'fatal' {
True
}
elsif $name eq 'fatal' {
elsif %just_set_pragma{$name} {
$*LANG.set_pragma($name, 0);
True
}
elsif $name eq 'precompilation' {
Expand Down Expand Up @@ -1209,6 +1221,23 @@ class RakuAST::Statement::Use is RakuAST::Statement is RakuAST::BeginTime
}

method IMPL-DO-PRAGMA(RakuAST::Resolver $resolver, Mu $arglist) {
# pragmas without args that just set_pragma to true
my %just_set_pragma := nqp::hash(
'internals', 1,
'MONKEY-TYPING', 1,
'MONKEY-SEE-NO-EVAL', 1,
'MONKEY-BRAINS', 1,
'MONKEY-GUTS', 1,
'MONKEY-BUSINESS', 1,
'MONKEY-TRAP', 1,
'MONKEY-SHINE', 1,
'MONKEY-WRENCH', 1,
'MONKEY-BARS', 1,
'nqp', 1,
'trace', 1,
'worries', 1,
);

return False unless $!module-name.is-identifier;
my str $name := self.IMPL-UNWRAP-LIST($!module-name.parts)[0].name;
if $name eq 'lib' {
Expand Down Expand Up @@ -1237,13 +1266,8 @@ class RakuAST::Statement::Use is RakuAST::Statement is RakuAST::BeginTime
}
True
}
elsif $name eq 'MONKEY-SEE-NO-EVAL' {
True
}
elsif $name eq 'MONKEY-GUTS' {
True
}
elsif $name eq 'nqp' {
elsif %just_set_pragma{$name} {
$*LANG.set_pragma($name, 1);
True
}
else {
Expand Down
2 changes: 1 addition & 1 deletion tools/build/raku-ast-compiler.nqp
Expand Up @@ -62,7 +62,7 @@ grammar RakuASTParser {
(
| <name>
| <attribute>
| $<variable>=['$' <.identifier>]
| $<variable>=['$' '*'? <.identifier>]

This comment has been minimized.

Copy link
@MasterDuke17

MasterDuke17 Dec 3, 2022

Contributor

Did you accidentally pull in part of @vrurg’s PR?

This comment has been minimized.

Copy link
@vrurg

vrurg Dec 3, 2022

Member

No, mine also has <sigil>.

| <string>
| ['/' <-[/]>+ '/' || '//' || '/' <?before \s* [\d | '$']>] # regex or // operator
| $<numeric>=[ \d+ ['.' \d*]? [<[eE]> \d+]? ]
Expand Down

0 comments on commit 877a08b

Please sign in to comment.