diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-29 04:41:38 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-29 04:41:38 +0000 |
commit | 7b6e527f440cd7e6f8be2b07cee320ee6ca18786 (patch) | |
tree | 4a2738d69fa2814659fdadddf5826282e73d81f4 /test cases/frameworks/8 flex | |
parent | Initial commit. (diff) | |
download | meson-7b6e527f440cd7e6f8be2b07cee320ee6ca18786.tar.xz meson-7b6e527f440cd7e6f8be2b07cee320ee6ca18786.zip |
Adding upstream version 1.0.1.upstream/1.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test cases/frameworks/8 flex')
-rw-r--r-- | test cases/frameworks/8 flex/lexer.l | 13 | ||||
-rw-r--r-- | test cases/frameworks/8 flex/meson.build | 36 | ||||
-rw-r--r-- | test cases/frameworks/8 flex/parser.y | 11 | ||||
-rw-r--r-- | test cases/frameworks/8 flex/prog.c | 30 | ||||
-rw-r--r-- | test cases/frameworks/8 flex/test.json | 3 | ||||
-rw-r--r-- | test cases/frameworks/8 flex/test.txt | 1 | ||||
-rw-r--r-- | test cases/frameworks/8 flex/testfile | 1 |
7 files changed, 95 insertions, 0 deletions
diff --git a/test cases/frameworks/8 flex/lexer.l b/test cases/frameworks/8 flex/lexer.l new file mode 100644 index 0000000..ca6513c --- /dev/null +++ b/test cases/frameworks/8 flex/lexer.l @@ -0,0 +1,13 @@ +%{ +#include <stdlib.h> +#include "parser.tab.h" + +extern int yylex(void); +extern int yyerror(); +%} + +%option noyywrap nounput noinput + +%% +("true"|"false") {return BOOLEAN;} +. { yyerror(); } diff --git a/test cases/frameworks/8 flex/meson.build b/test cases/frameworks/8 flex/meson.build new file mode 100644 index 0000000..55b96dd --- /dev/null +++ b/test cases/frameworks/8 flex/meson.build @@ -0,0 +1,36 @@ +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, + override_options: 'unity=off') + +test('parsertest', e, + args: [meson.current_source_dir() / 'testfile']) diff --git a/test cases/frameworks/8 flex/parser.y b/test cases/frameworks/8 flex/parser.y new file mode 100644 index 0000000..663f2f3 --- /dev/null +++ b/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/test cases/frameworks/8 flex/prog.c b/test cases/frameworks/8 flex/prog.c new file mode 100644 index 0000000..ae481d0 --- /dev/null +++ b/test cases/frameworks/8 flex/prog.c @@ -0,0 +1,30 @@ +#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>\n", argv[0]); + return 1; + } + input = open(argv[1], O_RDONLY); + dup2(input, STDIN_FILENO); + close(input); + return yyparse(); +} + +int yywrap(void) { + return 0; +} + +int yyerror(void) { + printf("Parse error\n"); + exit(1); +} diff --git a/test cases/frameworks/8 flex/test.json b/test cases/frameworks/8 flex/test.json new file mode 100644 index 0000000..613cfe5 --- /dev/null +++ b/test cases/frameworks/8 flex/test.json @@ -0,0 +1,3 @@ +{ + "skip_on_jobname": ["azure", "cygwin"] +} diff --git a/test cases/frameworks/8 flex/test.txt b/test cases/frameworks/8 flex/test.txt new file mode 100644 index 0000000..27ba77d --- /dev/null +++ b/test cases/frameworks/8 flex/test.txt @@ -0,0 +1 @@ +true diff --git a/test cases/frameworks/8 flex/testfile b/test cases/frameworks/8 flex/testfile new file mode 100644 index 0000000..27ba77d --- /dev/null +++ b/test cases/frameworks/8 flex/testfile @@ -0,0 +1 @@ +true |