]> ocean-lang.org Git - ocean/commitdiff
pargergen: make use of --tag for calc grammar
authorNeilBrown <neilb@suse.de>
Sun, 11 May 2014 04:23:10 +0000 (14:23 +1000)
committerNeilBrown <neilb@suse.de>
Sun, 15 Jun 2014 07:12:45 +0000 (17:12 +1000)
Rather than placing the 'calc' grammar in a separate file,
add 'calc:' tags to the sections and use --tag option to
extract the grammar directly from the pargergen.mdc file.

Signed-off-by: NeilBrown <neilb@suse.de>
csrc/parsergen.mdc

index a7d107cfa168d2deb8895321fbfc930a3b5eba20..9def0826d5ea57ac6b333f74c5bbe3767f78de59 100644 (file)
@@ -17,7 +17,10 @@ There are several distinct sections.
 5. `parser_run` is a library function intended to be linked together
    with the generated parser tables to complete the implementation of
    a parser.
-6. `calc.cgm` is a test grammar for a simple calculator.
+6. Finally `calc` is a test grammar for a simple calculator.  The
+   `parsergen` program built from the C code in this file can extract
+   that grammar directly from this file and process it.
+
 
 ###### File: parsergen.c
        #include <unistd.h>
@@ -42,12 +45,10 @@ There are several distinct sections.
        ## parser includes
        ## parser functions
        ## parser_run
-###### File: calc.cgm
-       ## demo grammar
 ###### File: parsergen.mk
        CFLAGS += -Wall -g
        all :: parsergen calc
-       parsergen.c parsergen.mk calc.cgm libparser.c parser.h : parsergen.mdc
+       parsergen.c parsergen.mk libparser.c parser.h : parsergen.mdc
                ./md2c parsergen.mdc
 
 ## Reading the grammar
@@ -2733,15 +2734,12 @@ better approach, but as the grammar file must have 3 components I need
 something like this.
 
 ###### File: parsergen.mk
-       calc.c : parsergen calc.cgm
-               ./parsergen -o calc calc.cgm
+       calc.c calc.h : parsergen parsergen.mdc
+               ./parsergen --tag calc -o calc parsergen.mdc
        calc : calc.o libparser.o libscanner.o libmdcode.o libnumber.o
                $(CC) $(CFLAGS) -o calc calc.o libparser.o libscanner.o libmdcode.o libnumber.o -licuuc -lgmp
 
-###### demo grammar
-
-       # header
-       ~~~~~
+# calc: header
 
        #include "number.h"
        // what do we use for a demo-grammar?  A calculator of course.
@@ -2751,9 +2749,7 @@ something like this.
                int err;
        };
 
-       ~~~~~
-       # code
-       ~~~~~
+# calc: code
 
        #include <stdlib.h>
        #include <unistd.h>
@@ -2794,9 +2790,7 @@ something like this.
                exit(0);
        }
 
-       ~~~~~
-       # grammar
-       ~~~~~
+# calc: grammar
 
        Session -> Session Line
                | Line