-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathparser.y
75 lines (60 loc) · 826 Bytes
/
parser.y
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
%{
#include <stdio.h>
#include <string.h>
#include "rpc_cli.h"
#define printPrompt()
static int EN = 0;
void yyerror(char *s)
{
printf("%s\n", s);
}
%}
%union
{
int ival;
char *sptr;
}
%token ZZH EXIT EOS DEBUG
%token <ival> _INT_
%token <sptr> _NAME_
%%
input:
| input line
{
printPrompt();
}
;
line:
EOS
{
clear_name_table();
}
| command
| error EOS
{
clear_name_table();
yyerrok;
}
;
command:
testcmds
| EXIT EOS
{
YYACCEPT;
}
;
testcmds:
ZZH EOS
{
EN = cli_action();
}
| ZZH _INT_ EOS
{
EN = cli_action_1($2);
}
%%
void start_cli(char *cmd, FILE *fp)
{
hy_switch_to_file(stdin);
yyparse();
}