Skip to content

Instantly share code, notes, and snippets.

View pstuifzand's full-sized avatar

Peter Stuifzand pstuifzand

View GitHub Profile
@pstuifzand
pstuifzand / Dockerfile
Created July 24, 2013 13:06
Pinto Dockerfile
FROM ubuntu
RUN apt-get -y install curl perl
RUN apt-get -y install build-essential
RUN curl -L http://getpinto.stratopan.com | bash
EXPOSE 3111
VOLUME ["/var/pinto"]
RUN adduser --system --home /opt/local/pinto --shell /bin/false --disabled-login --group pinto
ENV PINTO_HOME /opt/local/pinto
ENV PINTO_REPOSITORY_ROOT /var/pinto
RUN /opt/local/pinto/bin/pinto init
@pstuifzand
pstuifzand / Lisp.pm
Last active March 20, 2016 06:36
Simple Lisp parser for Marpa
package Stuifzand::Lisp;
use Marpa::R2;
sub new {
my ($class) = @_;
my $self = bless {}, $class;
$self->{grammar} = Marpa::R2::Scanless::G->new(
@pstuifzand
pstuifzand / error-example.pl
Created May 18, 2013 15:31
Jeffrey reminded me of a technique for generating error messages that I tried some time ago. This technique is quite easy to implement now that completion events are implemented in Marpa. The following example shows how. The grammar contains a rule for a common error in a certain non-existent example language. Some people like to extend a class,…
#!/usr/bin/env perl
use strict;
use 5.10.0;
use Marpa::R2 2.054000;
use Data::Dumper;
my $grammar = Marpa::R2::Scanless::G->new({
source => \<<'SOURCE',
:start ::= <class definition>
@pstuifzand
pstuifzand / marpa-calc-eval.go
Created May 17, 2013 09:52
The first result of some work on the Go version of the wrapper for Marpa. You can have more control over the evaluator. In the first version (in 'go-marpa') you needed to specify actions on interface{} parameters. Now you can create your own stack with your own type. This uses the go feature where a switch statement values don't need to be const…
/* Copyright (C) 2013 Peter Stuifzand
This program 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.
This program 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
@pstuifzand
pstuifzand / test.pl
Created May 6, 2013 21:17
Example of completion events in Marpa.
use 5.10.0;
use Marpa::R2;
use Data::Dumper;
my $grammar = Marpa::R2::Scanless::G->new({
source => \<<'SOURCE',
:start ::= numbers
event number_found = completed number
package ParserZPL;
use 5.10.0;
use Marpa::R2 '2.051_010';
sub parse_zpl {
my ($input) = @_;
my $grammar = Marpa::R2::Scanless::G->new({
default_action => '::array',
source => \<<'SOURCE',
@pstuifzand
pstuifzand / output.txt
Created April 15, 2013 08:07
If I call show_progress then lexeme_read doesn't work anymore.
P0 @0-0 [:start] -> . test
P1 @0-0 test -> . marker end
Can't locate object method "lexeme_read" via package "Marpa::R2::Recognizer" at t/show_progress.t line 20.
@pstuifzand
pstuifzand / MonthTotals.pm
Last active December 15, 2015 08:29
Build a datastructure from a DSL, calculate and display totals for each subheader.
package MonthTotals;
use 5.010;
use strict;
use Marpa::R2;
use Data::Dumper;
sub new {
my ($class) = @_;
my $self = bless {
grammar => Marpa::R2::Scanless::G->new({
@pstuifzand
pstuifzand / ast.pl
Last active December 12, 2015 09:39 — forked from jeffreykegler/ast.pl
#!/usr/bin/env perl
# Copyright 2013 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
@pstuifzand
pstuifzand / test.pl
Created January 29, 2013 11:07
Unproductive symbol: digits at test.pl line 7
package Parse::ProductName;
use Marpa::R2;
sub new {
my($class) = @_;
my $grammar = Marpa::R2::Scanless::G->new({
action_object => 'Parse::ProductName::Actions',
default_action => 'do_first_arg',
source => \<<'SOURCE'