Skip to content

Instantly share code, notes, and snippets.

View FROGGS's full-sized avatar

Tobias Leich FROGGS

  • Germany (near Berlin)
View GitHub Profile
@FROGGS
FROGGS / 1.diff
Created February 25, 2013 23:36
cclass oddity 2000
diff --git a/src/QRegex/P6Regex/Actions.nqp b/src/QRegex/P6Regex/Actions.nqp
index dff6757..1ab5bc3 100755
--- a/src/QRegex/P6Regex/Actions.nqp
+++ b/src/QRegex/P6Regex/Actions.nqp
@@ -432,6 +432,7 @@ class QRegex::P6Regex::Actions is HLL::Actions {
while $i < $n {
my $ast := $clist[$i].ast;
if $ast.negate {
+ say("method assertion:sym<[>($/) while negate");
if $ast.rxtype eq 'cclass' {
@FROGGS
FROGGS / nfa.pl
Last active December 14, 2015 13:38
working NFA example
sub store_regex_alt_nfa($code_obj, $key, @alternatives) {
my @saved;
for @alternatives {
@saved.push($_.save(:non_empty));
}
$code_obj.SET_ALT_NFA($key, @saved);
}
my $code_obj := nqp::create(NQPRegex);
my $ast := QAST::Regex.new(
# References ISO/IEC 9899:1990 "Information technology - Programming Language C" (C89 for short)
grammar C::StdC89Lexer;
#rule TOP {
# ^ <c-token>+ $
#}
# SS 6.4
proto token c-token {*}
@FROGGS
FROGGS / use_v5.diff
Last active December 15, 2015 15:59
diff --git a/src/Perl6/Grammar.pm b/src/Perl6/Grammar.pm
index abf96b7..c5f9177 100644
--- a/src/Perl6/Grammar.pm
+++ b/src/Perl6/Grammar.pm
@@ -1156,7 +1156,12 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
$<doc>=[ 'DOC' \h+ ]?
<sym> <.ws>
[
- | <version>
+ | <version> <?{ ~$<version><vnum>[0] ne '5' }>
@FROGGS
FROGGS / RT117415.diff
Last active December 17, 2015 10:49
RT117415 - patch for "Use of regex characters as substitution delimiter fails"
diff --git a/src/QRegex/P5Regex/Grammar.nqp b/src/QRegex/P5Regex/Grammar.nqp
index e29167b..5be2be3 100644
--- a/src/QRegex/P5Regex/Grammar.nqp
+++ b/src/QRegex/P5Regex/Grammar.nqp
@@ -69,7 +69,7 @@ grammar QRegex::P5Regex::Grammar is HLL::Grammar {
<![|)]>
<!rxstopper>
<atom>
- [ <.ws> <quantifier=p5quantifier> ]**0..1
+ [ <.ws> <!before <rxstopper> > <quantifier=p5quantifier> ]**0..1
@FROGGS
FROGGS / codepoints.diff
Created July 9, 2013 12:48
Super Slow Support(tm) for 32-bit unicode codepoints in nqp::chars() and nqp::substr(). This increases rakudo's parse time from 57s to nearly ten minutes.
diff --git a/src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java b/src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java
index c193007..e1d3418 100644
--- a/src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java
+++ b/src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java
@@ -2648,7 +2648,7 @@ public final class Ops {
/* String operations. */
public static long chars(String val) {
- return val.length();
+ return val.codePointCount(0, val.length());
# generate code that runs the block only once
make QAST::Stmts.new(
QAST::Op.new(
:op('if'),
QAST::Op.new( :op('p6stateinit') ),
QAST::Op.new(
:op('p6store'),
QAST::Var.new( :name($sym), :scope('lexical') ),
QAST::Op.new( :op('call'), $<blorst>.ast )
),
@FROGGS
FROGGS / add-i-mt.t
Created July 31, 2013 23:18
= Call it as: nqp add-i-mt. = It computes the sum of the two input RPMCAs (line 80/81), and returns the array containing the sums.
use QAST;
plan(1);
sub is_pirt_result($producer, $expected, $desc) {
my $pirt := $producer();
my $pir := $pirt.pir();
my $pbc := nqp::getcomp('nqp').compile($pir, :from('pir'));
$pbc := $pbc();
if nqp::islist($pbc) {

test script

sub ed_green_thread() { Q:PIR {
    .local pmc interp, task, block, block_name
    .local string name
    interp     = getinterp
    task       = interp.'current_task'()
    block_name = pop task
    name       = block_name
@FROGGS
FROGGS / unposal.md
Last active December 22, 2015 11:19
nqp::(un)pack proposal
my @items := nqp::unpack( 'U2 (xxxC)[W]', $binary_string );

I, FROGGS, solemnly propose the implementation of pack() and unpack in nqp.

For one, these are useful for Perl 5 and Perl 6, and the other reason is that they should be pretty fast. If a backend then can even provide a faster implementation (e.g. in C), then it would be easy to #ifdef it in.

The signatures I propose are: