aboutsummaryrefslogtreecommitdiffstats
path: root/meson/test cases/frameworks/8 flex
diff options
context:
space:
mode:
authorAngelos Mouzakitis <a.mouzakitis@virtualopensystems.com>2023-10-10 14:33:42 +0000
committerAngelos Mouzakitis <a.mouzakitis@virtualopensystems.com>2023-10-10 14:33:42 +0000
commitaf1a266670d040d2f4083ff309d732d648afba2a (patch)
tree2fc46203448ddcc6f81546d379abfaeb323575e9 /meson/test cases/frameworks/8 flex
parente02cda008591317b1625707ff8e115a4841aa889 (diff)
Add submodule dependency filesHEADmaster
Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec
Diffstat (limited to 'meson/test cases/frameworks/8 flex')
-rw-r--r--meson/test cases/frameworks/8 flex/lexer.l11
-rw-r--r--meson/test cases/frameworks/8 flex/meson.build33
-rw-r--r--meson/test cases/frameworks/8 flex/parser.y11
-rw-r--r--meson/test cases/frameworks/8 flex/prog.c40
-rw-r--r--meson/test cases/frameworks/8 flex/test.txt1
5 files changed, 96 insertions, 0 deletions
diff --git a/meson/test cases/frameworks/8 flex/lexer.l b/meson/test cases/frameworks/8 flex/lexer.l
new file mode 100644
index 000000000..952eeea12
--- /dev/null
+++ b/meson/test cases/frameworks/8 flex/lexer.l
@@ -0,0 +1,11 @@
+%{
+#include <stdlib.h>
+#include "parser.tab.h"
+
+extern int yylex(void);
+extern int yyerror();
+%}
+
+%%
+("true"|"false") {return BOOLEAN;}
+. { yyerror(); }
diff --git a/meson/test cases/frameworks/8 flex/meson.build b/meson/test cases/frameworks/8 flex/meson.build
new file mode 100644
index 000000000..cb5efdeb4
--- /dev/null
+++ b/meson/test cases/frameworks/8 flex/meson.build
@@ -0,0 +1,33 @@
+project('flex and bison', 'c')
+
+# The point of this test is that one generator
+# may output headers that are necessary to build
+# the sources of a different generator.
+
+flex = find_program('flex', required: false)
+bison = find_program('bison', required: false)
+
+if not flex.found()
+ error('MESON_SKIP_TEST flex not found.')
+endif
+
+if not bison.found()
+ error('MESON_SKIP_TEST bison not found.')
+endif
+
+lgen = generator(flex,
+output : '@PLAINNAME@.yy.c',
+arguments : ['-o', '@OUTPUT@', '@INPUT@'])
+
+lfiles = lgen.process('lexer.l')
+
+pgen = generator(bison,
+output : ['@BASENAME@.tab.c', '@BASENAME@.tab.h'],
+arguments : ['@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@'])
+
+pfiles = pgen.process('parser.y')
+
+e = executable('pgen', 'prog.c',
+lfiles, pfiles)
+
+test('parsertest', e)
diff --git a/meson/test cases/frameworks/8 flex/parser.y b/meson/test cases/frameworks/8 flex/parser.y
new file mode 100644
index 000000000..663f2f3cf
--- /dev/null
+++ b/meson/test cases/frameworks/8 flex/parser.y
@@ -0,0 +1,11 @@
+%{
+extern int yylex(void);
+extern int yyerror();
+%}
+
+%token BOOLEAN
+
+%%
+input:
+ BOOLEAN { $$ = $1;}
+;
diff --git a/meson/test cases/frameworks/8 flex/prog.c b/meson/test cases/frameworks/8 flex/prog.c
new file mode 100644
index 000000000..0b84d1823
--- /dev/null
+++ b/meson/test cases/frameworks/8 flex/prog.c
@@ -0,0 +1,40 @@
+#include"parser.tab.h"
+#include<unistd.h>
+#include<sys/types.h>
+#include<sys/stat.h>
+#include<fcntl.h>
+#include<stdio.h>
+#include<stdlib.h>
+
+extern int yyparse();
+
+int main(int argc, char **argv) {
+ /*
+ int input;
+ if(argc != 2) {
+ printf("%s <input file>");
+ return 1;
+ }
+ input = open(argv[1], O_RDONLY);
+ dup2(input, STDIN_FILENO);
+ close(input);
+ return yyparse();
+ */
+ /* We really should test that the
+ * generated parser works with input
+ * but it froze and I don't want to waste
+ * time debugging that. For this test what
+ * we care about is that it compiles and links.
+ */
+ void* __attribute__((unused)) dummy = (void*)yyparse;
+ return 0;
+}
+
+int yywrap(void) {
+ return 0;
+}
+
+int yyerror(void) {
+ printf("Parse error\n");
+ exit(1);
+}
diff --git a/meson/test cases/frameworks/8 flex/test.txt b/meson/test cases/frameworks/8 flex/test.txt
new file mode 100644
index 000000000..27ba77dda
--- /dev/null
+++ b/meson/test cases/frameworks/8 flex/test.txt
@@ -0,0 +1 @@
+true