You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@corinthia.apache.org by pm...@apache.org on 2015/08/05 16:51:15 UTC

incubator-corinthia git commit: Flat: Adjust syntax for grammar definitions

Repository: incubator-corinthia
Updated Branches:
  refs/heads/master e9ffeb107 -> 7ee1489ae


Flat: Adjust syntax for grammar definitions

Change the syntax used for specifying grammar definitions as follows:

- Definitions contain a colon after the identifier instead of "<-", and
  must now end with a semicolon, e.g.:

    Grammar    : Spacing Definition+ EndOfFile;
    Definition : Identifier COLON Expression SEMI;

- Use | instead of / to delimit choices. The former is what is normally
  used for BNF-style grammar syntax and is likely to be more familiar to
  people. The original PEG grammar indicated that / was to denote
  ordered choice, but in Flat we'll just say that | is implicitly
  ordered choice.

- As a matter of style, use double quotes instead of single quotes for
  representing literals in the built-in grammar file, and when printing
  out grammars. This is not a change in the language, but just in the
  default representation.

The built-in grammar file, in experiments/flat/grammars, is now called
flat.flat instead of peg.peg, to reflect the fact that we're now moving
towards our own syntax, and adding new constructs that are not in pure
PEGs.


Project: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/commit/7ee1489a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/7ee1489a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/7ee1489a

Branch: refs/heads/master
Commit: 7ee1489aeabf7d6caff121ed1f26001cdd2fca3b
Parents: e9ffeb1
Author: Peter Kelly <pe...@uxproductivity.com>
Authored: Wed Aug 5 21:37:22 2015 +0700
Committer: Peter Kelly <pe...@uxproductivity.com>
Committed: Wed Aug 5 21:43:45 2015 +0700

----------------------------------------------------------------------
 experiments/flat/grammars/flat.flat |  46 ++++++
 experiments/flat/grammars/peg.peg   |  45 ------
 experiments/flat/src/BuildGrammar.c |   2 +-
 experiments/flat/src/Builtin.c      | 267 ++++++++++++++++---------------
 experiments/flat/src/Builtin.h      |  91 +++++------
 experiments/flat/src/Expression.c   |   4 +-
 experiments/flat/src/Grammar.c      |  10 +-
 experiments/flat/src/Util.c         |   8 +-
 8 files changed, 241 insertions(+), 232 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7ee1489a/experiments/flat/grammars/flat.flat
