Author: pmichaud
Date: Tue Jun 12 07:42:38 2007
New Revision: 18947

Added:
   trunk/runtime/parrot/library/PGE/Perl6Grammar.pir
      - copied, changed from r18940, 
/trunk/runtime/parrot/library/PGE/P6Grammar.pir
Modified:
   trunk/MANIFEST
   trunk/config/gen/makefiles/root.in

Log:
[pge]:
* Add Perl6Grammar.pir, which is like P6Grammar.pir but uses the new S05
  quoting syntax (i.e., Perl6Regex instead of P6Regex).


Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST      (original)
+++ trunk/MANIFEST      Tue Jun 12 07:42:38 2007
@@ -2390,6 +2390,7 @@
 runtime/parrot/library/PGE/Glob.pir                         [library]
 runtime/parrot/library/PGE/Hs.pir                           [library]
 runtime/parrot/library/PGE/P6Grammar.pir                    [library]
+runtime/parrot/library/PGE/Perl6Grammar.pir                 [library]
 runtime/parrot/library/PGE/Text.pir                         [library]
 runtime/parrot/library/PGE/Util.pir                         [library]
 runtime/parrot/library/Parrot/Capture_PIR.pir               [library]

Modified: trunk/config/gen/makefiles/root.in
==============================================================================
--- trunk/config/gen/makefiles/root.in  (original)
+++ trunk/config/gen/makefiles/root.in  Tue Jun 12 07:42:38 2007
@@ -317,6 +317,7 @@
     $(LIBRARY_DIR)/PGE/Dumper.pbc \
     $(LIBRARY_DIR)/PGE/Glob.pbc \
     $(LIBRARY_DIR)/PGE/P6Grammar.pbc \
+    $(LIBRARY_DIR)/PGE/Perl6Grammar.pbc \
     $(LIBRARY_DIR)/PGE/Text.pbc \
     $(LIBRARY_DIR)/PGE/Util.pbc \
     $(LIBRARY_DIR)/Stream/Base.pbc \

Copied: trunk/runtime/parrot/library/PGE/Perl6Grammar.pir (from r18940, 
/trunk/runtime/parrot/library/PGE/P6Grammar.pir)
==============================================================================
--- /trunk/runtime/parrot/library/PGE/P6Grammar.pir     (original)
+++ trunk/runtime/parrot/library/PGE/Perl6Grammar.pir   Tue Jun 12 07:42:38 2007
@@ -1,18 +1,18 @@
 =head1 TITLE
 
-P6Grammar - compiler for Perl 6 grammars
+Perl6Grammar - compiler for Perl 6 grammars
 
 =head1 SYNOPSIS
 
 Command-line:
 
-    parrot P6Grammar.pir [options] file ...
+    parrot Perl6Grammar.pir [options] file ...
 
 From PIR:
     .local string grammar_source
     .local pmc pgc
 
-    pgc = compreg 'PGE::P6Grammar'
+    pgc = compreg 'PGE::Perl6Grammar'
 
     # Compile grammar_source to PIR
     $P1 = pgc(grammar_source, 'target' => 'PIR')
@@ -55,13 +55,13 @@
 
 =cut
 
-.namespace [ 'PGE::P6Grammar::Compiler' ]
+.namespace [ 'PGE::Perl6Grammar::Compiler' ]
 
 .sub 'main' :main
     .param pmc args
     .local pmc pgc
 
-    pgc = compreg 'PGE::P6Grammar'
+    pgc = compreg 'PGE::Perl6Grammar'
     pgc.'command_line'(args, 'target'=>'PIR', 'combine'=>1)
     .return ()
 .end
@@ -74,34 +74,39 @@
     load_bytecode 'Parrot/HLLCompiler.pbc'
 
     .local pmc p6regex
-    p6regex = compreg 'PGE::P6Regex'
+    p6regex = compreg 'PGE::Perl6Regex'
 
-    $S0 = "<?ident> [ \:\: <?ident> ]*"
-    p6regex($S0, 'grammar'=>'PGE::P6Grammar', 'name'=>'name')
+    $P0 = get_hll_global ['PGE::Perl6Regex'], 'regex'
+    set_hll_global ['PGE::Perl6Grammar'], 'regex', $P0
 
