Skip to content
Browse files

Start Niecza::Grammar.

We still don't have the NIL parser, but subclassing technology works.  An
installable STD would help a lot.
  • Loading branch information...
1 parent 39533fc commit 4c90cd6f358abd90da3a8fcf5c9f50ed3f85f94b @sorear committed Jul 1, 2010
Showing with 38 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +7 −0 Makefile
  3. +30 −0 Niecza/Grammar.pm6
View
1 .gitignore
@@ -1,3 +1,4 @@
Kernel.exe
Program.cs
*.swp
+*.pmc
View
7 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
View
30 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.
Something went wrong with that request. Please try again.