----------------------------------------------------------------------
diff --git a/experiments/flat/grammars/flat.flat b/experiments/flat/grammars/flat.flat
new file mode 100644
index 0000000..bf6e794
--- /dev/null
+++ b/experiments/flat/grammars/flat.flat
@@ -0,0 +1,46 @@
+Grammar    : Spacing Definition+ EndOfFile;
+Definition : Identifier COLON Expression SEMI;
+Expression : Sequence (BAR Sequence)*;
+Sequence   : Prefix*;
+Prefix     : (AND | NOT)? Suffix;
+Suffix     : Primary (QUESTION | STAR | PLUS)?;
+Primary    : Identifier !COLON
+           | DOLLAR OPEN Expression CLOSE
+           | OPEN Expression CLOSE
+           | Literal
+           | Class
+           | DOT;
+Identifier : $(IdentStart IdentCont*) Spacing;
+IdentStart : [a-zA-Z_];
+IdentCont  : IdentStart
+           | [0-9];
+Literal    : ['] (!['] Char)* ['] Spacing
+           | ["] (!["] Char)* ["] Spacing;
+Class      : "[" (!"]" Range)* "]" Spacing;
+Range      : Char "-" Char
+           | Char;
+Char       : "\\" [nrt'"\[\]\\]
+           | "\\" [0-2] [0-7] [0-7]
+           | "\\" [0-7] [0-7]?
+           | !"\\" .;
+COLON      : ":" Spacing;
+SEMI       : ";" Spacing;
+BAR        : "|" Spacing;
+AND        : "&" Spacing;
+NOT        : "!" Spacing;
+QUESTION   : "?" Spacing;
+STAR       : "*" Spacing;
+PLUS       : "+" Spacing;
+OPEN       : "(" Spacing;
+CLOSE      : ")" Spacing;
+DOT        : "." Spacing;
+DOLLAR     : "$" Spacing;
+Spacing    : $((Space | Comment)*);
+Comment    : "#" (!EndOfLine .)* EndOfLine;
+Space      : " "
+           | "\t"
+           | EndOfLine;
+EndOfLine  : "\r\n"
+           | "\n"
+           | "\r";
+EndOfFile  : !.;

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7ee1489a/experiments/flat/grammars/peg.peg
----------------------------------------------------------------------
diff --git a/experiments/flat/grammars/peg.peg b/experiments/flat/grammars/peg.peg
deleted file mode 100644
index 8c70d19..0000000
--- a/experiments/flat/grammars/peg.peg
+++ /dev/null
@@ -1,45 +0,0 @@
-Grammar    <- Spacing Definition+ EndOfFile
-Definition <- Identifier LEFTARROW Expression
-Expression <- Sequence (SLASH Sequence)*
-Sequence   <- Prefix*
-Prefix     <- (AND / NOT)? Suffix
-Suffix     <- Primary (QUESTION / STAR / PLUS)?
-Primary    <- Identifier !LEFTARROW
-            / DOLLAR OPEN Expression CLOSE
-            / OPEN Expression CLOSE
-            / Literal
-            / Class
-            / DOT
-Identifier <- $(IdentStart IdentCont*) Spacing
-IdentStart <- [a-zA-Z_]
-IdentCont  <- IdentStart
-            / [0-9]
-Literal    <- ['] (!['] Char)* ['] Spacing
-            / ["] (!["] Char)* ["] Spacing
-Class      <- '[' (!']' Range)* ']' Spacing
-Range      <- Char '-' Char
-            / Char
-Char       <- '\\' [nrt'"\[\]\\]
-            / '\\' [0-2] [0-7] [0-7]
-            / '\\' [0-7] [0-7]?
-            / !'\\' .
-LEFTARROW  <- '<-' Spacing
-SLASH      <- '/' Spacing
-AND        <- '&' Spacing
-NOT        <- '!' Spacing
-QUESTION   <- '?' Spacing
-STAR       <- '*' Spacing
-PLUS       <- '+' Spacing
-OPEN       <- '(' Spacing
-CLOSE      <- ')' Spacing
-DOT        <- '.' Spacing
-DOLLAR     <- '$' Spacing
-Spacing    <- $((Space / Comment)*)
-Comment    <- '#' (!EndOfLine .)* EndOfLine
-Space      <- ' '
-            / '\t'
-            / EndOfLine
-EndOfLine  <- '\r\n'
-            / '\n'
-            / '\r'
-EndOfFile  <- !.

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7ee1489a/experiments/flat/src/BuildGrammar.c
----------------------------------------------------------------------
diff --git a/experiments/flat/src/BuildGrammar.c b/experiments/flat/src/BuildGrammar.c
index ea066a5..7425878 100644
--- a/experiments/flat/src/BuildGrammar.c
+++ b/experiments/flat/src/BuildGrammar.c
@@ -463,7 +463,7 @@ static void buildGrammar(Builder *builder, Term *term)
         Term *defIdent = plusItem->term;
         assert(isIdent(defIdent,"Definition"));
         Term *defSeq = TermChildAt(defIdent,0);
-        assert(isSequence(defSeq,3));
+        assert(isSequence(defSeq,4));
         Term *identTerm = TermChildAt(defSeq,0);
         Term *exprTerm = TermChildAt(defSeq,2);
         assert(isIdent(identTerm,"Identifier"));

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7ee1489a/experiments/flat/src/Builtin.c
----------------------------------------------------------------------
diff --git a/experiments/flat/src/Builtin.c b/experiments/flat/src/Builtin.c
index 3db323b..ce060cb 100644
--- a/experiments/flat/src/Builtin.c
+++ b/experiments/flat/src/Builtin.c
@@ -51,181 +51,188 @@ Grammar *GrammarNewBuiltin(void)
 {
     Grammar *gram = GrammarNew();
 
-    // Grammar    <- Spacing Definition+ EndOfFile
+    // Grammar : Spacing Definition+ EndOfFile
     GrammarDefine(gram,"Grammar",
-                    seq(ref("Spacing"),
-                        plus(ref("Definition")),
-                        ref("EndOfFile")));
+                  seq(ref("Spacing"),
+                      plus(ref("Definition")),
+                      ref("EndOfFile")));
 
-    // Definition <- Identifier LEFTARROW Expression
+    // Definition : Identifier COLON Expression SEMI
     GrammarDefine(gram,"Definition",
-                    seq(ref("Identifier"),
-                        ref("LEFTARROW"),
-                        ref("Expression")));
-    // Expression <- Sequence (SLASH Sequence)*
+                  seq(ref("Identifier"),
+                      ref("COLON"),
+                      ref("Expression"),
+                      ref("SEMI")));
+
+    // Expression : Sequence (BAR Sequence)*
     GrammarDefine(gram,"Expression",
-                    seq(ref("Sequence"),
-                        star(seq(ref("SLASH"),ref("Sequence")))));
+                  seq(ref("Sequence"),
+                      star(seq(ref("BAR"),ref("Sequence")))));
 
-    // Sequence   <- Prefix*
+    // Sequence : Prefix*
     GrammarDefine(gram,"Sequence",
-                    star(ref("Prefix")));
+                  star(ref("Prefix")));
 
