-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathicd.y
72 lines (54 loc) · 1.28 KB
/
icd.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
%{
#include "iclexer.h"
#include "icparser.h"
#include "block.h"
//#include <QtDebug>
#include <QString>
#include <string>
#include <cstdio>
int yylex();
QString type;
BlockData blockdata;
%}
%error-verbose
%token TYPE VALUE FUNC INT
%%
start : prop prop prop prop spec
;
prop : type ':' value
;
type : TYPE {type = getTokenString();}
;
value : VALUE
{
if (type.compare("%name", Qt::CaseInsensitive) == 0)
icNameList->append(getTokenString());
else if (type.compare("%pins", Qt::CaseInsensitive) == 0)
icPinsList->append(getTokenString());
else if (type.compare("%desc", Qt::CaseInsensitive) == 0)
icDescList->append(getTokenString());
else if (type.compare("%label", Qt::CaseInsensitive) == 0)
icLabelList->append(getTokenString());
}
;
spec : '{' expr_list '}'
;
expr_list : expr_list expr | expr
;
expr : out func in {ICData.push_back(blockdata);blockdata.reset();}
;
out : INT {blockdata.outPin.push_back(atoi(getTokenString()));}
;
func : '=' FUNC {blockdata.id = Block::mapBlockID(getTokenString());}
;
in : '(' args ')'
| '(' ')'
;
args : args ',' arg | arg
;
arg : INT {blockdata.inPin.push_back(atoi(getTokenString()));}
%%
int yylex()
{
return nextToken();
}