Skip to content

Instantly share code, notes, and snippets.

@rns
rns / solarradiation_ecma_ast.out
Created May 18, 2016 11:03
ECMAScript::AST traversal example
# 1: Program
# 2: Statement
# 3: VariableStatement
# 3: VAR: 'var' @0:3
# 3: IDENTIFIER: 'i' @4:5
# 3: ASSIGN: '=' @6:7
# 3: DECIMALLITERAL: '0' @8:9
# 2: Statement
# 3: ExpressionStatement
# 3: IDENTIFIER: 'i' @11:12
@rns
rns / sl_jirotka.t.out
Created April 11, 2016 13:35
output of sl_jirotka.t
1..7
G1 S0 :start -- Internal G1 start symbol
G1 S1 Input
G1 S2 Statement
G1 S3 SEPARATOR
G1 S4 CREATE
G1 S5 TypeDef
G1 S6 METRIC
G1 S7 ID_METRIC
G1 S8 AS
use 5.010;
use strict;
use warnings;
use Test::More tests => 3;
use Marpa::R2;
use Data::Dumper;
$Data::Dumper::Indent = 0;
$Data::Dumper::Terse = 1;
@rns
rns / ast-full-traverser.out
Last active October 22, 2015 09:09
ast full travserser template
Ambiguous parse: 5 alternatives.
# Alternative 1:
['Expr',['Expr',['Expr',['Expr',['Number','2']],'**',['Expr',['Number','7']]],'-',['Expr',['Number','3']]],'**',['Expr',['Number','10']]]
# Alternative 2:
['Expr',['Expr',['Expr',['Number','2']],'**',['Expr',['Expr',['Number','7']],'-',['Expr',['Number','3']]]],'**',['Expr',['Number','10']]]
# Alternative 3:
['Expr',['Expr',['Number','2']],'**',['Expr',['Expr',['Expr',['Number','7']],'-',['Expr',['Number','3']]],'**',['Expr',['Number','10']]]]
# Alternative 4:
['Expr',['Expr',['Number','2']],'**',['Expr',['Expr',['Number','7']],'-',['Expr',['Expr',['Number','3']],'**',['Expr',['Number','10']]]]]
# Alternative 5:
@rns
rns / deny_allow.pl
Created September 11, 2015 14:49
deny_allow.pl with parens to hide eol
#!/usr/bin/env perl
# Adapted from tutorial Copyright (c) 2013 Peter Stuifzand
# at http://marpa-guide.github.io/chapter3.html
# In particular this is an attempt at Exercise 3
use strict;
use warnings;
package Authorization;
@rns
rns / deny-allow.pl
Last active September 11, 2015 04:03 — forked from spacebat/deny-allow.pl
#!/usr/bin/env perl
# Adapted from tutorial Copyright (c) 2013 Peter Stuifzand
# at http://marpa-guide.github.io/chapter3.html
# In particular this is an attempt at Exercise 3
use strict;
use warnings;
package Authorization;
@rns
rns / bslr.pl
Last active August 27, 2015 21:02
Benchmark sequences vs left recursion
#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;
use Marpa::R2;
use Getopt::Long;
\[
'scutil',
'scutil',
'> open',
'> show',
[
'path',
'State:/Network/Service/0F70B221-EEF7-4ACC-96D8-ECBA3A15F132/IPv4'
],
'<dictionary>',
assert(2^-2 == 1/4 and -2^- -2 == - - -4);
use 5.010;
use strict;
use warnings;
use Data::Dumper;
$Data::Dumper::Indent = 0;
$Data::Dumper::Terse = 1;
$Data::Dumper::Deepcopy = 1;
use Marpa::R2;