Skip to content

Instantly share code, notes, and snippets.

View jeffreykegler's full-sized avatar

Jeffrey Kegler jeffreykegler

View GitHub Profile
@jeffreykegler
jeffreykegler / OP1.pm
Created August 22, 2012 16:39
Precedence parsing, example 1
package Marpa::Demo::OP1;
use 5.010;
use strict;
use warnings;
use English qw( -no_match_vars );
use Marpa::XS;
sub rules { shift; return $_[0]; }
@jeffreykegler
jeffreykegler / OP1.pm
Created August 22, 2012 16:42
Precedence parsing, example 2
package Marpa::Demo::OP1;
use 5.010;
use strict;
use warnings;
use English qw( -no_match_vars );
use Marpa::XS;
sub rules { shift; return $_[0]; }
@jeffreykegler
jeffreykegler / dsl3.pl
Created August 30, 2012 02:39
Simple calculator DSL, for blog post
#!perl
# This calculator contains *TWO* DSL's.
# The first one is for the calculator itself.
# The calculator's grammar is written in OP2.
# OP2 is the second DSL, and its code is the
# second half of this file.
use 5.010;
use strict;
@jeffreykegler
jeffreykegler / marpa_r2_html_fmt
Created September 14, 2012 23:46
html_fmt -- HTML Reformatter
#!/usr/bin/perl
# Copyright 2012 Jeffrey Kegler
# This file is part of Marpa::R2. Marpa::R2 is free software: you can
# redistribute it and/or modify it under the terms of the GNU Lesser
# General Public License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
#
# Marpa::R2 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@jeffreykegler
jeffreykegler / gist:3869482
Created October 11, 2012 00:49
Marpa::R2::HTML Grammar Configuration file
# Copyright 2012 Jeffrey Kegler
# This file is part of Marpa::R2. Marpa::R2 is free software: you can
# redistribute it and/or modify it under the terms of the GNU Lesser
# General Public License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
#
# Marpa::R2 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
@jeffreykegler
jeffreykegler / acme-block-block.sh
Created October 11, 2012 03:43
Scripts for the Configurable HTML parser blog post
cp default.cfg test.cfg
echo "ELE_acme is a FLO_block included in GRP_block" >> test.cfg
echo '<acme>-during-<span>-more inline stuff-<p>-new block-' |
marpa_r2_html_fmt --no-added-tag --compile test.cfg
@jeffreykegler
jeffreykegler / default.txt
Created October 16, 2012 20:04
Marpa::R2::HTML Grammar Configuration file, new format
# Copyright 2012 Jeffrey Kegler
# This file is part of Marpa::R2. Marpa::R2 is free software: you can
# redistribute it and/or modify it under the terms of the GNU Lesser
# General Public License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
#
# Marpa::R2 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
@jeffreykegler
jeffreykegler / reject_text.txt
Created October 21, 2012 03:32
Marpa::R2::HTML example configuration file for changing Ruby Slippers
# Copyright 2012 Jeffrey Kegler
# This file is part of Marpa::R2. Marpa::R2 is free software: you can
# redistribute it and/or modify it under the terms of the GNU Lesser
# General Public License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
#
# Marpa::R2 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
@jeffreykegler
jeffreykegler / error.pl
Created October 29, 2012 16:50
Code for blog post on error reporting
#!/usr/bin/perl
# Copyright 2012 Jeffrey Kegler
# This file is part of Marpa::R2. Marpa::R2 is free software: you can
# redistribute it and/or modify it under the terms of the GNU Lesser
# General Public License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
#
# Marpa::R2 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@jeffreykegler
jeffreykegler / Makefile
Created November 12, 2012 02:50
Code for blog post on pattern searching
dummy:
test:
sh test.sh | diff - test.out