2 /*-------------------------------------------------------------------------
5 * a lexical scanner for an isolation test specification
7 * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 *-------------------------------------------------------------------------
13 static int yyline = 1; /* line number for error reporting */
15 static char litbuf[1024];
16 static int litbufpos = 0;
18 static void addlitchar(char c);
23 %option never-interactive
29 %option prefix="spec_yy"
38 comment ("#"{non_newline}*)
42 permutation { return(PERMUTATION); }
43 session { return(SESSION); }
44 setup { return(SETUP); }
45 step { return(STEP); }
46 teardown { return(TEARDOWN); }
49 {comment} { /* ignore */ }
50 {space} { /* ignore */ }
52 /* Quoted strings: "foo" */
58 litbuf[litbufpos] = '\0';
59 yylval.str = strdup(litbuf);
61 return(string_literal);
63 <qstr>. { addlitchar(yytext[0]); }
64 <qstr>\n { yyerror("unexpected newline in quoted string"); }
65 <qstr><<EOF>> { yyerror("unterminated quoted string"); }
67 /* SQL blocks: { UPDATE ... } */
74 litbuf[litbufpos] = '\0';
75 yylval.str = strdup(litbuf);
80 addlitchar(yytext[0]);
84 addlitchar(yytext[0]);
87 yyerror("unterminated sql block");
91 fprintf(stderr, "syntax error at line %d: unexpected character \"%s\"\n", yyline, yytext);
99 if (litbufpos >= sizeof(litbuf) - 1)
101 fprintf(stderr, "SQL step too long\n");
104 litbuf[litbufpos++] = c;
108 yyerror(const char *message)
110 fprintf(stderr, "%s at line %d\n", message, yyline);