meson.build

Mon, 01 Sep 2025 00:14:59 +0800

author
Gong Zhile <gongzl@stu.hebust.edu.cn>
date
Mon, 01 Sep 2025 00:14:59 +0800
changeset 0
59c92fa19678
permissions
-rw-r--r--

Initial Lexer/Parser

0
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
1 project('tlvc', 'c',
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
2 version : '0.1',
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
3 default_options : ['warning_level=3'])
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
4
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
5 flex = find_program('flex')
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
6 bison = find_program('bison')
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
7
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
8 lexer = generator(
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
9 flex,
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
10 output : [ '@BASENAME@.yy.c', '@BASENAME@.yy.h' ],
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
11 arguments : [
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
12 '--outfile=@OUTPUT0@',
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
13 '--header-file=@OUTPUT1@',
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
14 '@INPUT@'
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
15 ]
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
16 )
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
17
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
18 parser = generator(
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
19 bison,
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
20 output : [ '@BASENAME@.tab.c', '@BASENAME@.tab.h' ],
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
21 arguments : [
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
22 '-d', '@INPUT@', '-v',
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
23 '--output=@OUTPUT0@',
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
24 '--defines=@OUTPUT1@'
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
25 ]
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
26 )
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
27
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
28 parser_src = parser.process('tlvc.y')
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
29 lexer_src = lexer.process('tlvc.l')
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
30
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
31 SOURCES = [
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
32 'tlvc.c',
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
33 parser_src,
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
34 lexer_src,
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
35 ]
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
36
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
37 exe = executable('tlvc', SOURCES,
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
38 include_directories : include_directories('.'),
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
39 install : true)
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
40
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
41 test('basic', exe)

mercurial