Skip to content

Commit

Permalink
Start Niecza::Grammar.
Browse files Browse the repository at this point in the history
We still don't have the NIL parser, but subclassing technology works.  An
installable STD would help a lot.
  • Loading branch information
sorear committed Jul 1, 2010
1 parent 39533fc commit 4c90cd6
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,3 +1,4 @@
Kernel.exe
Program.cs
*.swp
*.pmc
7 changes: 7 additions & 0 deletions Makefile
@@ -1,3 +1,10 @@
STDBASE=/usr/local/src/pugs/src/perl6
STDENV=PERL5LIB=$(STDBASE) PERL6LIB=$(STDBASE):$(STDBASE)/lib \
STD5PREFIX=$(STDBASE)/

all:
perl Compiler.pm > Program.cs
gmcs /target:exe Kernel.cs Program.cs

Niecza/Grammar.pmc: Niecza/Grammar.pm6
$(STDENV) $(STDBASE)/viv -5 -o Niecza/Grammar.pmc Niecza/Grammar.pm6
30 changes: 30 additions & 0 deletions Niecza/Grammar.pm6
@@ -0,0 +1,30 @@
use STD;

class Niecza;
grammar Grammar is STD { # viv doesn't handle :: in definitions well atm

method p6class () { ::Niecza::Grammar::P6 }

grammar P6 is STD::P6 {
method unitstart() {
%*LANG<Q> = ::Niecza::Grammar::Q ;
%*LANG<MAIN> = ::Niecza::Grammar::P6 ;
self;
}

token statement_prefix:sym<PRE-INIT>
{ :my %*MYSTERY; <sym> <.spacey> <blast> <.explain_mystery> }
token statement_control:sym<PRELUDE>
{ <sym> <.spacey> <quibble($¢.cursor_fresh( %*LANG<Q> ).tweak(:NIL))> }
}

grammar Q is STD::Q {
#}

multi method tweak(:$NIL!) { self.cursor_fresh( ::Niecza::Grammar::NIL ) }
}

grammar NIL is STD {
}

}

0 comments on commit 4c90cd6

Please sign in to comment.