-    // Prefix     <- (AND / NOT)? Suffix
+    // Prefix : (AND | NOT)? Suffix
     GrammarDefine(gram,"Prefix",
-                    seq(opt(choice(ref("AND"),
-                                   ref("NOT"))),
-                        ref("Suffix")));
+                  seq(opt(choice(ref("AND"),
+                                 ref("NOT"))),
+                      ref("Suffix")));
 
-    // Suffix     <- Primary (QUESTION / STAR / PLUS)?
+    // Suffix : Primary (QUESTION | STAR | PLUS)?
     GrammarDefine(gram,"Suffix",
-                    seq(ref("Primary"),
-                        opt(choice(ref("QUESTION"),
-                                   ref("STAR"),
-                                   ref("PLUS")))));
-
-    // Primary    <- Identifier !LEFTARROW
-    //             / OPEN Expression CLOSE
-    //             / Literal
-    //             / Class
-    //             / DOT
+                  seq(ref("Primary"),
+                      opt(choice(ref("QUESTION"),
+                                 ref("STAR"),
+                                 ref("PLUS")))));
+
+    // Primary : Identifier !COLON
+    //         | DOLLAR OPEN Expression CLOSE
+    //         | OPEN Expression CLOSE
+    //         | Literal
+    //         | Class
+    //         | DOT
     GrammarDefine(gram,"Primary",
-                    choice(seq(ref("Identifier"),not(ref("LEFTARROW"))),
-                           seq(ref("DOLLAR"),ref("OPEN"),ref("Expression"),ref("CLOSE")),
-                           seq(ref("OPEN"),ref("Expression"),ref("CLOSE")),
-                           ref("Literal"),
-                           ref("Class"),
-                           ref("DOT")));
-
-    // Identifier <- IdentStart IdentCont* Spacing
+                  choice(seq(ref("Identifier"),not(ref("COLON"))),
+                         seq(ref("DOLLAR"),ref("OPEN"),ref("Expression"),ref("CLOSE")),
+                         seq(ref("OPEN"),ref("Expression"),ref("CLOSE")),
+                         ref("Literal"),
+                         ref("Class"),
+                         ref("DOT")));
+
+    // Identifier : $(IdentStart IdentCont*) Spacing
     GrammarDefine(gram,"Identifier",
-                    seq(string(seq(ref("IdentStart"),
-                                   star(ref("IdentCont")))),
-                        ref("Spacing")));
+                  seq(string(seq(ref("IdentStart"),
+                                 star(ref("IdentCont")))),
+                      ref("Spacing")));
 
