]> ocean-lang.org Git - ocean/blobdiff - csrc/indent_test.mdc
parsergen: add more power to symbol references in generated code
[ocean] / csrc / indent_test.mdc
index 960f63eb8122a2b8791952498e5c7b42832d2029..fddb64b7520a15931b430075406c2853f056fef3 100644 (file)
@@ -114,8 +114,6 @@ with complete bracketing and indenting.
                char *file = mmap(NULL, len, PROT_READ, MAP_SHARED, fd, 0);
                struct section *s = code_extract(file, file+len, NULL);
                struct token_config config = {
-                       .ignored = (1 << TK_line_comment)
-                                | (1 << TK_block_comment),
                        .number_chars = ".,_+-",
                        .word_start = "",
                        .word_cont = "",
@@ -134,13 +132,15 @@ with complete bracketing and indenting.
 
 ~~~~~~
 
+$TERM if { } : * + - / ; =
+
 Program -> Statementlist ${ print_statement($1, 0); }$
 
 $*statement
        Newlines -> NEWLINE
                | Newlines NEWLINE
-       Statementlist ->  Statements ${ $0 = $<1; }$
-               | Newlines Statements ${ $0 = $<2; }$
+       Statementlist ->  Statements ${ $0 = $<S; }$
+               | Newlines Statements ${ $0 = $<S1; }$
 
        Statements -> Statements Statement ${
                                {
@@ -159,20 +159,20 @@ $*statement
                | Newlines {
        Close -> }
                | Newlines }
-       Block -> Open Statementlist Close ${ $0 = $<2; }$
-               | Open SimpleStatements } ${ $0 = $<2; }$
-               | : SimpleStatements ${ $0 = $<2; }$
-               | : StatementBlock ${ $0 = $<2; }$
-       StatementBlock -> Statementlist $$OUT ${ $0 = $<1; }$
+       Block -> Open Statementlist Close ${ $0 = $<S; }$
+               | Open SimpleStatements } ${ $0 = $<S; }$
+               | : SimpleStatements ${ $0 = $<SS; }$
+               | : StatementBlock ${ $0 = $<SB; }$
+       StatementBlock -> Statementlist $$OUT ${ $0 = $<Sl; }$
 
        SimpleStatements -> SimpleStatements ; SimpleStatement ${
                        {
                                struct statement **s;
-                               $0 = $<1;
+                               $0 = $<SSs;
                                s = &$0;
                                while (*s)
                                        s = &(*s)->next;
-                               *s = $<3;
+                               *s = $<SS;
                        }
                        }$
                | SimpleStatement ${ $0 = $<1; }$