-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathpatch-leg-output.sed
37 lines (32 loc) · 1.43 KB
/
patch-leg-output.sed
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
# Location tracking
# YY_LOCAL(void) yyDo(yycontext *yy, yyaction action, int begin, int end, int location[4])
# +++++++++++++++++
/^YY_LOCAL/ {
s/\(yyDo\|yyPush\|yyPop\|yySet\)(\(.\+\))/\1(\2, int location[4])/
t
}
# YY_ACTION(void) yy...(yycontext *yy, char *yytext, int yyleng, int location[4])
# +++++++++++++++++
/^YY_ACTION/ {
s/\(yy.*\)(\(.\+\))/\1(\2, int location[4])/
t
}
# typedef void (*yyaction)(yycontext *yy, char *yytext, int yyleng, int location[4]);
# +++++++++++++++++
/^typedef.*yyaction/ {
s/);/, int location[4]);/
t
}
# typedef struct _yythunk { int begin, end; yyaction action; struct _yythunk *next; int location[4]; } yythunk;
# +++++++++++++++++
/^typedef.*_yythunk/ {
s/}/int location[4]; }/
t
}
s/yyDo(\(yy, yy_[^)]\+\))/{ int loc[4]; position_to_line_col(yy, yypos0, loc); position_to_line_col(yy, yy->__pos, \&loc[2]); yyDo%%(\1, loc); };/g;
# Non actions do not need location to be set anyway
s/yyDo(\([^)]\+\))/yyDo(\1, (int []){0, 0, 0 ,0})/g
s/yyDo%%/yyDo/g
# thunk->action(yy, yy->__text, yyleng, thunk->location);
# +++++++++++++++++
s/thunk->action(\([^)]\+\))/thunk->action(\1, thunk->location)/