Skip to content

Commit

Permalink
interface for binding numbers as well as yytext
Browse files Browse the repository at this point in the history
  • Loading branch information
WardCunningham committed Jul 18, 2011
1 parent 95899e1 commit 27cb098
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ void done();

struct { int begin, end; } bindings[100];
void bind(int b);
void bind_num(int b, int n);
void bind_end(int b);

void write_selected(char *buf, int len);
Expand Down Expand Up @@ -42,6 +43,10 @@ void bind(int b) {
bindings[b].begin = yythisthunk->mybegin;
bindings[b].end = yythisthunk->myend;
}
void bind_num(int b, int n) {
bindings[b].begin = -2;
bindings[b].end = n;
}
void bind_end(int b) {
bindings[b].end = yythisthunk->myend;
}
Expand All @@ -62,6 +67,8 @@ void write_binding() {
for (int i=0; i<=max; i++) {
if (bindings[i].begin == -1) {
fprintf(binding_file, "\t");
} else if (bindings[i].begin == -2) {
fprintf(binding_file, "%d%s", bindings[i].end, i!=max ? "\t" : "\n");
} else {
yyText(bindings[i].begin, bindings[i].end); fprintf(binding_file, "%s%s", yytext, i!=max ? "\t" : "\n");
}
Expand Down

0 comments on commit 27cb098

Please sign in to comment.