-    $S0 = '[ \# \N* | \s+ | <?pod_comment> ]* :::'
-    p6regex($S0, 'grammar'=>'PGE::P6Grammar', 'name'=>'ws')
+    $S0 = "<?ident> [ '::' <?ident> ]*"
+    p6regex($S0, 'grammar'=>'PGE::Perl6Grammar', 'name'=>'name')
+
+    $S0 = "[ '#' \\N* | \\s+ | <?pod_comment> ]* :::"
+    p6regex($S0, 'grammar'=>'PGE::Perl6Grammar', 'name'=>'ws')
 
     $S0 = <<'      END_POD_COMMENT_RULE'
-      ^^ = [ [ cut \h*: | end [\h\N*]? ]
+      ^^ '=' [ [ cut \h*: | end [\h\N*]? ]
            | for [ \h\N+: ] \n [ \N+\n ]*:
-           | \w\N*: \n .*? \n = [ cut \h*: | end [\h\N*:]? ]
+           | \w\N*: \n .*? \n '=' [ cut \h*: | end [\h\N*:]? ]
            ]
            [\n|$]
       END_POD_COMMENT_RULE
-    p6regex($S0, 'grammar'=>'PGE::P6Grammar', 'name'=>'pod_comment')
+    p6regex($S0, 'grammar'=>'PGE::Perl6Grammar', 'name'=>'pod_comment')
 
     $S0 = <<'      END_ARG_RULE'
-         ' (<-[']>*:) '
-      |  " (<-["]>*:) "
-      | \( (<-[)]>*:) \)
-      | \< (<-[>]>*:) \>
+      [  \' (<-[']>*:) \'
+      | '"' (<-["]>*:) '"'
+      | '(' (<-[)]>*:) ')'
+      | '<' (<-[>]>*:) '>'
+      | '«' (<-[»]>*:) '»'
       | (\S+)
+      ]
       END_ARG_RULE
-    p6regex($S0, 'grammar'=>'PGE::P6Grammar', 'name'=>'arg')
+    p6regex($S0, 'grammar'=>'PGE::Perl6Grammar', 'name'=>'arg')
 
     $S0 = <<'      STMT_PARSE'
-        $<cmd>:=(grammar) $<name>:=<arg> ;?
+        $<cmd>:=(grammar) $<name>:=<arg> ';'?
       | $<cmd>:=(regex|token|rule) 
           $<name>:=<arg>
           $<optable>:=(is optable)?
@@ -109,17 +114,17 @@
       | [multi]? $<cmd>:=(proto)
           $<name>:=<arg>
           ( is $<trait>:=[\w+]<arg>? )*
-          [ \{ <-[}]>*: \} | ; | <?PGE::Util::die: missing proto/sub body> ]
+          [ \{ <-[}]>*: \} | ';' | <?PGE::Util::die: missing proto/sub body> ]
       | [$|<PGE::Util::die: unrecognized statement>]
       STMT_PARSE
-    $P0 = p6regex($S0, 'grammar'=>'PGE::P6Grammar', 'name'=>'statement', 
'w'=>1)
+    $P0 = p6regex($S0, 'grammar'=>'PGE::Perl6Grammar', 'name'=>'statement', 
'w'=>1)
 
 
-    ##   create the PGE::P6Grammar compiler object
+    ##   create the PGE::Perl6Grammar compiler object
     .local pmc pgc
-    $P99 = subclass 'HLLCompiler', 'PGE::P6Grammar::Compiler'
-    pgc = new [ 'PGE::P6Grammar::Compiler' ]
-    pgc.'language'('PGE::P6Grammar')
+    $P99 = subclass 'HLLCompiler', 'PGE::Perl6Grammar::Compiler'
+    pgc = new [ 'PGE::Perl6Grammar::Compiler' ]
+    pgc.'language'('PGE::Perl6Grammar')
 .end
 
 
@@ -140,10 +145,10 @@
     # get our initial match object
     .local pmc match 
     $P0 = get_hll_global ['PGE::Match'], 'newfrom'
-    match = $P0(source, 0, 'PGE::P6Grammar')
+    match = $P0(source, 0, 'PGE::Perl6Grammar')
 
     .local pmc stmtrule
-    stmtrule = get_hll_global ['PGE::P6Grammar'], 'statement'
+    stmtrule = get_hll_global ['PGE::Perl6Grammar'], 'statement'
 
   stmt_loop:
     match = stmtrule(match)
@@ -270,7 +275,7 @@
     if $I0 goto rulepir_optable
     ##   compile the rule to pir
     .local pmc p6regex, regex, rulepir
-    p6regex = compreg 'PGE::P6Regex'
+    p6regex = compreg 'PGE::Perl6Regex'
     regex = stmt['regex']
     rulepir = p6regex(regex, 'target'=>'PIR', adverbs :flat :named)
     goto with_rulepir

Reply via email to