mei_rt2mei_rt2_fix_1meiyap-rt1meiyap1rt2
yap_rt0
Last change
on this file since 53e540d was
e08bf83,
checked in by Mei <mei@…>, 13 years ago
|
1) update to use appendL in clauses
|
-
Property mode set to
100644
|
File size:
1.7 KB
|
Rev | Line | |
---|
[e95d652] | 1 | %{ |
---|
| 2 | #include <stdio.h> |
---|
| 3 | #include <string.h> |
---|
| 4 | #include "ort0.h" |
---|
| 5 | |
---|
| 6 | int debug=0; |
---|
| 7 | |
---|
| 8 | /* with yacc */ |
---|
| 9 | extern YYSTYPE yylval; |
---|
| 10 | /* with just lex */ |
---|
| 11 | /* YYSTYPE yylval; */ |
---|
| 12 | |
---|
| 13 | /* if using canned fixed test string */ |
---|
| 14 | char INPUT_LINE[] = "usc.playground <- usc.employee.friend"; |
---|
| 15 | char *yyfptr = INPUT_LINE; /* default */ |
---|
| 16 | |
---|
| 17 | #undef YY_INPUT |
---|
| 18 | #define YY_INPUT(buf,result,max_size) \ |
---|
| 19 | { \ |
---|
| 20 | if(yyfptr != NULL) { \ |
---|
| 21 | char* c = strncpy(buf,yyfptr,max_size); \ |
---|
| 22 | if (max_size > 0) buf[max_size-1] = '\0'; \ |
---|
| 23 | if(strlen(yyfptr) > max_size) yyfptr = yyfptr + max_size-1; \ |
---|
| 24 | else yyfptr=NULL; \ |
---|
| 25 | result = (c == NULL ) ? YY_NULL : strlen(buf); \ |
---|
| 26 | } else { \ |
---|
| 27 | buf[0] = '\0'; \ |
---|
| 28 | result = YY_NULL; \ |
---|
| 29 | } \ |
---|
| 30 | } |
---|
| 31 | |
---|
| 32 | void abac_reset_yyfptr(char *str) { |
---|
| 33 | yyfptr=str; |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | char* abac_get_yyfptr() { |
---|
| 37 | return yyfptr; |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | /* if using external file input, output */ |
---|
| 41 | void abac_reset_yyin(FILE *new_yyin) { |
---|
| 42 | yyin=new_yyin; |
---|
| 43 | } |
---|
| 44 | void abac_reset_yyout(FILE *new_yyout) { |
---|
| 45 | yyout=new_yyout; |
---|
| 46 | } |
---|
| 47 | FILE *abac_get_yyin() { |
---|
| 48 | if(yyin) return yyin; |
---|
| 49 | else return stdin; |
---|
| 50 | } |
---|
| 51 | FILE *abac_get_yyout() { |
---|
| 52 | if(yyout) return yyout; |
---|
| 53 | else return stdout; |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | %} |
---|
| 57 | %% |
---|
| 58 | [a-zA-Z0-9][_a-zA-Z0-9]* { yylval.string=strdup(yytext); |
---|
| 59 | if(debug) fprintf(yyout,"IDEN "); |
---|
| 60 | return IDEN; } |
---|
| 61 | \<- { if(debug) fprintf(yyout,"DERIVE "); |
---|
| 62 | return DERIVE; } |
---|
| 63 | \. { if(debug) fprintf(yyout, "DOT " ); |
---|
| 64 | return DOT; } |
---|
[e08bf83] | 65 | & { if(debug) fprintf(yyout, "AND " ); |
---|
| 66 | return AND; } |
---|
[e95d652] | 67 | \n { /* ignore end-of-line */; } |
---|
| 68 | [ \t]+ { /* ignore whitespace */; } |
---|
| 69 | %% |
---|
| 70 | |
---|
Note: See
TracBrowser
for help on using the repository browser.