-    // IdentStart <- [a-zA-Z_]
+    // IdentStart : [a-zA-Z_]
     GrammarDefine(gram,"IdentStart",
-                    cls(range('a','z'),
-                        range('A','Z'),
-                        range('_','_')));
+                  cls(range('a','z'),
+                      range('A','Z'),
+                      range('_','_')));
 
-    // IdentCont  <- IdentStart
-    //             / [0-9]
+    // IdentCont : IdentStart
+    //           | [0-9]
     GrammarDefine(gram,"IdentCont",
-                    choice(ref("IdentStart"),
-                        cls(range('0','9'))));
+                  choice(ref("IdentStart"),
+                         cls(range('0','9'))));
 
-    // Literal    <- ['] (!['] Char)* ['] Spacing
-    //             / ["] (!["] Char)* ["] Spacing
+    // Literal : ['] (!['] Char)* ['] Spacing
+    //         | ["] (!["] Char)* ["] Spacing
     GrammarDefine(gram,"Literal",
-                    choice(seq(cls(range('\'','\'')),
-                               star(seq(not(cls(range('\'','\''))),
-                                        ref("Char"))),
-                               cls(range('\'','\'')),
-                               ref("Spacing")),
-                           seq(cls(range('"','"')),
-                               star(seq(not(cls(range('"','"'))),
-                                        ref("Char"))),
-                               cls(range('"','"')),
-                               ref("Spacing"))));
-
-    // Class      <- '[' (!']' Range)* ']' Spacing
+                  choice(seq(cls(range('\'','\'')),
+                             star(seq(not(cls(range('\'','\''))),
+                                      ref("Char"))),
+                             cls(range('\'','\'')),
+                             ref("Spacing")),
+                         seq(cls(range('"','"')),
+                             star(seq(not(cls(range('"','"'))),
+                                      ref("Char"))),
+                             cls(range('"','"')),
+                             ref("Spacing"))));
+
+    // Class : "[" (!"]" Range)* "]" Spacing
     GrammarDefine(gram,"Class",
-                    seq(lit("["),
-                        star(seq(not(lit("]")),
-                                 ref("Range"))),
-                        lit("]"),
-                        ref("Spacing")));
-    // Range      <- Char '-' Char
-    //             / Char
+                  seq(lit("["),
+                      star(seq(not(lit("]")),
+                               ref("Range"))),
+                      lit("]"),
+                      ref("Spacing")));
+
+    // Range : Char "-" Char
+    //       | Char
     GrammarDefine(gram,"Range",
-                    choice(seq(ref("Char"),
-                               lit("-"),
-                               ref("Char")),
-                           ref("Char")));
-
-    // Char       <- '\\' [nrt'"\[\]\\]
-    //             / '\\' [0-2] [0-7] [0-7]
-    //             / '\\' [0-7] [0-7]?
-    //             / !'\\' .
+                  choice(seq(ref("Char"),
+                             lit("-"),
+                             ref("Char")),
+                         ref("Char")));
+
+    // Char : "\\" [nrt'"\[\]\\]
+    //      | "\\" [0-2] [0-7] [0-7]
+    //      | "\\" [0-7] [0-7]?
+    //      | !"\\" .
     GrammarDefine(gram,"Char",
-                    choice(seq(lit("\\"),
-                               cls(range('n','n'),
-                                   range('r','r'),
-                                   range('t','t'),
-                                   range('\'','\''),
-                                   range('"','"'),
-                                   range('[','['),
-                                   range(']',']'),
-                                   range('\\','\\'))),
-                           seq(lit("\\"),
-                               cls(range('0','2')),
-                               cls(range('0','7')),
-                               cls(range('0','7'))),
-                           seq(lit("\\"),
-                               cls(range('0','7')),
-                               opt(cls(range('0','7')))),
-                           seq(not(lit("\\")),dot())));
-
-    // LEFTARROW  <- '<-' Spacing
-    GrammarDefine(gram,"LEFTARROW",seq(lit("<-"),ref("Spacing")));
-
-    // SLASH      <- '/' Spacing
-    GrammarDefine(gram,"SLASH",seq(lit("/"),ref("Spacing")));
-
-    // AND        <- '&' Spacing
+                  choice(seq(lit("\\"),
+                             cls(range('n','n'),
+                                 range('r','r'),
+                                 range('t','t'),
+                                 range('\'','\''),
+                                 range('"','"'),
+                                 range('[','['),
+                                 range(']',']'),
+                                 range('\\','\\'))),
+                         seq(lit("\\"),
+                             cls(range('0','2')),
+                             cls(range('0','7')),
+                             cls(range('0','7'))),
+                         seq(lit("\\"),
+                             cls(range('0','7')),
+                             opt(cls(range('0','7')))),
+                         seq(not(lit("\\")),dot())));
+
+    // COLON : ":" Spacing
+    GrammarDefine(gram,"COLON",seq(lit(":"),ref("Spacing")));
+
+    // SEMI : ";" Spacing
+    GrammarDefine(gram,"SEMI",seq(lit(";"),ref("Spacing")));
+
+    // BAR : "|" Spacing
+    GrammarDefine(gram,"BAR",seq(lit("|"),ref("Spacing")));
+
+    // AND : "&" Spacing
     GrammarDefine(gram,"AND",seq(lit("&"),ref("Spacing")));
 
