Subversion Repositories PlanixRsrch.SVN

Compare Revisions

Ignore whitespace Rev 233 → Rev 234

/branches/bnf/libmavl/mavl_destroy.c
File deleted
/branches/bnf/libmavl/mavl_print.c
File deleted
/branches/bnf/libmavl/mavl_del_all.c
File deleted
/branches/bnf/libmavl/example1.c
File deleted
/branches/bnf/libmavl/example2.c
File deleted
/branches/bnf/libmavl/mavlnode_destroy.c
File deleted
/branches/bnf/libmavl/mavliter_next.c
File deleted
/branches/bnf/libmavl/mavl_create.c
File deleted
/branches/bnf/libmavl/mavl_get_depth.c
File deleted
/branches/bnf/libmavl/mavliter_get.c
File deleted
/branches/bnf/libmavl/mavl_foreach_lr.c
File deleted
/branches/bnf/libmavl/mavl_verify.c
File deleted
/branches/bnf/libmavl/mavl_foreach.c
File deleted
/branches/bnf/libmavl/man/mavl.3
File deleted
/branches/bnf/libmavl/Makefile
File deleted
/branches/bnf/libmavl/mavl_get.c
File deleted
/branches/bnf/libmavl/mavl.c
File deleted
/branches/bnf/libmavl/LICENSE
File deleted
/branches/bnf/libmavl/mavl.h
File deleted
/branches/bnf/libmavl/mavliter_seek_set.c
File deleted
/branches/bnf/libmavl/mavliter_init.c
File deleted
/branches/bnf/libmavl
Property changes:
Deleted: svn:mergeinfo
## -0,2 +0,0 ##
Reverse-merged /branches/smavel/libmavl:r27-65
Reverse-merged /branches/ai/libmavl:r59-72
Index: bnf/mgen/mgen_skip_spaces.c
===================================================================
--- bnf/mgen/mgen_skip_spaces.c (revision 233)
+++ bnf/mgen/mgen_skip_spaces.c (nonexistent)
@@ -1,43 +0,0 @@
-/*
- * Copyright 2019,2020, The PLANIX Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "mgen.h"
-
-int
-mgen_skip_spaces(struct mgen_stream * mf )
-{
- int c;
- while (1) {
- c=mgen_getc(mf);
- if ( mgen_isspace(c) ) {
- continue;
- }
- break;
- };
- return c;
-}
-
Index: bnf/mgen/algol60.raw
===================================================================
--- bnf/mgen/algol60.raw (revision 233)
+++ bnf/mgen/algol60.raw (nonexistent)
@@ -1,7 +0,0 @@
-:
-<program> ::= <block> | <compound statement><block> ::= <unlabelled block> | <label>: <block>
-<unlabelled block> ::= <block head> ;
-<compound tail><block head> ::= begin <declaration> | <block head> ; <declaration>
-<compound statement> ::= <unlabelled compound> | <label>: <compound statement><unlabelled compound> ::= begin <compound tail><compound tail> ::= <statement> end | <statement> ; <compound tail><declaration> ::= <type declaration> | <array declaration> | <switch declaration> | <procedure declaration><type declaration> ::= <local or own type> <type list><local or own type> ::= <type> | own <type><type> ::= real | integer | boolean<type list> ::= <simple variable> | <simple variable> , <type list><array declaration> ::= array <array list> | <local or own type> array <array list><array list> ::= <array segment> | <array list> , <array segment><array segment> ::= <array identifier> [ <bound pair list> ] | <array identifier> , <array segment><array identifier> ::= <identifier><bound pair list> ::= <bound pair> | <bound pair list> , <bound pair><bound pair> ::= <lower bound> : <upper bound><upper bound> ::= <arithmetic expression><lower bound> ::= <arithmetic expression><switch declaration> ::= switch <switch identifier> := <switch list><switch identifier> ::= <identifier><switch list> ::= <designational expression> | <switch list> , <designational expression><procedure declaration> ::= procedure <procedure heading> <procedure body> | <type> procedure <procedure heading> <procedure body><procedure heading> ::= <procedure identifier> <formal parameter part> ; <value part> <specification part><procedure identifier> ::= <identifier><formal parameter part> ::= <empty> | ( <formal parameter list> )<formal parameter list> ::= <formal parameter> | <formal parameter list> <parameter delimiter> <formal parameter><formal parameter> ::= <identifier> <value part> ::= value <identifier list> ; | <empty><specification part> ::= <empty> | <specifier> <identifier list> ; | <specification part> <specifier> <identifier list><specifier> ::= string | <type> | array | <type> array | label | switch | procedure | <type> procedure<identifier list> ::= <identifier> | <identifier list> , <identifier><procedure body> ::= <statement> | <code><statement> ::= <unconditional statement> | <conditional statement> | <for statement><unconditional statement> ::= <basic statement> | <compound statement> | <block><basic statement> ::= <unlabelled basic statement> | <label>: <basic statement><label> ::= <identifier> | <unsigned integer><unlabelled basic statement> ::= <assignment statement> | <go to statement> | <dummy statement> | <procedure statement><assignment statement> ::= <left part list> <arithmetic expression> | <left part list> <Boolean expression><left part list> ::= <left part> | <left part list> <left part><left part> ::= <variable> := | <procedure identifier> :=<go to statement> ::= goto <designational expression><designational expression> ::= <simple designational expression> |<if clause> <simple designational expression> else <designational expression><simple designational expression> ::= <label> | <switch designator> | (<designational expression>)<switch designator> ::= <switch identifier> [<subscript expression>]<dummy statement> ::= <empty><procedure statement> ::= <procedure identifier> <actual parameter part><actual parameter part> ::= <empty> | ( <actual parameter list> )<actual parameter list> ::= <actual parameter> | <actual parameter list> <parameter delimiter> <actual parameter><parameter delimiter> ::= , | ) <letter string> : (<actual parameter> ::= <string> | <expression> | <array identifier> | <switch identifier> | <procedure identifier><conditional statement> ::= <if statement> | <if statement> else <statement> | <if clause> <for statement> | <label>: <conditional statement><if statement> ::= <if clause> <unconditional statement><if clause> ::= if <Boolean expression> then<for statement> ::= <for clause> <statement> | <label>: <for statement><for clause> ::= for <variable> := <for list> do<for list> ::= <for list element> | <for list> , <for list element><for list element> ::= <arithmetic expression> |<arithmetic expression> step <arithmetic expression> until <arithmetic expression> |<arithmetic expression> while <Boolean expression><expression> ::= <arithmetic expression> | <Boolean expression> | <designational expression><arithmetic expression> ::= <simple arithmetic expression> | <if clause> <simple arithmetic expression> else <arithmetic expression><simple arithmetic expression> ::= <term> | <adding operator> <term> | <simple arithmetic expression> <adding operator> <term><adding operator> ::= + | –<term> ::= <factor> | <term> <multiplying operator> <factor><multiplying operator> ::= × | / | ÷<factor> ::= <primary> | <factor> | <factor> ↑ <primary><primary> ::= <unsigned number> | <variable> | <function designator> | ( <arithmetic expression> )<unsigned number> ::= <decimal number> | <exponential part> | <decimal number> <exponential part>
-<decimal number> ::= <unsigned integer> | <decimal fraction> | <unsigned integer> <decimal fraction><unsigned integer> ::= <digit> | <unsigned integer> <digit><decimal fraction> ::= . <unsigned integer><exponential part> ::= 10 <integer><integer> ::= <unsigned integer> | + <unsigned integer> | – <unsigned integer><Boolean expression> ::= <simple Boolean> | <if clause> <simple Boolean> else <Boolean expression><simple Boolean> ::= <implication> | <simple Boolean> ≣ <implication><implication> ::= <Boolean term> | <implication> ⊃ <Boolean term><Boolean term> ::= <Boolean factor> | <Boolean term> ⋁ <Boolean factor><Boolean factor> ::= <Boolean secondary> | <Boolean factor> ⋀ <Boolean secondary><Boolean secondary> ::= <Boolean primary> | ¬ <Boolean primary><Boolean primary> ::= <logical value> | <variable> | <function designator> | <relation> | ( <Boolean expression> )<relation> ::= <simple arithmetic expression> <relational operator> <simple arithmetic expression><relational operator> ::= < | ≤ | = | ≠ | > | ≥<function designator> ::= <procedure identifier> <actual parameter part><variable> ::= <simple variable> | <subscripted variable><simple variable> ::= <variable identifier><variable identifier> ::= <identifier><subscripted variable> ::= <array identifier> [ <subscript list> ]<subscript list> ::= <subscript expression> | <subscript list> , <subscript expression><subscript expression> ::= <arithmetic expression><string> ::= "<open string>"<open string> ::= <proper string> "<open string>" | <open string><open string><proper string> ::= <any sequence of symbols not containing " > | <empty><letter string> ::= <letter> | <letter string> <letter><identifier> ::= letter> | <identifier> <letter> | <identifier> <digit><basic symbol> ::= <letter> | <digit> | <logical value> | <delimiter><letter> ::= a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r | s | t | u | v | w | x | y | z |A |B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z<digit> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 <logical value> ::= true | false<delimiter> ::= <operator> | <separator> | <bracket> | <declarator> | <specificator><operator> ::= <arithmetic operator> | <relational operator> | <logical operator> | <sequential operator><arithmetic operator> ::= + | – | × | / | ÷ | ↑<relational operator> ::= < | ≤ | = | ≠ | > | ≥<logical operator> ::= ≣ | ⊃ | ⋁ | ⋀ | ¬<sequential operator> ::= goto | if | then | else | for | do<separator> ::= , | . | 10 | : | ; | := | _ | step | until | while | comment<bracket> ::= ( | ) | [ | ] | ` | ' | begin | end<declarator> ::= own | boolean | integer | real | array | switch | procedure<specificator> ::= string | label | value
-
Index: bnf/mgen/mgen_create_rule_set.c
===================================================================
--- bnf/mgen/mgen_create_rule_set.c (revision 233)
+++ bnf/mgen/mgen_create_rule_set.c (nonexistent)
@@ -1,56 +0,0 @@
-/*
- * Copyright 2019,2020, The PLANIX Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include <string.h>
-#include "mgen.h"
-
-static int
-cmp_rules(const void *v1, const void *v2)
-{
- const char *s1,*s2;
- s1 = ((struct mgen_rule *)v1)->name;
- s2 = ((struct mgen_rule *)v2)->name;
-
- return strcmp(s1,s2);
-}
-
-
-struct mgen_rule_set *
-mgen_create_rule_set()
-{
- MGEN_RULE_SET * rs;
- rs = malloc (sizeof(MGEN_RULE_SET));
- if (!rs)
- return NULL;
-
- rs->rules = mavl_create(cmp_rules,
- NULL, sizeof (struct mgen_rule) );
- if (!rs->rules){
- free(rs);
- return NULL;
- }
- return rs;
-}
Index: bnf/mgen/mi.prg
===================================================================
--- bnf/mgen/mi.prg (revision 233)
+++ bnf/mgen/mi.prg (nonexistent)
@@ -1 +0,0 @@
-PROGRAMGgtBEGIN...END.
Index: bnf/mgen/mgen_ring_seek.c
===================================================================
--- bnf/mgen/mgen_ring_seek.c (revision 233)
+++ bnf/mgen/mgen_ring_seek.c (nonexistent)
@@ -1,62 +0,0 @@
-/*
- * Copyright 2019,2020, The PLANIX Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "mgen.h"
-
-int
-mgen_ring_seek(MGEN_RING * ring, size_t pos)
-{
- if (ring->buf_size == ring->bufmax_size ){
- size_t diff;
-
- diff = ring->absmaxpos-pos;
- if (diff > ring->buf_size)
- return 0;
-
-/* npos = ring->maxpos - diff;*/
-
- if ( ring->maxpos > diff ){
- ring->pos = ring->maxpos -diff;
- }
- else{
- ring->pos = ring->bufmax_size - (diff-ring->maxpos);
- }
-
- if (ring->pos == ring->bufmax_size)
- ring->pos=0;
-
- ring->abspos = pos;
- return 1;
- }
- if (pos<0)
- return 0;
- ring->pos = pos;
- ring->abspos = pos;
- return 1;
-}
-
-
Index: bnf/mgen/mipascal.bnf
===================================================================
--- bnf/mgen/mipascal.bnf (revision 233)
+++ bnf/mgen/mipascal.bnf (nonexistent)
@@ -1,13 +0,0 @@
-#
-# mini pascal
-#
-
-<Programm> ::= PROGRAM <Bezeichner> BEGIN <Satzfolge> END .
-<Bezeichner> ::= <Buchstabe> <Restbezeichner>
-<Restbezeichner> ::= | <Buchstabe oder Ziffer> <Restbezeichner>
-<Buchstabe oder Ziffer> ::= <Buchstabe> | <Ziffer>
-<Grossbuchstabe> ::= A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z
-<Kleinbuchstabe> ::= a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z
-<Buchstabe> ::= <Grossbuchstabe> | <Kleinbuchstabe>
-<Ziffer> ::= 0|1|2|3|4|5|6|7|8|9
-<Satzfolge> ::= ...
Index: bnf/mgen/README
===================================================================
--- bnf/mgen/README (revision 233)
+++ bnf/mgen/README (nonexistent)
@@ -1 +0,0 @@
-A simple *true* BNF-Parser in pure ANSI C 89
Index: bnf/mgen/example.bnf
===================================================================
--- bnf/mgen/example.bnf (revision 233)
+++ bnf/mgen/example.bnf (nonexistent)
@@ -1,6 +0,0 @@
-
-<Ziffer ausser Null> ::= 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
-<Ziffer> ::= 0 | <Ziffer ausser Null>
-<Zweistellige Zahl> ::= <Ziffer ausser Null> <Ziffer>
-<Zehn bis Neunzehn> ::= 1 <Ziffer>
-<Zweiundvierzig> ::= 42
Index: bnf/mgen/mgen_ring_alloc.c
===================================================================
--- bnf/mgen/mgen_ring_alloc.c (revision 233)
+++ bnf/mgen/mgen_ring_alloc.c (nonexistent)
@@ -1,57 +0,0 @@
-/*
- * Copyright 2019,2020, The PLANIX Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "mgen.h"
-
-size_t
-mgen_ring_alloc(MGEN_RING *ring)
-{
- if(ring->buf_size == ring->bufmax_size){
- return ring->pos;
- }
-
- if (ring->pos==ring->buf_size){
- size_t s;
- void * newbuf;
-
- s=ring->buf_size+ring->block_size;
- if ( s>ring->bufmax_size && ring->bufmax_size!=0) {
- s = ring->bufmax_size;
- }
-
- newbuf = realloc(ring->buf,s*ring->elem_size);
- if (!newbuf)
- return -1;
- ring->buf = newbuf;
- ring->buf_size=s;
- return ring->pos;
- }
-
- return ring->pos;
-}
-
-
Index: bnf/mgen/mgen_perror.c
===================================================================
--- bnf/mgen/mgen_perror.c (revision 233)
+++ bnf/mgen/mgen_perror.c (nonexistent)
@@ -1,49 +0,0 @@
-/*
- * Copyright 2019,2020, The PLANIX Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <stdarg.h>
-
-#include "mgen.h"
-
-void
-mgen_perror(struct mgen_stream *mf, char *msg, ...)
-{
- va_list argp;
- va_start(argp, msg);
-
- if (mf->filename){
- (void)fprintf(stderr,"\"%s\",",mf->filename);
- }
-
- (void)fprintf(stderr, "line %d, col %d: error: ",
- mf->line, mf->col);
-
- (void)vfprintf(stderr,msg,argp);
- (void)fprintf(stderr,"\n");
- va_end(argp);
-}
Index: bnf/mgen/test.c
===================================================================
--- bnf/mgen/test.c (revision 233)
+++ bnf/mgen/test.c (nonexistent)
@@ -1,198 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-
-#include <mutests.h>
-
-#include "mgen.h"
-
-
-
-static char *
-gen_test_file(char *str)
-{
- FILE *f;
- char *filename;
- filename = tmpnam(NULL);
- f=fopen(filename,"wt");
- (void)fprintf(f,str);
- (void)fclose(f);
- return filename;
-}
-
-
-
-int test_mgen_read_rule_set1(char *bnf, char *prg, char * start, int wrc)
-{
- char * filename;
- MGEN_FILE * mf;
- struct mgen_rule_set * rules;
- int rc;
-
- filename = gen_test_file(bnf);
- mf = mgen_open(filename,"");
- rules = mgen_read_rule_set(mf);
-
- mu_assert(rules!=NULL,"create rules");
- (void) remove(filename);
-
- filename = gen_test_file(prg);
- mf = mgen_open(filename,"");
- rc = mgen_parse(mf,rules, start);
- mu_assert(rc == wrc, "mgen_parse bnf: %s, prg: %s",bnf,prg);
-
- (void) remove (filename);
- return 1;
-}
-
-int test_mgen_read_rule_set()
-{
- int rc;
- rc = test_mgen_read_rule_set1(
- "<Program> ::= a b c",
- "abc",
- "Program",
- 1);
- rc |= test_mgen_read_rule_set1(
- "<Program> ::= a b c",
- "abx",
- "Program",
- 0);
- rc |= test_mgen_read_rule_set1(
-"<Program> ::= <Word> a b c\n\
-<Word> ::= <Letter> <Wordrest>\n\
-<Wordrest> ::= <Letter> | \n\
-<Letter> ::= x | y | z",
-
-"xyabc",
- "Program",
- 1);
- rc |= test_mgen_read_rule_set1(
-"<Programm1> ::= a b c\n"
-"<Programm> ::= <Wort> Z u m s e l\n"
-"<Buchstabe> ::= <Kleinbuchstabe> | <Grossbuchstabe>\n"
-"<Wort> ::= <Buchstabe> <Wortrest> <Delimiter>\n"
-"<Wortrest> ::= <Buchstabe> <Wortrest> |\n"
-"<Kleinbuchstabe> ::= a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z\n"
-"<Grossbuchstabe> ::= A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z\n"
-"<Delimiter> ::= _ <Delimiterrest>\n"
-"<Delimiterrest> ::= <Delimiter> |\n",
- "Z____Zumsel",
- "Programm",
- 1);
-
- return rc;
-}
-
-int test_mgen_ring_seek1(char *str,int bufsize,int blocksize)
-{
- char * filename;
- MGEN_FILE * mf;
- int i,c,rc;
-
- filename = gen_test_file(str);
-
- mf = mgen_open(filename,"");
- mu_assert(mf!=NULL, "seek: can't open file %s",filename);
-
- mgen_ring_set_block_size(&mf->ring,(size_t)blocksize);
- mgen_ring_set_buffer_size(&mf->ring,(size_t)bufsize);
-
- for(i=0; i<(int)strlen(str); i++){
- c = mgen_getc(mf);
- mu_assert( c == str[i], "seek: test 1");
- }
-
- for(i=0; i<(int)strlen(str); i++){
- rc = mgen_ring_seek(&mf->ring,(size_t)i);
- if ( (int)strlen(str)-i > bufsize )
- mu_assert(!rc,"seek: test 44");
- else{
- mu_assert(rc,"seek: test 45");
- c = mgen_getc(mf);
- mu_assert (c == str[i], "seek: test 77");
- }
- }
-
- (void)remove(filename);
- return 1;
-}
-
-int test_mgen_ring_seek()
-{
- int rc=0;
- rc |= test_mgen_ring_seek1("012345678",5,3);
- rc |= test_mgen_ring_seek1("0123456789123",100,3);
- rc |= test_mgen_ring_seek1("xxaass0123456789123",5,1);
- rc |= test_mgen_ring_seek1("12345678",8,2);
- rc |= test_mgen_ring_seek1("12345678",8,8);
- rc |= test_mgen_ring_seek1("12345678",9,8);
- return rc;
-}
-
-
-
-int test_mgen_getc()
-{
- MGEN_FILE * mf;
- char * str;
- char *filename;
- int i,rc;
- int maxbuf,diff,blocksize;
-
- str = "Hello World"; /* 11 characters */
- diff = 3;
- blocksize = 2;
- maxbuf = (int)strlen(str)-diff;
-
- filename = gen_test_file(str);
-
- mf = mgen_open(filename,"");
- mu_assert(mf!=NULL, "can't open file %s",filename);
-
- mgen_ring_set_block_size(&mf->ring,(size_t)blocksize);
- mgen_ring_set_buffer_size(&mf->ring,(size_t)maxbuf);
-
- for (i=0; (size_t)i<strlen(str); i++){
- int c;
- c = mgen_getc(mf);
- mu_assert(c == str[i],"test 1");
- mu_assert((size_t)i+1 == mf->ring.abspos,"test 2");
- }
-
-/* mu_assert(mf->ring.pos == (size_t)maxbuf % (size_t)diff-1, "test 3");*/
-
- /* unget characters into the whole buffer */
- for (i=0; i<maxbuf; i++){
- rc = mgen_ungetc('0'+i,mf);
- mu_assert(rc == '0'+i,"test 4");
- }
-
- /* unget one more character should result in EOF */
- rc = mgen_ungetc('x',mf);
- mu_assert( rc == EOF, "test 5");
-
- for (i=0; i<maxbuf; i++){
- rc = mgen_getc(mf);
- mu_assert(rc == '0'+maxbuf-1-i, "test 6");
- }
-
- rc = mgen_getc(mf);
- mu_assert(rc == EOF,"test 7");
-
- (void)fclose(mf->infile);
- (void)remove(filename);
-
- return 1;
-}
-
-int main()
-{
- mutests tf = {
- test_mgen_getc,
- test_mgen_ring_seek,
- test_mgen_read_rule_set,
- NULL
- };
- return mutests_run(tf);
-}
-
Index: bnf/mgen/mgen_parse.c
===================================================================
--- bnf/mgen/mgen_parse.c (revision 233)
+++ bnf/mgen/mgen_parse.c (nonexistent)
@@ -1,171 +0,0 @@
-/*
- * Copyright 2019,2020, The PLANIX Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "mgen.h"
-
-
-struct status {
- size_t fpos;
- struct rhs_elem * e;
- size_t sstackptr;
-};
-
-struct mgen_parser {
- struct mavl * rules;
- struct mgen_stream * mf;
-
- MGEN_RING st;
- MGEN_RING ss;
-};
-
-
-static int
-check_string(struct mgen_stream *mf, char *str)
-{
- int i,c;
- i=0;
-
- while (str[i] != 0){
- c=mgen_getc(mf);
- if (c==str[i]){
- i++;
- continue;
- }
- return 0;
- }
- return 1;
-}
-
-static struct rhs_elem *
-get_rhs_list(struct mgen_parser * prs, char *rulename)
-{
- struct mgen_rule *rule,rs;
- rs.name = rulename;
- rule = mavl_get(prs->rules,&rs);
- if ( !rule ){
- (void)printf("Fatal error rule not found %s\n",rulename);
- return 0;
- }
-
- return rule->rhs_list;
-}
-
-static int
-run_rhs_list(struct mgen_parser *prs, struct rhs_elem * e)
-{
- struct mgen_sym * sym;
- struct status * st;
- size_t i;
-
-loop0:
- /* push curent status on ststack */
- i = mgen_ring_alloc(&prs->st);
- (void)mgen_ring_next(&prs->st);
- st = (struct status*)(prs->st.buf);
- st[i].fpos = mgen_tell(prs->mf);
- st[i].e = e;
-
- st[i].sstackptr=prs->ss.abspos;
-
-loop1:
- if (!e) {
- if (prs->st.abspos==1)
- return 0;
-
- /* pop status */
- (void)mgen_ring_prev(&prs->st);
- goto loop3;
- }
- sym=e->sym_list;
-
-loop2:
-
- if (!sym) {
- if (prs->ss.abspos==0){
- return 1;
- }
-
- /* sym = popsym(prs); */
- (void)mgen_ring_prev(&prs->ss);
- sym = ((struct mgen_sym**)(prs->ss.buf))[prs->ss.pos];
- goto loop2;
- }
- switch( sym->type ){
- case MGEN_T_SYM:
- if (check_string(prs->mf,sym->name)){
- sym=sym->next;
- goto loop2;
- }
-loop3:
- (void)mgen_ring_prev(&prs->st);
- st = &(((struct status*)(prs->st.buf))[prs->st.pos]);
- (void)mgen_ring_next(&prs->st);
-
- e=st->e->next;
- st->e=e;
- (void)mgen_seek(prs->mf,st->fpos);
- (void)mgen_ring_seek(&prs->ss,st->sstackptr);
- goto loop1;
-
- case MGEN_NT_SYM:
- e = get_rhs_list(prs,sym->name);
- /* pushsym(prs,sym->next); */
- if (sym->next){
- size_t i1;
- i1 = mgen_ring_alloc(&prs->ss);
- ((struct mgen_sym**)(prs->ss.buf))[i1]=
- sym->next;
- (void)mgen_ring_next(&prs->ss);
- }
- goto loop0;
- }
-
- /* this should never happen */
- return 0;
-}
-
-int
-mgen_parse(
- struct mgen_stream *mf,
- struct mgen_rule_set *rules,
- const char * start)
-{
- struct mgen_parser prs;
- int rc;
- struct rhs_elem * e;
-
- prs.rules = rules->rules;
- prs.mf = mf;
-
- mgen_ring_init(&prs.st,sizeof(struct status));
- mgen_ring_init(&prs.ss,sizeof(struct mgen_sym *));
-
- e = get_rhs_list(&prs,(char*)start);
-
- rc = run_rhs_list(&prs,e);
- return rc;
-}
Index: bnf/mgen/mgen_read_rule_set.c
===================================================================
--- bnf/mgen/mgen_read_rule_set.c (revision 233)
+++ bnf/mgen/mgen_read_rule_set.c (nonexistent)
@@ -1,424 +0,0 @@
-/*
- * Copyright 2019,2020, The PLANIX Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include <string.h>
-#include <errno.h>
-
-#include "mgen.h"
-
-#define MAX_NONTERMINAL 1024
-#define MAX_TERMINAL 1024
-
-struct bnf0_prs {
- struct mgen_rule * current_rule;
- struct rhs_elem * current_rhs_elem;
- struct mgen_sym ** current_sym;
- MGEN_RULE_SET *rules;
-};
-
-static int
-skip_comment(struct mgen_stream * mf)
-{
- int c;
- do {
- c=mgen_getc(mf);
- }while (c!='\n' && c!=EOF);
- return c;
-}
-
-static int
-get_non_terminal(struct mgen_stream * mf, char * result)
-{
- int c;
- int i;
-
- c=EOF; /* this eliminates a compiler warning
- about c may be used unassigned */
-
- for (i=0; i<MAX_NONTERMINAL; i++){
- c = mgen_getc(mf);
- if (c=='>')
- break;
- if (c=='\n' || c==EOF){
- mgen_perror(mf,"missing '>' at end of non-terminal");
- return EOF;
- }
- result[i]=(char)c;
- }
-
- if (i==MAX_NONTERMINAL && c!='>'){
- mgen_perror(mf,"non-terminal symbol too long");
- return EOF;
- }
- result[i]=0;
-
- return c;
-}
-
-static int
-get_terminal(struct mgen_stream * mf, char * result)
-{
- int c;
- int i;
-
- c=EOF; /* this eliminates a compiler warning
- about c may be used unassigned */
-
- for (i=0; i<MAX_TERMINAL; i++){
- c = mgen_getc(mf);
- if (c==' ' || c=='\n' || c=='|' ||
- c=='\t' || c=='\r' || c==EOF)
- break;
- result[i]=(char)c;
- }
-
- if (i==MAX_TERMINAL ){
- mgen_perror(mf,"terminal symbol too long");
- return EOF;
- }
- result[i]=0;
- if (strcmp(result,"\\n")==0){
- strcpy(result,"\n");
- }
- if (strcmp(result,"\\s")==0){
- strcpy(result," ");
- }
- if (strcmp(result,"\\t")==0){
- strcpy(result,"\t");
- }
- if (strcmp(result,"\\r")==0){
- strcpy(result,"\r");
- }
-
-
-
- return c;
-}
-
-
-static struct rhs_elem *
-append_rhs_elem(struct rhs_elem ** next)
-{
- while (*next!=NULL){
- next = &((*next)->next);
- }
- *next = malloc(sizeof(struct rhs_elem));
- if (!*next)
- return NULL;
-
- (*next)->sym_list=NULL;
- (*next)->next=NULL;
- return *next;
-}
-
-static struct mgen_sym *
-append_sym(struct mgen_sym ** next, int type, char *name)
-{
- struct mgen_sym * sym;
- sym = malloc( sizeof( struct mgen_sym));
- if (!sym){
- return NULL;
- }
- sym->name = malloc( strlen(name)+1);
- if (!sym->name){
- return NULL;
- }
- (void)strcpy (sym->name,name);
- sym->type=type;
- sym->next=NULL;
-
- *next = sym;
- return sym;
-}
-
-MGEN_CHAR *
-mgen_get_char(MGEN_FILE *mf)
-{
- MGEN_CHAR * mc;
- if (!mgen_ring_prev(&mf->ring)){
- return NULL;
- }
- mc = mgen_ring_getat(&mf->ring,MGEN_CHAR,mf->ring.pos);
- (void)mgen_ring_next(&mf->ring);
- return mc;
-}
-
-static int
-get_left_hand_side(struct mgen_stream * mf, struct bnf0_prs * prs)
-{
- int c;
- MGEN_CHAR *mc;
-
- char result[MAX_NONTERMINAL+1];
- struct mgen_rule rule;
- int exists;
-
- while(1) {
-
- c = mgen_skip_spaces(mf);
- if (c==EOF)
- return EOF;
-
- mc = mgen_get_char(mf);
- if (c=='#' && mc->col==1){
- c=skip_comment(mf);
- (void)mgen_ungetc(c,mf);
- continue;
- }
- break;
- }
-
-
- if (c != '<' ){
- mgen_perror(mf,"'<' expected.");
- return EOF;
- }
- mc = mgen_get_char(mf);
- if (mc->col != 1){
- mgen_perror(mf,
- "left hand side of a rule has to start at column 1.");
- return EOF;
- }
-
- c = get_non_terminal(mf, result);
- if (c==EOF)
- return EOF;
-
- rule.name = malloc(strlen(result)+1);
- if (!rule.name){
- mgen_perror(mf,"can't allocate memory.");
- return EOF;
- }
- (void)strcpy(rule.name,result);
- rule.rhs_list=0;
- rule.line = mf->line;
- rule.rhs_list = NULL;
-
-/* (void)printf("non-terminal found: %s\n",rule.name);*/
-
- prs->current_rule =
- mavl_insert(prs->rules->rules, &rule, &exists);
-
- if (!prs->current_rule){
- mgen_perror(mf,"can't allocate memory\n");
- return EOF;
- }
-
- if (exists){
- char msg[MAX_NONTERMINAL+256];
- (void)sprintf(msg,"symbol <%s> is already defined.",result);
- mgen_perror(mf,msg);
- return EOF;
- }
-
- prs->current_rhs_elem =
- append_rhs_elem(&(prs->current_rule->rhs_list));
-
- if (!prs->current_rhs_elem)
- return EOF;
- prs->current_sym = &prs->current_rhs_elem->sym_list;
- return 0;
-}
-
-static int
-get_right_hand_side(struct mgen_stream *mf, struct bnf0_prs *prs)
-{
- int c;
- MGEN_CHAR * mc;
- struct mgen_sym * sym;
-
- /* int nsyms;
- * nsyms = 0;*/
-
- do{
- c = mgen_skip_spaces(mf);
- switch (c) {
- case '|':
- prs->current_rhs_elem =
- append_rhs_elem(
- &(prs->current_rule->rhs_list)
- );
- if (!prs->current_rhs_elem)
- return EOF;
- prs->current_sym =
- &prs->current_rhs_elem->sym_list;
- break;
-
- case '<': {
- int c1;
- char result[MAX_NONTERMINAL+1];
-
- mc = mgen_get_char(mf);
- if (mc->col <= 1){
- (void)mgen_ungetc(c,mf);
- return c;
- }
-
- c1 = mgen_getc(mf);
- (void)mgen_ungetc(c1,mf);
- if (!mgen_isspace(c1)) {
- c = get_non_terminal(mf,result);
- if (c==EOF)
- return EOF;
-
- sym=append_sym(
- prs->current_sym,
- MGEN_NT_SYM,result
- );
-
- if (!sym) {
- mgen_perror(mf,
- "Can't allocate memory"
- );
- return EOF;
- }
-
- prs->current_sym = &sym->next;
- break;
- }
- /* this goto statement prevents the
- * compiler warning fall into default
- * statement */
- printf("Special goto!\n");
- goto l0;
- }
-l0:
- default:{
- char result[MAX_TERMINAL+1];
- (void)mgen_ungetc(c,mf);
- c=get_terminal(mf,result);
-
- sym=append_sym(
- prs->current_sym,MGEN_T_SYM,result
- );
-
- if (!sym){
- mgen_perror(mf,
- "Can't allocate memory"
- );
- return EOF;
- }
- (void)mgen_ungetc(c,mf);
- prs->current_sym = &sym->next;
- }
- }
-
- }while (c!=EOF);
- return EOF;
-}
-
-static int
-get_assignment (struct mgen_stream * mf)
-{
- int c,i,n;
- char * search = "::=";
-
- c = mgen_skip_spaces(mf);
-
- i=0; n=(int)strlen(search);
- do {
- if (c!=search[i]){
- mgen_perror(mf,"'::=' expected.");
- return EOF;
- }
- i++;
- c=mgen_getc(mf);
- }while(i<n);
- return c;
-}
-
-static void
-verify(struct bnf0_prs * prs)
-{
- struct mavl *t;
- struct mavliter it;
- void *data;
- struct mgen_stream mf;
-
- t = prs->rules->rules;
-
- mavliter_init(&it, t);
- (void)mavliter_seek_set(&it);
- while ((data = mavliter_get(&it)) != NULL) {
- struct mgen_rule * rule = (struct mgen_rule *)data;
- struct rhs_elem *e;
- struct mgen_sym *sym;
-
- e = rule->rhs_list;
- while (e!=NULL){
- sym = e->sym_list;
- while (sym!=NULL){
- if (sym->type == MGEN_NT_SYM){
- void * r;
- struct mgen_rule trule;
- trule.name = sym->name;
- r = mavl_get(t,&trule);
- if (!r){
- char msg[MAX_NONTERMINAL+256];
- (void)sprintf(msg,"unedfined non-terminal: <%s>",sym->name);
- mf.line = rule->line;
- mf.col = 0;
- mf.filename=NULL;
- mgen_perror(&mf,msg);
- return;
- }
- /* (void)printf("%s<%s>",delim_spc,sym->name);*/
- }
- sym = sym->next;
- }
- e=e->next;
- }
- (void)mavliter_next(&it);
- }
-}
-
-
-
-struct mgen_rule_set * mgen_read_rule_set(struct mgen_stream *mf)
-{
- struct bnf0_prs prs;
- /*struct mgen_rule_set * rules;*/
- int c;
-
- prs.rules = mgen_create_rule_set();
- if (!prs.rules){
- mgen_perror(mf,"can't allocate memory");
- return NULL;
- }
-
- do {
- c = get_left_hand_side(mf,&prs);
- if (c==EOF)
- break;
- c = get_assignment(mf);
- if (c==EOF)
- break;
- c = get_right_hand_side(mf,&prs);
-
- }while(c!=EOF);
- verify(&prs);
- return prs.rules;
-}
/bnf/mgen/mgen_read_rule_set.c
Property changes:
Deleted: svn:mergeinfo
## -0,3 +0,0 ##
Reverse-merged /branches/bnf/bnf_cleanup/mgen_read_rule_set.c:r123-126
Reverse-merged /branches/tmp-mgen/mgen_read_rule_set.c:r217-222
Reverse-merged /branches/mgen-tmp/mgen_read_rule_set.c:r152-155
Index: bnf/mgen/mgen_print_symlist.c
===================================================================
--- bnf/mgen/mgen_print_symlist.c (revision 233)
+++ bnf/mgen/mgen_print_symlist.c (nonexistent)
@@ -1,44 +0,0 @@
-/*
- * Copyright 2019,2020, The PLANIX Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "mgen.h"
-
-void
-print_symlist(struct mgen_sym * sym)
-{
- char *delim_spc;
- delim_spc="";
- while (sym!=NULL){
- if (sym->type == MGEN_NT_SYM)
- (void)printf("%s<%s>",delim_spc,sym->name);
- else
- (void)printf("%s%s",delim_spc,sym->name);
- sym = sym->next;
- delim_spc=" ";
- }
-}
-
Index: bnf/mgen/algol60.bnf
===================================================================
--- bnf/mgen/algol60.bnf (revision 233)
+++ bnf/mgen/algol60.bnf (nonexistent)
@@ -1,111 +0,0 @@
-<program> ::= <block> | <compound statement>
-<block> ::= <unlabelled block> | <label>: <block>
-<unlabelled block> ::= <block head> ; <compound tail>
-<block head> ::= begin <declaration> | <block head> ; <declaration>
-<compound statement> ::= <unlabelled compound> | <label>: <compound statement>
-<unlabelled compound> ::= begin <compound tail>
-<compound tail> ::= <statement> end | <statement> ; <compound tail>
-<declaration> ::= <type declaration> | <array declaration> | <switch declaration> | <procedure declaration>
-<type declaration> ::= <local or own type> <type list>
-<local or own type> ::= <type> | own <type>
-<type> ::= real | integer | boolean
-<type list> ::= <simple variable> | <simple variable> , <type list>
-<array declaration> ::= array <array list> | <local or own type> array <array list>
-<array list> ::= <array segment> | <array list> , <array segment>
-<array segment> ::= <array identifier> [ <bound pair list> ] | <array identifier> , <array segment>
-<array identifier> ::= <identifier>
-<bound pair list> ::= <bound pair> | <bound pair list> , <bound pair>
-<bound pair> ::= <lower bound> : <upper bound>
-<upper bound> ::= <arithmetic expression>
-<lower bound> ::= <arithmetic expression>
-<switch declaration> ::= switch <switch identifier> := <switch list>
-<switch identifier> ::= <identifier>
-<switch list> ::= <designational expression> | <switch list> , <designational expression>
-<procedure declaration> ::= procedure <procedure heading> <procedure body> | <type> procedure <procedure heading> <procedure body>
-<procedure heading> ::= <procedure identifier> <formal parameter part> ; <value part> <specification part>
-<procedure identifier> ::= <identifier>
-<formal parameter part> ::= <empty> | ( <formal parameter list> )
-<formal parameter list> ::= <formal parameter> | <formal parameter list> <parameter delimiter> <formal parameter>
-<formal parameter> ::= <identifier>
-<value part> ::= value <identifier list> ; | <empty>
-<specification part> ::= <empty> | <specifier> <identifier list> ; | <specification part> <specifier> <identifier list>
-<specifier> ::= string | <type> | array | <type> array | label | switch | procedure | <type> procedure
-<identifier list> ::= <identifier> | <identifier list> , <identifier>
-<procedure body> ::= <statement> | <code>
-<statement> ::= <unconditional statement> | <conditional statement> | <for statement>
-<unconditional statement> ::= <basic statement> | <compound statement> | <block>
-<basic statement> ::= <unlabelled basic statement> | <label>: <basic statement>
-<label> ::= <identifier> | <unsigned integer>
-<unlabelled basic statement> ::= <assignment statement> | <go to statement> | <dummy statement> | <procedure statement>
-<assignment statement> ::= <left part list> <arithmetic expression> | <left part list> <Boolean expression>
-<left part list> ::= <left part> | <left part list> <left part>
-<left part> ::= <variable> := | <procedure identifier> :=
-<go to statement> ::= goto <designational expression>
-<designational expression> ::= <simple designational expression> | <if clause> <simple designational expression> else <designational expression>
-<simple designational expression> ::= <label> | <switch designator> | (<designational expression>)
-<switch designator> ::= <switch identifier> [<subscript expression>]
-<dummy statement> ::= <empty>
-<procedure statement> ::= <procedure identifier> <actual parameter part>
-<actual parameter part> ::= <empty> | ( <actual parameter list> )
-<actual parameter list> ::= <actual parameter> | <actual parameter list> <parameter delimiter> <actual parameter>
-<parameter delimiter> ::= , | ) <letter string> : (
-<actual parameter> ::= <string> | <expression> | <array identifier> | <switch identifier> | <procedure identifier>
-<conditional statement> ::= <if statement> | <if statement> else <statement> | <if clause> <for statement> | <label>: <conditional statement>
-<if statement> ::= <if clause> <unconditional statement>
-<if clause> ::= if <Boolean expression> then
-<for statement> ::= <for clause> <statement> | <label>: <for statement>
-<for clause> ::= for <variable> := <for list> do
-<for list> ::= <for list element> | <for list> , <for list element>
-<for list element> ::= <arithmetic expression> | <arithmetic expression> step <arithmetic expression> until <arithmetic expression> | <arithmetic expression> while <Boolean expression>
-<expression> ::= <arithmetic expression> | <Boolean expression> | <designational expression>
-<arithmetic expression> ::= <simple arithmetic expression> | <if clause> <simple arithmetic expression> else <arithmetic expression>
-<simple arithmetic expression> ::= <term> | <adding operator> <term> | <simple arithmetic expression> <adding operator> <term>
-<adding operator> ::= + | –
-<term> ::= <factor> | <term> <multiplying operator> <factor>
-<multiplying operator> ::= × | / | ÷
-<factor> ::= <primary> | <factor> | <factor> ↑ <primary>
-<primary> ::= <unsigned number> | <variable> | <function designator> | ( <arithmetic expression> )
-<unsigned number> ::= <decimal number> | <exponential part> | <decimal number> <exponential part>
-
-<decimal number> ::= <unsigned integer> | <decimal fraction> | <unsigned integer> <decimal fraction>
-<unsigned integer> ::= <digit> | <unsigned integer> <digit>
-<decimal fraction> ::= . <unsigned integer>
-<exponential part> ::= 10 <integer>
-<integer> ::= <unsigned integer> | + <unsigned integer> | – <unsigned integer>
-<Boolean expression> ::= <simple Boolean> | <if clause> <simple Boolean> else <Boolean expression>
-<simple Boolean> ::= <implication> | <simple Boolean> ≣ <implication>
-<implication> ::= <Boolean term> | <implication> ⊃ <Boolean term>
-<Boolean term> ::= <Boolean factor> | <Boolean term> ⋁ <Boolean factor>
-<Boolean factor> ::= <Boolean secondary> | <Boolean factor> ⋀ <Boolean secondary>
-<Boolean secondary> ::= <Boolean primary> | ¬ <Boolean primary>
-<Boolean primary> ::= <logical value> | <variable> | <function designator> | <relation> | ( <Boolean expression> )
-<relation> ::= <simple arithmetic expression> <relational operator> <simple arithmetic expression>
-<relational operator> ::= < | ≤ | = | ≠ | > | ≥
-<function designator> ::= <procedure identifier> <actual parameter part>
-<variable> ::= <simple variable> | <subscripted variable>
-<simple variable> ::= <variable identifier>
-<variable identifier> ::= <identifier>
-<subscripted variable> ::= <array identifier> [ <subscript list> ]
-<subscript list> ::= <subscript expression> | <subscript list> , <subscript expression>
-<subscript expression> ::= <arithmetic expression>
-<string> ::= "<open string>"
-<open string> ::= <proper string> "<open string>" | <open string><open string>
-<proper string> ::= <any sequence of symbols not containing " > | <empty>
-<letter string> ::= <letter> | <letter string> <letter>
-<identifier> ::= letter> | <identifier> <letter> | <identifier> <digit>
-<basic symbol> ::= <letter> | <digit> | <logical value> | <delimiter>
-<letter> ::= a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r | s | t | u | v | w | x | y | z |
-A| B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z
-<digit> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
-<logical value> ::= true | false
-<delimiter> ::= <operator> | <separator> | <bracket> | <declarator> | <specificator>
-<operator> ::= <arithmetic operator> | <relational operator> | <logical operator> | <sequential operator>
-<arithmetic operator> ::= + | – | × | / | ÷ | ↑
-<relational operator> ::= < | ≤ | = | ≠ | > | ≥
-<logical operator> ::= ≣ | ⊃ | ⋁ | ⋀ | ¬
-<sequential operator> ::= goto | if | then | else | for | do
-<separator> ::= , | . | 10 | : | ; | := | _ | step | until | while | comment
-<bracket> ::= ( | ) | [ | ] | ` | ' | begin | end
-<declarator> ::= own | boolean | integer | real | array | switch | procedure
-<specificator> ::= string | label | value
-
Index: bnf/mgen/mgen_ring_init.c
===================================================================
--- bnf/mgen/mgen_ring_init.c (revision 233)
+++ bnf/mgen/mgen_ring_init.c (nonexistent)
@@ -1,46 +0,0 @@
-/*
- * Copyright 2019,2020, The PLANIX Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "mgen.h"
-
-void
-mgen_ring_init(struct mgen_ring *m, size_t elem_size)
-{
- m->buf=NULL;
- m->pos=0;
- m->maxpos=0;
- m->abspos=0;
- m->absmaxpos=0;
-
- m->block_size=MGEN_BUF_BLOCK_SIZE;
- m->bufmax_size=MGEN_BUF_SIZE;
- m->buf_size=0;
- m->elem_size=elem_size;
-}
-
-
-
Index: bnf/mgen/mgen_getc.c
===================================================================
--- bnf/mgen/mgen_getc.c (revision 233)
+++ bnf/mgen/mgen_getc.c (nonexistent)
@@ -1,80 +0,0 @@
-/*
- * Copyright 2019, The PLANIX Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include "mgen.h"
-
-/**
- * Function: mgen_getc
- * -------------------
- * Read one character from inputstream.
- *
- * mf: mgen_stream to read from
- *
- * returns: the next character from stream.
- *
- */
-int
-mgen_getc(struct mgen_stream * mf)
-{
- int c;
-
- if (mf->ring.abspos != mf->ring.absmaxpos){
- /* int pos;*/
- (void) mgen_ring_alloc(&mf->ring);
- c = ((MGEN_CHAR*)(mf->ring.buf))[mf->ring.pos].c;
- (void)mgen_ring_next(&mf->ring);
- }
- else{
- (void)mgen_ring_alloc(&mf->ring);
- c = fgetc(mf->infile);
- if (c==EOF)
- return EOF;
-
- ((MGEN_CHAR*)(mf->ring.buf))[mf->ring.pos].c=c;
- ((MGEN_CHAR*)(mf->ring.buf))[mf->ring.pos].line=mf->line;
- ((MGEN_CHAR*)(mf->ring.buf))[mf->ring.pos].col=mf->col;
- (void)mgen_ring_next(&mf->ring);
- switch(c) {
- case '\n':
- mf->line++;
- mf->prev_col = mf->col;
- mf->col=1;
- break;
- case '\t':
- mf->col+=mf->tab_size;
- break;
- default:
- mf->col++;
- }
-
- }
-
- /* count line number an column number */
- return c;
-}
-
Index: bnf/mgen/mgen_ungetc.c
===================================================================
--- bnf/mgen/mgen_ungetc.c (revision 233)
+++ bnf/mgen/mgen_ungetc.c (nonexistent)
@@ -1,76 +0,0 @@
-/*
- * Copyright 2019,2020, The PLANIX Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include "mgen.h"
-
-int
-mgen_ungetc(int c, MGEN_FILE *mf)
-{
- if (!mf->ring.buf)
- return EOF;
-
- if (!mgen_ring_prev(&mf->ring))
- return EOF;
-
- ((MGEN_CHAR*)mf->ring.buf)[mf->ring.pos].c=c;
-/*
- switch(c) {
- case '\n':
- mf->line--;
- mf->col=mf->prev_col;
- break;
- case '\t':
- mf->col-=8;
- break;
- default:
- mf->col--;
- }
-*/ return c;
-}
-/*
-void
-mgen_ungetc(int c, struct mgen_stream *mf)
-{
- mf->bufptr--;
- mf->buf[mf->bufptr]=(char)c;
- mf->eof=0;
-
- switch(c) {
- case '\n':
- mf->line--;
- mf->col=mf->prev_col;
- break;
- case '\t':
- mf->col-=8;
- break;
- default:
- mf->col--;
- }
-}
-
-*/
Index: bnf/mgen/mgen.h
===================================================================
--- bnf/mgen/mgen.h (revision 233)
+++ bnf/mgen/mgen.h (nonexistent)
@@ -1,170 +0,0 @@
-/*
- * Copyright 2019, The PLANIX Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _MGEN_H
-#define _MGEN_H
-
-
-#include <ctype.h>
-#include <stdio.h>
-#include <libmavl/mavl.h>
-
-#ifndef MGEN_BUF_BLOCK_SIZE
-#define MGEN_BUF_BLOCK_SIZE 1024
-#endif
-
-#ifndef MGEN_BUF_SIZE
-#define MGEN_BUF_SIZE (8192)
-#endif
-
-/* representation of a dynamically
- * growing (ring) buffer */
-struct mgen_ring{
- void *buf;
- size_t pos;
- size_t maxpos;
- size_t abspos;
- size_t absmaxpos;
-
- size_t block_size;
- size_t bufmax_size;
- size_t buf_size;
- size_t elem_size;
-};
-typedef struct mgen_ring MGEN_RING;
-void mgen_ring_init(struct mgen_ring *m,size_t elem_size);
-size_t mgen_ring_next(struct mgen_ring *m);
-int mgen_ring_prev(struct mgen_ring *m);
-int mgen_ring_add(struct mgen_ring *m);
-size_t mgen_ring_alloc(MGEN_RING *ring);
-int mgen_ring_seek(MGEN_RING * ring, size_t pos);
-
-struct mgen_char{
- int c;
- int line;
- int col;
-};
-typedef struct mgen_char MGEN_CHAR;
-
-#define mgen_ring_set_block_size(r,s) ((r)->block_size=s)
-#define mgen_ring_set_buffer_size(r,s) ((r)->bufmax_size=s)
-#define mgen_ring_getat(ring,type,pos) (&(((type*)((ring)->buf))[pos]))
-
-
-
-struct mgen_stream {
- FILE *infile; /* file pointer of current open file */
- int line; /* line number */
- int col; /* current column */
-
- MGEN_RING ring;
-
- char *buf;
- int buflast;
- int buffirst;
- int bufptr;
- int bufmax;
-
-
-
-
- int prev_col;
-
- int tab_size;
- int block_size;
- int buf_size;
-
- const char *filename;
- const char *prgname;
-
-/* int eof:1;*/
-};
-
-
-typedef struct mgen_stream MGEN_FILE;
-
-enum {
- MGEN_NT_SYM, /* describes a non-terminal symbol */
- MGEN_T_SYM /* a terminal symbol */
-};
-
-/* representation of a symbol */
-struct mgen_sym {
- int type;
- struct mgen_sym * next;
- char *name;
-};
-
-/*extern struct rhs_elem;*/
-struct rhs_elem{
- struct mgen_sym * sym_list;
- struct rhs_elem * next;
-};
-
-struct mgen_rule {
- char * name;
- int line;
- struct rhs_elem * rhs_list;
-};
-
-
-struct mgen_rule_set {
- struct mavl * rules;
-};
-typedef struct mgen_rule_set MGEN_RULE_SET;
-
-int mgen_getc(struct mgen_stream * mf);
-struct mgen_stream * mgen_open(const char *filename, const char *prgname);
-int mgen_ungetc(int c, struct mgen_stream *mf);
-int mgen_skip_spaces(struct mgen_stream * mf );
-void mgen_perror(struct mgen_stream *mf, char *msg, ...);
-struct mgen_stream * mgen_open_stream(FILE *infile, const char *prgname);
-struct mgen_rule_set * mgen_read_rule_set(struct mgen_stream *mf);
-struct mgen_rule_set * mgen_create_rule_set();
-int mgen_parse( struct mgen_stream *mf,
- struct mgen_rule_set *rules,
- const char * start);
-
-/* debugging stuff */
-void print_symlist(struct mgen_sym * sym);
-void print_rhs_list(struct rhs_elem *e);
-
-#define mgen_isspace(c) isspace(c)
-
-
-#define mgen_tell(mf) (mf->ring.abspos)
-
-/*#define mgen_seek(mf,pos) (mf->bufptr=(pos))*/
-
-
-#define mgen_seek(mf,pos) mgen_ring_seek(&((mf)->ring),pos)
-
-
-#define mgen_set_block_size(mf,s) mf->block_size=s
-#define mgen_set_buf_size(mf,s) mf->buf_size=s
-
-#endif
Index: bnf/mgen/my.prg
===================================================================
--- bnf/mgen/my.prg (revision 233)
+++ bnf/mgen/my.prg (nonexistent)
@@ -1 +0,0 @@
-abc
Index: bnf/mgen/Makefile
===================================================================
--- bnf/mgen/Makefile (revision 233)
+++ bnf/mgen/Makefile (nonexistent)
@@ -1,40 +0,0 @@
-
-
-OBJS= mgen_getc.o \
- mgen_open.o \
- mgen_ungetc.o \
- mgen_skip_spaces.o \
- mgen_perror.o \
- mgen_read_rule_set.o \
- mgen_create_rule_set.o \
- mgen_print_symlist.o \
- mgen_print_rhs_list.o \
- mgen_parse.o \
- mgen_ring_init.o \
- mgen_ring_alloc.o \
- mgen_ring_prev.o\
- mgen_ring_next.o\
- mgen_ring_seek.o\
-
-PRGOBJS=\
- bnf.o
-
-TSTOBJS=\
- test.o
-
-PRG=bnf
-TSTPRG=test
-
-.c.o:
- $(CC) -c $(CFLAGS) $<
-
-$(PRG): $(OBJS) $(PRGOBJS)
- $(CC) $(LDFLAGS) -o $(PRG) $(PRGOBJS) $(OBJS) -lmavl
-
-$(TSTPRG): $(OBJS) $(TSTOBJS)
- $(CC) $(LDFLAGS) -o $(TSTPRG) $(TSTOBJS) $(OBJS) -lmavl -lmutests
-
-clean:
- rm -f *.o
- rm -f $(PRG) $(TSTPRG)
- rm -f *.core
Index: bnf/mgen/LICENSE
===================================================================
--- bnf/mgen/LICENSE (revision 233)
+++ bnf/mgen/LICENSE (nonexistent)
@@ -1,26 +0,0 @@
-/*
- * Copyright 2019,2020, The PLANIX Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
Index: bnf/mgen/mgen_ring_prev.c
===================================================================
--- bnf/mgen/mgen_ring_prev.c (revision 233)
+++ bnf/mgen/mgen_ring_prev.c (nonexistent)
@@ -1,59 +0,0 @@
-/*
- * Copyright 2019,2020, The PLANIX Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "mgen.h"
-
-int
-mgen_ring_prev(struct mgen_ring *m)
-{
- if ( (m->buf_size!=m->bufmax_size) || (m->bufmax_size==0) ){
- if (m->abspos>0){
- m->pos--;
- m->abspos--;
- return 1;
- }
- return 0;
- }
-
-/* printf("%d >= %d\n",m->absmaxpos - m->abspos,m->bufmax_size);*/
- if ((m->absmaxpos - m->abspos) >= m->bufmax_size){
-/* printf("ERRR!\n");*/
- return 0;
- }
-
- if(m->pos==0){
- m->pos = m->bufmax_size-1;
- m->abspos--;
- return 1;
- }
-
- m->pos--;
- m->abspos--;
- return 1;
-
-}
-
-
Index: bnf/mgen/algol60.txt
===================================================================
--- bnf/mgen/algol60.txt (revision 233)
+++ bnf/mgen/algol60.txt (nonexistent)
@@ -1,110 +0,0 @@
-
-<program> ::= <block> | <compound statement>
-<block> ::= <unlabelled block> | <label>: <block>
-<unlabelled block> ::= <block head> ;
-<compound tail>
-<block head> ::= begin <declaration> | <block head> ; <declaration>
-<compound statement> ::= <unlabelled compound> | <label>: <compound statement>
-<unlabelled compound> ::= begin <compound tail>
-<compound tail> ::= <statement> end | <statement> ;
-<compound tail>
-<declaration> ::=
- <type declaration> | <array declaration> | <switch declaration> | <procedure declaration>
-
-<type declaration> ::= <local or own type>
-<type list>
-<local or own type> ::= <type> | own
-<type>
-<type> ::= real | integer | boolean
-<type list> ::= <simple variable> | <simple variable> , <type list>
-<array declaration> ::= array <array list> | <local or own type> array <array list>
-<array list> ::= <array segment> | <array list> , <array segment>
-<array segment> ::= <array identifier> [ <bound pair list> ] | <array identifier> , <array segment>
-<array identifier> ::= <identifier>
-<bound pair list> ::= <bound pair> | <bound pair list> , <bound pair>
-<bound pair> ::= <lower bound> : <upper bound>
-<upper bound> ::= <arithmetic expression>
-<lower bound> ::= <arithmetic expression>
-<switch declaration> ::= switch <switch identifier> := <switch list>
-<switch identifier> ::= <identifier>
-<switch list> ::= <designational expression> | <switch list> , <designational expression>
-<procedure declaration> ::= procedure <procedure heading> <procedure body> | <type> procedure <procedure heading> <procedure body>
-<procedure heading> ::= <procedure identifier> <formal parameter part> ; <value part> <specification part>
-<procedure identifier> ::= <identifier>
-<formal parameter part> ::= <empty> | ( <formal parameter list> )
-<formal parameter list> ::= <formal parameter> | <formal parameter list> <parameter delimiter> <formal parameter>
-<formal parameter> ::= <identifier> <value part> ::= value <identifier list> ; | <empty>
-<specification part> ::= <empty> | <specifier> <identifier list> ; | <specification part> <specifier> <identifier list>
-<specifier> ::= string | <type> | array | <type> array | label | switch | procedure | <type> procedure<identifier list> ::= <identifier> | <identifier list> , <identifier>
-<procedure body> ::= <statement> | <code>
-<statement> ::= <unconditional statement> | <conditional statement> | <for statement>
-<unconditional statement> ::= <basic statement> | <compound statement> | <block>
-<basic statement> ::= <unlabelled basic statement> | <label>: <basic statement>
-<label> ::= <identifier> | <unsigned integer>
-<unlabelled basic statement> ::= <assignment statement> | <go to statement> | <dummy statement> | <procedure statement>
-<assignment statement> ::= <left part list> <arithmetic expression> | <left part list> <Boolean expression>
-<left part list> ::= <left part> | <left part list> <left part>
-<left part> ::= <variable> := | <procedure identifier> :=<go to statement> ::= goto <designational expression>
-<designational expression> ::= <simple designational expression> |<if clause> <simple designational expression> else <designational expression>
-<simple designational expression> ::= <label> | <switch designator> | (<designational expression>)
-<switch designator> ::= <switch identifier> [<subscript expression>]
-<dummy statement> ::= <empty>
-<procedure statement> ::= <procedure identifier> <actual parameter part>
-<actual parameter part> ::= <empty> | ( <actual parameter list> )
-<actual parameter list> ::= <actual parameter> | <actual parameter list> <parameter delimiter> <actual parameter>
-
-<parameter delimiter> ::= , | ) <letter string> : (
-<actual parameter> ::= <string> | <expression> | <array identifier> | <switch identifier> | <procedure identifier>
-
-<conditional statement> ::= <if statement> | <if statement> else <statement> |
- <if clause> <for statement> | <label>: <conditional statement>
-
-<if statement> ::= <if clause> <unconditional statement>
-<if clause> ::= if <Boolean expression> then<for statement> ::= <for clause> <statement> | <label>: <for statement>
-<for clause> ::= for <variable> := <for list> do<for list> ::= <for list element> | <for list> , <for list element>
-<for list element> ::= <arithmetic expression> |<arithmetic expression> step <arithmetic expression> until <arithmetic expression> |<arithmetic expression> while <Boolean expression>
-<expression> ::= <arithmetic expression> | <Boolean expression> | <designational expression>
-<arithmetic expression> ::= <simple arithmetic expression> | <if clause> <simple arithmetic expression> else <arithmetic expression>
-<simple arithmetic expression> ::= <term> | <adding operator> <term> | <simple arithmetic expression> <adding operator> <term>
-<adding operator> ::= + | –<term> ::= <factor> | <term> <multiplying operator> <factor>
-<multiplying operator> ::= × | / | ÷<factor> ::= <primary> | <factor> | <factor> ↑ <primary>
-<primary> ::= <unsigned number> | <variable> | <function designator> | ( <arithmetic expression> )<unsigned number> ::= <decimal number> | <exponential part> | <decimal number> <exponential part>
-<decimal number> ::= <unsigned integer> | <decimal fraction> | <unsigned integer> <decimal fraction>
-<unsigned integer> ::= <digit> | <unsigned integer> <digit>
-<decimal fraction> ::= . <unsigned integer>
-<exponential part> ::= 10 <integer>
-<integer> ::= <unsigned integer> | + <unsigned integer> | – <unsigned integer>
-<Boolean expression> ::= <simple Boolean> | <if clause> <simple Boolean> else <Boolean expression>
-<simple Boolean> ::= <implication> | <simple Boolean> ≣ <implication>
-<implication> ::= <Boolean term> | <implication> ⊃ <Boolean term>
-<Boolean term> ::= <Boolean factor> | <Boolean term> ⋁ <Boolean factor>
-<Boolean factor> ::= <Boolean secondary> | <Boolean factor> ⋀ <Boolean secondary>
-<Boolean secondary> ::= <Boolean primary> | ¬ <Boolean primary>
-<Boolean primary> ::= <logical value> | <variable> | <function designator> | <relation> | ( <Boolean expression> )<relation> ::= <simple arithmetic expression> <relational operator> <simple arithmetic expression>
-<relational operator> ::= < | ≤ | = | ≠ | > | ≥<function designator> ::= <procedure identifier> <actual parameter part>
-<variable> ::= <simple variable> | <subscripted variable>
-<simple variable> ::= <variable identifier>
-<variable identifier> ::= <identifier>
-<subscripted variable> ::= <array identifier> [ <subscript list> ]<subscript list> ::= <subscript expression> | <subscript list> , <subscript expression>
-<subscript expression> ::= <arithmetic expression>
-<string> ::= "<open string>"
-<open string> ::= <proper string> "<open string>" | <open string>
-<open string>
-<proper string> ::= <any sequence of symbols not containing " > | <empty>
-<letter string> ::= <letter> | <letter string> <letter>
-<identifier> ::= letter> | <identifier> <letter> | <identifier> <digit>
-<basic symbol> ::= <letter> | <digit> | <logical value> | <delimiter>
-<letter> ::= a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r | s | t | u | v | w | x | y | z |A |B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z
-<digit> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
-<logical value> ::= true | false
-<delimiter> ::= <operator> | <separator> | <bracket> | <declarator> | <specificator>
-<operator> ::= <arithmetic operator> | <relational operator> | <logical operator> | <sequential operator>
-<arithmetic operator> ::= + | – | × | / | ÷ | ↑
-<relational operator> ::= < | ≤ | = | ≠ | > | ≥
-<logical operator> ::= ≣ | ⊃ | ⋁ | ⋀ | ¬
-<sequential operator> ::= goto | if | then | else | for | do
-<separator> ::= , | . | 10 | : | ; | := | _ | step | until | while | comment
-<bracket> ::= ( | ) | [ | ] | ` | ' | begin | end
-<declarator> ::= own | boolean | integer | real | array | switch | procedure
-<specificator> ::= string | label | value
-
Index: bnf/mgen/mgen_ring_next.c
===================================================================
--- bnf/mgen/mgen_ring_next.c (revision 233)
+++ bnf/mgen/mgen_ring_next.c (nonexistent)
@@ -1,45 +0,0 @@
-/*
- * Copyright 2019,2020, The PLANIX Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "mgen.h"
-
-size_t
-mgen_ring_next(struct mgen_ring *m)
-{
- m->pos++;
-
- if (m->pos == m->bufmax_size && m->bufmax_size!=0){
- m->pos=0;
- }
- m->abspos++;
- if (m->abspos > m->absmaxpos){
- m->absmaxpos = m->abspos;
- m->maxpos=m->pos;
- }
- return m->pos;
-}
-
Index: bnf/mgen/bnf.c
===================================================================
--- bnf/mgen/bnf.c (revision 233)
+++ bnf/mgen/bnf.c (nonexistent)
@@ -1,143 +0,0 @@
-/*
- * Copyright 2019, The PLANIX Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include <libmavl/mavl.h>
-
-#define MAX_NONTERMINAL 1024
-#define MAX_TERMINAL 1024
-
-#include "mgen.h"
-
-const char * prgname;
-
-void
-print(struct mavl *t)
-{
- struct mavliter it;
- void *data;
-
- mavliter_init(&it, t);
- (void)mavliter_seek_set(&it);
-
- while ((data = mavliter_get(&it)) != NULL) {
- struct mgen_rule * rule = (struct mgen_rule *)data;
- struct rhs_elem *e;
- struct mgen_sym *sym;
- char * delim_or, *delim_spc;
-
- delim_or="";
-
- (void)printf("<%s> ::= ",rule->name);
- e = rule->rhs_list;
- while (e!=NULL){
- sym = e->sym_list;
- (void)printf("%s",delim_or);
- delim_or="|";
- delim_spc="";
- while (sym!=NULL){
- if (sym->type == MGEN_NT_SYM)
- (void)printf("%s<%s>",delim_spc,sym->name);
- else
- (void)printf("%s%s",delim_spc,sym->name);
- sym = sym->next;
- delim_spc=" ";
- }
- e=e->next;
- }
- (void)printf("\n");
-
-
- (void)mavliter_next(&it);
- }
-}
-
-int
-main(int argc, char *argv[])
-{
- struct mgen_stream *mf;
- struct mgen_rule_set * rules;
- int rc;
- FILE *infile;
- const char * filename;
-
- if (argc>0)
- prgname = argv[0];
- else
- prgname ="";
-
- if (argc==1){
- infile = stdin;
- filename = NULL;
- }
- else{
- infile = fopen(argv[1],"rt");
- filename=argv[1];
- if (!infile){
- (void)fprintf(stderr,
- "%s: error: can't open '%s': %s\n",
- prgname,filename,strerror(errno)
- );
- return errno;
- }
-
- }
-
- mf = mgen_open_stream(infile,prgname);
- if (!mf){
- (void)fprintf(stderr,"Error: %s",strerror(errno));
- return errno;
- }
-
- rules = mgen_read_rule_set(mf);
-
- if (argc==3){
- mf = mgen_open(argv[2],prgname);
- if (!mf){
- perror("");
- return 1;
- }
-/* mgen_set_block_size(mf,1112);
- mgen_set_buf_size(mf,1118);
-*/
-
-(void)printf("call parse\n");
-(void)printf("================================================\n");
- rc = mgen_parse(mf,rules,"Programm");
- (void)printf("RC: %s\n", rc ? "TRUE" : "FALSE");
-
- /*run(rules,argv[2]);*/
- }
- (void)printf("------------------------------\n");
- print(rules->rules);
-
- return 0;
-}
Index: bnf/mgen/mgen_open.c
===================================================================
--- bnf/mgen/mgen_open.c (revision 233)
+++ bnf/mgen/mgen_open.c (nonexistent)
@@ -1,99 +0,0 @@
-/*
- * Copyright 2019,2020, The PLANIX Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "mgen.h"
-
-static struct mgen_stream *
-mgen_stream_create()
-{
- struct mgen_stream * mf;
- mf = malloc(sizeof(struct mgen_stream));
- if (!mf)
- return NULL;
-
- mgen_ring_init(&(mf->ring),sizeof(MGEN_CHAR));
-
-
-/* mf->buf = malloc(MGEN_BUF_BLOCK_SIZE);
- if (!mf->buf){
- free (mf);
- return NULL;
- }*/
-
- mf->buf = NULL;
- mf->bufmax = 0;
- mf->buflast=0;
- mf->buffirst=0;
- mf->buf_size = MGEN_BUF_SIZE;
- mf->block_size = MGEN_BUF_BLOCK_SIZE;
-
- mf->line = 1;
- mf->col=1;
- mf->bufptr=0;
- mf->filename = NULL;
-/* mf->eof=0;*/
- return mf;
-}
-
-struct mgen_stream *
-mgen_open_stream(FILE *infile, const char *prgname)
-{
- struct mgen_stream * mf;
- mf = mgen_stream_create();
- if (!mf){
- return NULL;
- }
- mf->prgname = prgname;
- mf->infile = infile;
- return mf;
-}
-
-struct mgen_stream *
-mgen_open(const char *filename, const char *prgname)
-{
- FILE * infile;
- struct mgen_stream * mf;
-
- infile = fopen(filename,"rt");
- if (infile==NULL)
- return NULL;
-
-
- mf = mgen_open_stream(infile,prgname);
-/* mf = mgen_stream_create();*/
- if (!mf){
- (void)fclose(infile);
- return NULL;
- }
-
-/* mf->infile = infile;*/
- return mf;
-}
-
Index: bnf/mgen/my.bnf
===================================================================
--- bnf/mgen/my.bnf (revision 233)
+++ bnf/mgen/my.bnf (nonexistent)
@@ -1,11 +0,0 @@
-<Programm> ::= a b c
-
-<Programm1> ::= <Wort> Z u m s e l
-<Buchstabe> ::= <Kleinbuchstabe> | <Grossbuchstabe>
-<Wort> ::= <Buchstabe> <Wortrest> <Delimiter>
-<Wortrest> ::= <Buchstabe> <Wortrest> |
-<Kleinbuchstabe> ::= a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z
-<Grossbuchstabe> ::= A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z
-<Delimiter> ::= _ <Delimiterrest>
-<Delimiterrest> ::= <Delimiter> |
-
Index: bnf/mgen/mgen_print_rhs_list.c
===================================================================
--- bnf/mgen/mgen_print_rhs_list.c (revision 233)
+++ bnf/mgen/mgen_print_rhs_list.c (nonexistent)
@@ -1,53 +0,0 @@
-/*
- * Copyright 2019,2020, The PLANIX Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "mgen.h"
-
-void
-print_rhs_list(struct rhs_elem *e)
-{
- struct mgen_sym *sym;
- char * delim_or, *delim_spc;
- delim_or="";
- while (e!=NULL){
- sym = e->sym_list;
- (void)printf("%s",delim_or);
- delim_or="|";
- delim_spc="";
- while (sym!=NULL){
- if (sym->type == MGEN_NT_SYM)
- (void)printf("%s<%s>",delim_spc,sym->name);
- else
- (void)printf("%s%s",delim_spc,sym->name);
- sym = sym->next;
- delim_spc=" ";
- }
- e=e->next;
- }
-}
-
-
Index: bnf/mgen
===================================================================
--- bnf/mgen (revision 233)
+++ bnf/mgen (nonexistent)
/bnf/mgen
Property changes:
Deleted: svn:mergeinfo
## -0,2 +0,0 ##
Reverse-merged /branches/bnf/bnf_cleanup:r123-126
Reverse-merged /branches/mgen-tmp:r152-155