10 #define YY_NEVER_INTERACTIVE 1
11 #define YY_DECL int yylex(YYSTYPE* yylval)
13 #define YY_INPUT(buf, result, max_size) \
15 input->read(buf, max_size); \
16 result = input->gcount(); \
19 std::string last_docucomment;
20 std::string original_file;
21 std::string current_file;
27 return yylineno - offset_lnum;
34 /* %option never-interactive */
39 #[ \t]+[0-9]+[ \t]+.* {
42 if(sscanf(yytext, "# %d \"%1023[^\"]\"", &lnum, file) == 2) {
43 offset_lnum = yylineno - lnum + 1;
45 if(original_file == "")
48 std::cerr << "Warning: Parse error in processor info directive.\n";
51 #.* /* ignore preprocessor directives */
52 [[:space:]]+ /* eat spaces */
53 "/*" { BEGIN(comment); comm = ""; }
54 <comment>[^*\n]* { comm += yytext; }
55 <comment>"*"+[^*/]* { comm += yytext; }
58 if(comm[0] == '*') { // It's a docu comment...
59 last_docucomment = "";
60 bool linestart = true;
61 for(size_t i = 1; i < comm.size(); ++i) {
62 if(linestart && (comm[i] == '*' || isspace(comm[i]))) {
64 } else if(comm[i] == '\n') {
69 last_docucomment += comm[i];
74 if(yytext[2] == '/') { // it's a docu comment...
75 last_docucomment = std::string(yytext+3, strlen(yytext)-4);
78 class { return T_CLASS; }
79 struct { return T_STRUCT; }
80 static { return T_STATIC; }
81 virtual { return T_VIRTUAL; }
82 const { return T_CONST; }
83 unsigned { return T_UNSIGNED; }
84 signed { return T_SIGNED; }
85 void { return T_VOID; }
86 bool { return T_BOOL; }
87 char { return T_CHAR; }
88 short { return T_SHORT; }
90 long { return T_LONG; }
91 float { return T_FLOAT; }
92 double { return T_DOUBLE; }
93 public { return T_PUBLIC; }
94 protected { return T_PROTECTED; }
95 private { return T_PRIVATE; }
96 namespace { return T_NAMESPACE; }
97 [a-zA-Z_][a-zA-Z_0-9]* {
98 Namespace* ns = search_namespace;
100 ns = current_namespace;
102 yylval->atomic_type = ns->_findType(yytext, search_down);
103 if(yylval->atomic_type)
104 return T_ATOMIC_TYPE;
105 // or a namespace? (hack for now...)
106 yylval->_namespace = ns->_findNamespace(yytext, search_down);
107 if(yylval->_namespace) {
108 return T_NAMESPACEREF;
111 yylval->str = strdup(yytext);
114 \:\: { return T_DDCOL; }
116 yylval->ival = atoi(yytext);
119 [0-9]*\.[0-9]+(e[0-9]+)? {
120 yylval->fval = atof(yytext);
124 yylval->str = strdup(yytext);
127 . { return yytext[0]; }