1 // vim: set ft=cpp noet ts=4 sw=4 :
3 // make sure we have the header imports that bison's horrible .h file needs
7 #include "catalogue.tab.hpp"
13 const char *Catalogue::catalogue_parse_p = NULL;
14 int Catalogue::yylineno = -1;
16 void Catalogue::yyinit(const char *buf) {
17 catalogue_parse_p = buf;
21 int Catalogue::catalex() {
24 assert(catalogue_parse_p);
26 basep = catalogue_parse_p;
29 re2c:define:YYCTYPE = "unsigned char";
30 re2c:define:YYCURSOR = catalogue_parse_p;
31 re2c:yyfill:enable = 0;
32 re2c:yych:conversion = 1;
37 comment = [#*][^\r\n\000]*;
38 whitespace = ( comment | [ \t\r] ) *;
42 override = "OVERRIDE";
48 whitespace { goto start; }
49 newline { yylineno++; goto start; }
50 tag { return CTOK_TAG; }
51 array { return CTOK_ARRAY; }
52 override { return CTOK_OVERRIDE; }
53 number { catalval.number = atoi(basep); return CTOK_INT; }
55 any { catalogueParseError(); }
59 std::ostringstream temp;
61 basep = catalogue_parse_p;
64 backslash any { temp << catalogue_descape(basep[1]); goto strloop; }
65 quote { catalval.string = new std::string(temp.str()); return CTOK_STR; }
66 backslash ? eoi { catalogueParseError("premature end of input"); }
67 newline { temp << basep[0]; yylineno++; goto strloop; }
68 any { temp << basep[0]; goto strloop; }
73 catalogue_parse_p = NULL;