Akim Demaille wrote: > Can you show the content of this file? Can you also show where you > include it in your Bison file? Maybe you include the flex header from > the bison and vice versa, which probably does not work as expected. > Usually you include the Bison header from the Flex scanner (to get the > token definitions and so forth). I have no experience with the > converse.
Sure. I'll attach all the files (flex, bison, makefile). As a side note, I believe I'm having trouble posting messages to the mailing list. I started posting them through the gmane newsgroup but I'm not sure they found their way into the mailing list. Does anyone use gmane to access the mailing list? If so, what's the best way to post messages to this mailing list? Rui Maciel
%{ #define YY_HEADER_EXPORT_START_CONDITIONS #include <stdio.h> #include "lex.yy.h" /* for the lexer's start states */ %} %union { double real; int integer; } %token <real> FLOAT; %token <integer> INTEGER; %token WS %token LABEL_OPEN %token LABEL_CLOSE %token MESH_FORMAT %token NODES %token ELEMENTS %token EL_QUAD4 %% document: | HeaderField NodesField ElementsField ; HeaderField: StartHeader HeaderValues EndHeader { printf("all header ok\n"); } ; StartHeader: LABEL_OPEN MESH_FORMAT '\n' { printf("opened header\n"); } ; HeaderValues: FLOAT WS INTEGER WS INTEGER '\n' { printf("version: %f [%d,%d]\n",$1,$3,$5); } ; EndHeader: LABEL_CLOSE MESH_FORMAT '\n' { printf("closed header\n"); } ; NodesField: StartNodes NodesLinesCount NodesLines EndNodes { printf("all nodes ok\n"); } ; StartNodes: LABEL_OPEN NODES '\n' { printf("open nodes\n"); } ; NodesLinesCount: INTEGER '\n' { printf("%d lines\n", $1); } ; NodesLines: | NodesLines NodesLine ; NodesLine: INTEGER WS FLOAT WS FLOAT WS FLOAT '\n' { printf("[%d] {%f,%f,%f}\n", $1, $3, $5, $7); } ; EndNodes: LABEL_CLOSE NODES '\n' { printf("close nodes\n"); } ; ElementsField: StartElements ElementsLinesCount ElementsLines EndElements { printf("all elements ok\n"); } ; ElementsLinesCount: INTEGER '\n' { printf("%d lines\n", $1); } ; StartElements: LABEL_OPEN ELEMENTS '\n' { printf("open elements\n"); } ; ElementsLines: | ElementsLines CompleteElementLine ; CompleteElementLine: INTEGER WS Element_tags_nodes { yy_push_state(s_element); } ; Element_tags_nodes: ; EndElements: LABEL_CLOSE ELEMENTS '\n' { printf("close elements\n"); } ; %%
all: msh msh: lex.yy.c msh.tab.c cc -o msh lex.yy.c msh.tab.c -ll -ly lex.yy.c: msh.l msh.y flex --header-file=lex.yy.h msh.l msh.tab.c: msh.l msh.y bison -d --debug msh.y clean: rm -f msh msh.tab.c msh.tab.h lex.yy.c lex.yy.h
%{ #include "msh.tab.h" %} %x s_element %option stack dreal ([0-9]*"."[0-9]+) ereal ([0-9]*"."[0-9]+[eE][+-]?[0-9]+) real {dreal}|{ereal} %% \n { return '\n'; } [ \t]+ { return (WS); } ^\$ { return (LABEL_OPEN); } ^\$End { return (LABEL_CLOSE); } MeshFormat { return (MESH_FORMAT) ; } Nodes { return (NODES); } Elements { return (ELEMENTS); } [0-9]+ { sscanf(yytext,"%d",&yylval.integer); return INTEGER; } {real} { sscanf(yytext,"%lf",&yylval.real); return FLOAT; } <s_element>"3 " { return (EL_QUAD4); } %%
_______________________________________________ help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison