10 #define YY_DECL int yylex(YYSTYPE* yylval)
12 #define YY_INPUT(buf, result, max_size) \
14 input->read(buf, max_size); \
15 result = input->gcount(); \
18 std::string last_docucomment;
19 std::string original_file;
20 std::string current_file;
26 return yylineno - offset_lnum;
33 /* %option never-interactive */
38 #[ \t]+[0-9]+[ \t]+.* {
41 if(sscanf(yytext, "# %d \"%1023[^\"]\"", &lnum, file) == 2) {
42 offset_lnum = yylineno - lnum + 1;
44 if(original_file == "")
47 std::cerr << "Warning: Parse error in processor info directive.\n";
50 #.* /* ignore preprocessor directives */
51 [[:space:]]+ /* eat spaces */
52 "/*" { BEGIN(comment); comm = ""; }
53 <comment>[^*\n]* { comm += yytext; }
54 <comment>"*"+[^*/]* { comm += yytext; }
57 if(comm[0] == '*') { // It's a docu comment...
58 last_docucomment = "";
59 bool linestart = true;
60 for(size_t i = 1; i < comm.size(); ++i) {
61 if(linestart && (comm[i] == '*' || isspace(comm[i]))) {
63 } else if(comm[i] == '\n') {
68 last_docucomment += comm[i];
73 if(yytext[2] == '/') { // it's a docu comment...
74 last_docucomment = std::string(yytext+3, strlen(yytext)-4);
77 class { return T_CLASS; }
78 struct { return T_STRUCT; }
79 static { return T_STATIC; }
80 virtual { return T_VIRTUAL; }
81 const { return T_CONST; }
82 unsigned { return T_UNSIGNED; }
83 signed { return T_SIGNED; }
84 void { return T_VOID; }
85 bool { return T_BOOL; }
86 char { return T_CHAR; }
87 short { return T_SHORT; }
89 long { return T_LONG; }
90 float { return T_FLOAT; }
91 double { return T_DOUBLE; }
92 public { return T_PUBLIC; }
93 protected { return T_PROTECTED; }
94 private { return T_PRIVATE; }
95 namespace { return T_NAMESPACE; }
96 [a-zA-Z_][a-zA-Z_0-9]* {
97 Namespace* ns = search_namespace;
99 ns = current_namespace;
101 yylval->atomic_type = ns->_findType(yytext, search_down);
102 if(yylval->atomic_type)
103 return T_ATOMIC_TYPE;
104 // or a namespace? (hack for now...)
105 yylval->_namespace = ns->_findNamespace(yytext, search_down);
106 if(yylval->_namespace) {
107 return T_NAMESPACEREF;
110 yylval->str = strdup(yytext);
113 \:\: { return T_DDCOL; }
115 yylval->ival = atoi(yytext);
118 [0-9]*\.[0-9]+(e[0-9]+)? {
119 yylval->fval = atof(yytext);
123 yylval->str = strdup(yytext);
126 . { return yytext[0]; }