View GetoptSubset.pm
package GetoptSubset;
# Copyright 2017 Lukas Atkinson
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
View offside rule.md

Certain languages like Python use leading indentation to denote blocks. Wouldn't it be nice if a Marpa frontend like the IRIF would have support for this? Well, the problem is that implementing the Off-side Rule is similarly difficult to implementing here-docs: both are non-context free constructs, but are easy to implement by maintaining state in the scanner.

Consider this piece of Python code:

def foo(x, y):
    return x + (2*
y)

foo(1, 2) #=> 5
View MarpaX::Interface::Inline Specification.md

MarpaX::Interface::Inline Specification

The MarpaX::Interface::Inline module provides the Inline Rule Interface (IRIF) to write grammars for the [Marpa parser generator][Marpa::R2]. While Marpa already provides the Scanless Interface (SLIF), the IRIF tries to provide a more productive frontend:

  • Longest-Acceptable-Token Matching: The builtin lexer is smart and only tries to find tokens that can actually be used at the current position. This makes it easier to nest languages.
  • Inline Rules and Quantifiers: A regex like syntax allows you to specify rules where you need them – and not every rule has to be named. Quantifiers include support for Perl6's separation operator %.
  • Inline Actions: Each production is associated with an action that builds the AST. With the IRIF, these are specified inline, directly after the rule which they operate on.
View report.pl
use strict; use warnings;
use feature 'say';
use autodie;
use File::Slurp;
use Mojo;
use List::MoreUtils 'uniq';
use Data::Dump qw/dd pp/;
my %urls = (
View test.pl
use 5.018; use strict; use warnings; use Benchmark ':all';
cmpthese $ARGV[0] => {
grep => \&with_grep,
grep_light => \&with_grep_light,
splice => \&with_splice,
slice => \&with_slice,
copy => \&with_copy,
};
View gist:5866793
use strict; use warnings; use 5.010;
my $ast = bless( [
[
bless( [
bless( [
bless( [
bless( ['Myvalue.xyz'], 'Ast::Var' ),
'==',
bless( ['1'], 'Ast::Literal' )
View gist:5866146
use strict; use warnings; use 5.010;
my $ast = bless( [
[
bless( [
bless( [
bless( [
bless( ['Myvalue.xyz'], 'Ast::Var' ),
'==',
bless( ['1'], 'Ast::Literal' )
View gist:5866025
use strict; use warnings; use 5.010;
use Data::Dumper;
my $ast = bless( [
[
bless( [
bless( [
bless( [
bless( ['Myvalue.xyz'], 'Ast::Var' ),
'==',
View gist:5854616
use strict; use warnings; use 5.010;
use Data::Dumper;
my $data = <<'END';
If ((Myvalue.xyz == 1) Or (Frmae_1.signal_1 == 1)) Then a = 1
Else a = 0;
END
my $ast = Parser->parse(\$data);
View solar_game.pl
#########################################
# Solar Game #
# #
# (C) 2013 Donovan Roudabush #
# GPU/Creative Commons #
# #
# sharksfan98@gmail.com #
# github.com/sharksfan98/solargame #
#########################################