Skip to content

Commit 33cc834

Browse files
committed
Get quote parsing to work again under QRegex. Now we parse and pass some of NQPs test suite again.
1 parent 5d63533 commit 33cc834

File tree

1 file changed

+48
-61
lines changed

1 file changed

+48
-61
lines changed

src/QHLL/Grammar.pm

Lines changed: 48 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -394,67 +394,53 @@ position C<pos>.
394394
};
395395
}
396396

397-
method quote_EXPR(*@args) {
398-
Q:PIR {
399-
.include 'src/Regex/constants.pir'
400-
401-
.local pmc self, cur_class, args
402-
self = find_lex 'self'
403-
cur_class = find_lex '$cursor_class'
404-
args = find_lex '@args'
405-
406-
.local pmc cur
407-
.local string target
408-
.local int pos
409-
410-
(cur, target, pos) = self.'!cursor_start'()
411-
412-
.local pmc quotemod, true
413-
.lex '%*QUOTEMOD', quotemod
414-
quotemod = new ['Hash']
415-
416-
true = box 1
417-
418-
419-
args_loop:
420-
unless args goto args_done
421-
.local string mod
422-
mod = shift args
423-
mod = substr mod, 1
424-
quotemod[mod] = true
425-
if mod == 'qq' goto opt_qq
426-
if mod == 'b' goto opt_b
427-
goto args_loop
428-
opt_qq:
429-
quotemod['s'] = true
430-
quotemod['a'] = true
431-
quotemod['h'] = true
432-
quotemod['f'] = true
433-
quotemod['c'] = true
434-
quotemod['b'] = true
435-
opt_b:
436-
quotemod['q'] = true
437-
goto args_loop
438-
args_done:
439-
440-
441-
.local pmc start, stop
442-
(start, stop) = self.'peek_delimiters'(target, pos)
443-
444-
.lex '$*QUOTE_START', start
445-
.lex '$*QUOTE_STOP', stop
446-
447-
$P10 = cur.'quote_delimited'()
448-
unless $P10 goto fail
449-
cur.'!mark_push'(0, CURSOR_FAIL, 0, $P10)
450-
$P10.'!cursor_names'('quote_delimited')
451-
pos = $P10.'pos'()
452-
cur.'!cursor_pass'(pos, 'quote_EXPR')
453-
goto done
454-
fail:
455-
done:
456-
.return (cur)
457-
};
397+
token quote_EXPR(*@args) {
398+
:my %*QUOTEMOD;
399+
:my $*QUOTE_START;
400+
:my $*QUOTE_STOP;
401+
{
402+
Q:PIR {
403+
.local pmc self, cur_class, args
404+
self = find_lex 'self'
405+
cur_class = find_lex '$cursor_class'
406+
args = find_lex '@args'
407+
408+
.local pmc quotemod, true
409+
quotemod = find_lex '%*QUOTEMOD'
410+
true = box 1
411+
412+
args_loop:
413+
unless args goto args_done
414+
.local string mod
415+
mod = shift args
416+
mod = substr mod, 1
417+
quotemod[mod] = true
418+
if mod == 'qq' goto opt_qq
419+
if mod == 'b' goto opt_b
420+
goto args_loop
421+
opt_qq:
422+
quotemod['s'] = true
423+
quotemod['a'] = true
424+
quotemod['h'] = true
425+
quotemod['f'] = true
426+
quotemod['c'] = true
427+
quotemod['b'] = true
428+
opt_b:
429+
quotemod['q'] = true
430+
goto args_loop
431+
args_done:
432+
433+
.local pmc start, stop
434+
.local string target
435+
.local int pos
436+
target = repr_get_attr_str self, cur_class, '$!target'
437+
pos = repr_get_attr_int self, cur_class, '$!pos'
438+
(start, stop) = self.'peek_delimiters'(target, pos)
439+
store_lex '$*QUOTE_START', start
440+
store_lex '$*QUOTE_STOP', stop
441+
}
442+
}
443+
<quote_delimited>
458444
}
459445

460446
our method quotemod_check($mod) {
@@ -509,6 +495,7 @@ position C<pos>.
509495

510496
our method split_words($words) {
511497
Q:PIR {
498+
.include 'src/Regex/constants.pir'
512499
.local string words
513500
$P0 = find_lex '$words'
514501
words = $P0

0 commit comments

Comments
 (0)