tlvc.c

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 #include <stdio.h>
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
2 #include <stdlib.h>
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
3 #include <string.h>
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
4 #include <sys/queue.h>
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
5
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
6 #include "tlvast.h"
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
7 #include "tlvc.tab.h"
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
8
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
9 struct tlv_list_head g_tlvs;
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
10
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
11 void yyerror(YYLTYPE *yylloc, const char *s)
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
12 {
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
13 fprintf(stderr, "Synatx error (%d:%d): %s\n",
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
14 yylloc->first_line, yylloc->first_column, s);
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 int main(int argc, char **argv)
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
18 {
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
19 TAILQ_INIT(&g_tlvs);
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
20 yyparse();
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
21 return 0;
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
22 }

mercurial