-
Notifications
You must be signed in to change notification settings - Fork 0
/
frame.y
103 lines (85 loc) · 1.81 KB
/
frame.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
%{
void yyerror(const char *s);
char testbuf[256];
%}
%union {
double nr3; /*double float*/
int nr1; /*integer value*/
int cmd; /*command value*/
char *text; /*text string buffer*/
}
// define all tokens for IEEE488.2 mandatory commands.
%token <cmd> IDN CLS RST RCL SAV
// white space accroading to the SCPI standard, just ignore it
%token SPACE "[\0x00-\0x09\0x0b-\0x20\0x1a]+" << skip(); >>
// define tokens for all SCPI commands
// start with the top level
// The actual commands implemented depends on the instrument
%token SENSe "(SENS) | (SENSE)"
%token TRIGger "(TRIG) | (TRIGGER)"
%token INIT "INIT"
// then the sublevel tokens
// typical trigger options
%token LINE "LINE"
%token IMM "(IMM) | (IMMediate)"
%token BUS "BUS"
%token VOLTage "(VOLT) | (VOLTAGE)"
%token DC "DC"
%token COUNt "(COUN) | (COUNT)"
%token SOURce "(SOUR) | (SOURCE)"
// and finally, punctuation
%token LINK ";:"
%token COLON ":"
%token SEMI ";"
%token CTERM "[\n]"
%token EOF "@"
// a number
%NUM
%token
%%
module:
(linked_command CTERM )* EOF
;
linked_command:
command (LINK command )*
;
command:
status_command
| sense_command
| trigger_command
;
status_command:
CLS <<
| RST <<
| INIT <<
;
sense_command:
SOURce COLON sense_sub (SEMI sense_sub)*
;
sense_sub:
VOLT DC <<
;
trigger_command:
TRIGger COLON trigger_sub (SEMI trigger_sub)*
l
trigger_sub:
SOURce
(
LINE <<
|IMM <<
|BUS <<
)
| COUNT num >> [x] <<
;
num > [int n]:
ii:NUM << $n = atoi($ii.getText()); >>
;
%%
void yyerror(const char *s)
{
}
int main()
{
yyparse();
return 0;
}