Skip to content

Commit 4f77966

Browse files
CIAvashalecthomas
authored andcommitted
Raku: Add more test data
1 parent 22fac1f commit 4f77966

File tree

1 file changed

+88
-3
lines changed

1 file changed

+88
-3
lines changed

Diff for: lexers/testdata/raku.actual

+88-3
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,17 @@ heading
1111
fmt.Println("Hello from Go")
1212
=end code
1313
14+
=begin DESCRIPTION
15+
Some description
16+
=item one item
17+
=end DESCRIPTION
18+
1419
=for defn :numbered
1520
We
1621
Need
1722
Numbers
1823
19-
=end pod
24+
=end pod
2025

2126
say $=pod[0].config<numbered>;
2227

@@ -43,7 +48,7 @@ multi sub fib (\n where * > 1) {
4348
say fib 10;
4449
# OUTPUT: 55
4550

46-
#| C<Shape> role
51+
#| B<A C<<uh U<Shape> umm>> role>
4752
role Shape {
4853
method area { ... }
4954

@@ -129,6 +134,82 @@ key2 = value2
129134
key3=value3
130135
END
131136

137+
grammar Nested {
138+
token TOP { <block> <section>* { if $/ { say $/ } } }
139+
token block {
140+
<?before <.[\)\]\}]>>
141+
}
142+
143+
token you_are_here {
144+
<?{ nqp::getlexdyn('$?FILES') ~~ /\.setting$/ }> ||
145+
\w+ 'some text' \d+
146+
{ self.typed_panic('X::Syntax::Reserved',
147+
reserved => 'use of {YOU_ARE_HERE} outside of a setting',
148+
instead => ' (use whitespace if not a setting, or rename file with .setting extension?)');
149+
}
150+
}
151+
152+
rule statement_control:sym<if> {
153+
$<sym>=[if|with]<.kok> {}
154+
<xblock(~$<sym>[0] ~~ /with/ ?? $PBLOCK_REQUIRED_TOPIC !! $PBLOCK_NO_TOPIC)>
155+
[
156+
[
157+
| 'else'\h*'if' <.typed_panic: 'X::Syntax::Malformed::Elsif'>
158+
| 'elif' { $/.typed_panic('X::Syntax::Malformed::Elsif', what => "elif") }
159+
| $<sym>='elsif' <xblock>
160+
| $<sym>='orwith' <xblock($PBLOCK_REQUIRED_TOPIC)>
161+
]
162+
]*
163+
{}
164+
[
165+
'else'
166+
<else=.pblock(~$<sym>[-1] ~~ /with/ ?? $PBLOCK_REQUIRED_TOPIC !! $PBLOCK_NO_TOPIC)>
167+
]?
168+
}
169+
170+
token special_variable:sym<$\\> {
171+
'$\\' <?before \s | ',' | '=' | <.terminator> >
172+
<.obsvar('$\\')>
173+
}
174+
175+
token type_declarator:sym<enum> {
176+
:my %*MYSTERY;
177+
[ <?[<(«]> <term> <.ws> || <.panic: 'An enum must supply an expression using <>, «», or ()'> ]
178+
<.explain_mystery> <.cry_sorrows>
179+
<?{
180+
elsif !($text ~~ /^(\w|\:)+$/) {
181+
$/.obs($bad, "$sigil\($text) for hard ref or $sigil\::($text) for symbolic ref");
182+
}
183+
}>
184+
}
185+
186+
token rad_number {
187+
:my $rad_digits := token rad_digits { <rad_digit>+ [ _ <rad_digit>+ ]* };
188+
<O(|%methodcall)>
189+
<O=.revO($<infixish>)>
190+
<code=[A..Z]>
191+
}
192+
193+
token pod_balanced_braces {
194+
<?{ nqp::chars($<start>) == $*POD_ANGLE_COUNT || $*POD_ANGLE_COUNT < 0 }>
195+
}
196+
197+
token routine_declarator:sym<macro> {
198+
:my $*LINE_NO := HLL::Compiler.lineof(self.orig(), self.from(), :cache(1));
199+
<!!{ nqp::rebless($/, self.slang_grammar('MAIN')); 1 }>
200+
<sym> <.end_keyword> <macro_def()>
201+
}
202+
203+
token routine_declarator:sym<macro> {
204+
:my $*LINE_NO := HLL::Compiler.lineof(self.orig(), self.from(), :cache(1));
205+
<sym> <.end_keyword> <macro_def()>
206+
}
207+
208+
token integer {
209+
<!!before ['.' <?before \s | ',' | '=' | ':' <!before <coloncircumfix <OPER=prefix> > > | <.terminator> | $ > <.typed_sorry: 'X::Syntax::Number::IllegalDecimal'>]? >
210+
[ <?before '_' '_'+\d> <.sorry: "Only isolated underscores are allowed inside numbers"> ]?
211+
}
212+
}
132213

133214
say $match<block><pair>[0]<value>;
134215
# OUTPUT: 「value1」
@@ -237,6 +318,8 @@ rx/:i
237318

238319
<?before <.[\)\]\}]>>
239320

321+
\/
322+
240323
$<string>=( [ $<part>=[abc] ]* % '-' )
241324
$<variable>=\w+ '=' $<value>=\w+
242325
a <( b )> c
@@ -316,6 +399,9 @@ say Q:b[Testing];
316399
"some $variable:some('adverb').method() testing";
317400
"some func() testing";
318401
"some func:some<adverb>() testing";
402+
"some &func() testing";
403+
"some &func($test) testing";
404+
"some &func:some<adverb>() testing";
319405
say "Something foo(2) $a.succ(2+3, $some_variable) $a.some-method() @more $_.Str(2) $_: { $_ * 2 }";
320406

321407
#`[[
@@ -384,7 +470,6 @@ for <a b c> {
384470
#|[[
385471
multiline pod declaration]
386472
]]
387-
388473
grammar Calculator {
389474
token TOP { <calc-op> }
390475

0 commit comments

Comments
 (0)