File tree Expand file tree Collapse file tree 5 files changed +79
-0
lines changed
test cases/frameworks/8 flex Expand file tree Collapse file tree 5 files changed +79
-0
lines changed Original file line number Diff line number Diff line change
1
+ %{
2
+ #include < stdlib.h>
3
+ #include " parser.tab.h"
4
+ %}
5
+
6
+ %%
7
+ (" true" | " false" ) {return BOOLEAN;}
8
+ . { yyerror (); }
Original file line number Diff line number Diff line change
1
+ project (' flex and bison' , ' c' )
2
+
3
+ # The point of this test is that one generator
4
+ # may output headers that are necessary to build
5
+ # the sources of a different generator.
6
+
7
+ flex = find_program (' flex' )
8
+ bison = find_program (' bison' )
9
+
10
+ lgen = generator (flex,
11
+ output : ' @PLAINNAME@.yy.c' ,
12
+ arguments : [' -o' , ' @OUTPUT@' , ' @INPUT@' ])
13
+
14
+ lfiles = lgen.process(' lexer.l' )
15
+
16
+ pgen = generator (bison,
17
+ output : [' @BASENAME@.tab.c' , ' @BASENAME@.tab.h' ],
18
+ arguments : [' @INPUT@' , ' --defines=@OUTPUT1@' , ' --output=@OUTPUT0@' ])
19
+
20
+ pfiles = pgen.process(' parser.y' )
21
+
22
+ e = executable (' pgen' , ' prog.c' ,
23
+ lfiles, pfiles)
24
+
25
+ test (' parsertest' , e)
26
+
Original file line number Diff line number Diff line change
1
+ %token BOOLEAN
2
+
3
+ %%
4
+ input :
5
+ BOOLEAN { $$ = $1 ;}
6
+ ;
Original file line number Diff line number Diff line change
1
+ #include "parser.tab.h"
2
+ #include <unistd.h>
3
+ #include <sys/types.h>
4
+ #include <sys/stat.h>
5
+ #include <fcntl.h>
6
+ #include <stdio.h>
7
+ #include <stdlib.h>
8
+
9
+ int main (int argc , char * * argv ) {
10
+ /*
11
+ int input;
12
+ if(argc != 2) {
13
+ printf("%s <input file>");
14
+ return 1;
15
+ }
16
+ input = open(argv[1], O_RDONLY);
17
+ dup2(input, STDIN_FILENO);
18
+ close(input);
19
+ return yyparse();
20
+ */
21
+ /* We really should test that the
22
+ * generated parser works with input
23
+ * but it froze and I don't want to waste
24
+ * time debugging that. For this test what
25
+ * we care about is that it compiles and links.
26
+ */
27
+ void * __attribute__ ( (unused )) dummy = (void * )yyparse ;
28
+ return 0 ;
29
+ }
30
+
31
+ int yywrap (void ) {
32
+ return 0 ;
33
+ }
34
+
35
+ int yyerror (void ) {
36
+ printf ("Parse error\n" );
37
+ exit (1 );
38
+ }
Original file line number Diff line number Diff line change
1
+ true
You can’t perform that action at this time.
0 commit comments