-    // NOT        <- '!' Spacing
+    // NOT : "!" Spacing
     GrammarDefine(gram,"NOT",seq(lit("!"),ref("Spacing")));
 
-    // QUESTION   <- '?' Spacing
+    // QUESTION : "?" Spacing
     GrammarDefine(gram,"QUESTION",seq(lit("?"),ref("Spacing")));
 
-    // STAR       <- '*' Spacing
+    // STAR : "*" Spacing
     GrammarDefine(gram,"STAR",seq(lit("*"),ref("Spacing")));
 
-    // PLUS       <- '+' Spacing
+    // PLUS : "+" Spacing
     GrammarDefine(gram,"PLUS",seq(lit("+"),ref("Spacing")));
 
-    // OPEN       <- '(' Spacing
+    // OPEN : "(" Spacing
     GrammarDefine(gram,"OPEN",seq(lit("("),ref("Spacing")));
 
-    // CLOSE      <- ')' Spacing
+    // CLOSE : ")" Spacing
     GrammarDefine(gram,"CLOSE",seq(lit(")"),ref("Spacing")));
 
-    // DOT        <- '.' Spacing
+    // DOT : "." Spacing
     GrammarDefine(gram,"DOT",seq(lit("."),ref("Spacing")));
 
-    // DOLLAR     <- '$' Spacing
+    // DOLLAR : "$" Spacing
     GrammarDefine(gram,"DOLLAR",seq(lit("$"),ref("Spacing")));
 
-    // Spacing    <- (Space / Comment)*
+    // Spacing : $((Space | Comment)*)
     GrammarDefine(gram,"Spacing",string(star(choice(ref("Space"),ref("Comment")))));
 
-    // Comment    <- '#' (!EndOfLine .)* EndOfLine
+    // Comment : "#" (!EndOfLine .)* EndOfLine;
     GrammarDefine(gram,"Comment",
-                    seq(lit("#"),
-                        star(seq(not(ref("EndOfLine")),
-                                 dot())),
-                        ref("EndOfLine")));
-
-    // Space      <- ' '
-    //            / '\t'
-    //            / EndOfLine
+                  seq(lit("#"),
+                      star(seq(not(ref("EndOfLine")),
+                               dot())),
+                      ref("EndOfLine")));
+
+    // Space : " "
+    //       | "\t"
+    //       | EndOfLine
     GrammarDefine(gram,"Space",
-                    choice(lit(" "),
-                           lit("\t"),
-                           ref("EndOfLine")));
-    // EndOfLine  <- '\r\n'
-    //             / '\n'
-    //             / '\r'
+                  choice(lit(" "),
+                         lit("\t"),
+                         ref("EndOfLine")));
+    // EndOfLine : "\r\n"
+    //           | "\n"
+    //           | "\r"
     GrammarDefine(gram,"EndOfLine",
-                    choice(lit("\r\n"),
-                           lit("\n"),
-                           lit("\r")));
+                  choice(lit("\r\n"),
+                         lit("\n"),
+                         lit("\r")));
 
-    // EndOfFile  <- !.
+    // EndOfFile : !.
     GrammarDefine(gram,"EndOfFile",not(dot()));
 
     GrammarResolve(gram);

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7ee1489a/experiments/flat/src/Builtin.h
----------------------------------------------------------------------
diff --git a/experiments/flat/src/Builtin.h b/experiments/flat/src/Builtin.h
index 089f068..76d3f38 100644
--- a/experiments/flat/src/Builtin.h
+++ b/experiments/flat/src/Builtin.h
@@ -23,50 +23,51 @@
  * The GrammarNewBuiltin() function creates the grammar shown below, which is based on the one from
  * Ford's original PEG paper.
  *
- *     Grammar    <- Spacing Definition+ EndOfFile
- *     Definition <- Identifier LEFTARROW Expression
- *     Expression <- Sequence (SLASH Sequence)*
- *     Sequence   <- Prefix*
- *     Prefix     <- (AND / NOT)? Suffix
- *     Suffix     <- Primary (QUESTION / STAR / PLUS)?
- *     Primary    <- Identifier !LEFTARROW
- *                 / DOLLAR OPEN Expression CLOSE
- *                 / OPEN Expression CLOSE
- *                 / Literal
- *                 / Class
- *                 / DOT
- *     Identifier <- $(IdentStart IdentCont*) Spacing
- *     IdentStart <- [a-zA-Z_]
- *     IdentCont  <- IdentStart
- *                 / [0-9]
- *     Literal    <- ['] (!['] Char)* ['] Spacing
- *                 / ["] (!["] Char)* ["] Spacing
- *     Class      <- '[' (!']' Range)* ']' Spacing
- *     Range      <- Char '-' Char
- *                 / Char
- *     Char       <- '\\' [nrt'"\[\]\\]
- *                 / '\\' [0-2] [0-7] [0-7]
- *                 / '\\' [0-7] [0-7]?
- *                 / !'\\' .
- *     LEFTARROW  <- '<-' Spacing
- *     SLASH      <- '/' Spacing
- *     AND        <- '&' Spacing
- *     NOT        <- '!' Spacing
- *     QUESTION   <- '?' Spacing
- *     STAR       <- '*' Spacing
- *     PLUS       <- '+' Spacing
- *     OPEN       <- '(' Spacing
- *     CLOSE      <- ')' Spacing
- *     DOT        <- '.' Spacing
- *     DOLLAR     <- '$' Spacing
- *     Spacing    <- $((Space / Comment)*)
- *     Comment    <- '#' (!EndOfLine .)* EndOfLine
- *     Space      <- ' '
- *                 / '\t'
- *                 / EndOfLine
- *     EndOfLine  <- '\r\n'
- *                 / '\n'
- *                 / '\r'
- *     EndOfFile  <- !.
+ *     Grammar    : Spacing Definition+ EndOfFile;
+ *     Definition : Identifier COLON Expression SEMI;
+ *     Expression : Sequence (BAR Sequence)*;
+ *     Sequence   : Prefix*;
+ *     Prefix     : (AND | NOT)? Suffix;
+ *     Suffix     : Primary (QUESTION | STAR | PLUS)?;
+ *     Primary    : Identifier !COLON
+ *                | DOLLAR OPEN Expression CLOSE
+ *                | OPEN Expression CLOSE
+ *                | Literal
+ *                | Class
+ *                | DOT;
+ *     Identifier : $(IdentStart IdentCont*) Spacing;
+ *     IdentStart : [a-zA-Z_];
+ *     IdentCont  : IdentStart
+ *                | [0-9];
+ *     Literal    : ['] (!['] Char)* ['] Spacing
+ *                | ["] (!["] Char)* ["] Spacing;
+ *     Class      : "[" (!"]" Range)* "]" Spacing;
+ *     Range      : Char "-" Char
+ *                | Char;
+ *     Char       : "\\" [nrt'"\[\]\\]
+ *                | "\\" [0-2] [0-7] [0-7]
+ *                | "\\" [0-7] [0-7]?
+ *                | !"\\" .;
+ *     COLON      : ":" Spacing;
+ *     SEMI       : ";" Spacing;
+ *     BAR        : "|" Spacing;
+ *     AND        : "&" Spacing;
+ *     NOT        : "!" Spacing;
+ *     QUESTION   : "?" Spacing;
+ *     STAR       : "*" Spacing;
+ *     PLUS       : "+" Spacing;
+ *     OPEN       : "(" Spacing;
+ *     CLOSE      : ")" Spacing;
+ *     DOT        : "." Spacing;
+ *     DOLLAR     : "$" Spacing;
+ *     Spacing    : $((Space | Comment)*);
+ *     Comment    : "#" (!EndOfLine .)* EndOfLine;
+ *     Space      : " "
+ *                | "\t"
+ *                | EndOfLine;
+ *     EndOfLine  : "\r\n"
+ *                | "\n"
+ *                | "\r";
+ *     EndOfFile  : !.;
  */
 Grammar *GrammarNewBuiltin(void);

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7ee1489a/experiments/flat/src/Expression.c
----------------------------------------------------------------------
diff --git a/experiments/flat/src/Expression.c b/experiments/flat/src/Expression.c
index 98b815c..ad2fc2e 100644
--- a/experiments/flat/src/Expression.c
+++ b/experiments/flat/src/Expression.c
@@ -258,9 +258,9 @@ void ExpressionPrint(Expression *expr, int highestPrecedence, const char *indent
             for (int i = 0; i < ExprChoiceCount(expr); i++) {
                 if (i > 0) {
                     if (indent != NULL)
-                        printf("\n%s/ ",indent);
+                        printf("\n%s| ",indent);
                     else
-                        printf(" / ");
+                        printf(" | ");
                 }
                 ExpressionPrint(ExprChoiceChildAt(expr,i),highestPrecedence,NULL);
             }

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7ee1489a/experiments/flat/src/Grammar.c
----------------------------------------------------------------------
diff --git a/experiments/flat/src/Grammar.c b/experiments/flat/src/Grammar.c
index 4f71f16..f015dfb 100644
--- a/experiments/flat/src/Grammar.c
+++ b/experiments/flat/src/Grammar.c
@@ -115,18 +115,18 @@ void GrammarPrint(Grammar *gram)
             maxNameLen = nameLen;
     }
 
-    char *prefix = malloc(maxNameLen+3);
-    memset(prefix,' ',maxNameLen+2);
-    prefix[maxNameLen+2] = '\0';
+    char *prefix = malloc(maxNameLen+2);
+    memset(prefix,' ',maxNameLen+1);
+    prefix[maxNameLen+1] = '\0';
 
     for (Rule *def = gram->defList; def != NULL; def = def->next) {
         int nameLen = strlen(def->name);
         printf("%s",def->name);
         for (int i = nameLen; i < maxNameLen+1; i++)
             printf(" ");
-        printf("<- ");
+        printf(": ");
         ExpressionPrint(def->expr,0,prefix);
-        printf("\n");
+        printf(";\n");
     }
 
     free(prefix);

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7ee1489a/experiments/flat/src/Util.c
----------------------------------------------------------------------
diff --git a/experiments/flat/src/Util.c b/experiments/flat/src/Util.c
index e03e8e0..5c53057 100644
--- a/experiments/flat/src/Util.c
+++ b/experiments/flat/src/Util.c
@@ -97,7 +97,7 @@ void printEscapedRangeChar(char c)
 
 void printLiteral(const char *value)
 {
-    printf("'");
+    printf("\"");
     for (int i = 0; value[i] != '\0'; i++) {
         switch (value[i]) {
             case '\r':
@@ -109,8 +109,8 @@ void printLiteral(const char *value)
             case '\t':
                 printf("\\t");
                 break;
-            case '\'':
-                printf("\\'");
+            case '\"':
+                printf("\\\"");
                 break;
             case '\\':
                 printf("\\\\");
@@ -119,5 +119,5 @@ void printLiteral(const char *value)
                 printf("%c",value[i]);
         }
     }
-    printf("'");
+    printf("\"");
 }