%{
#include <math.h>
#include <stdlib.h>
+#include <string.h>
+#include <iostream>
#include "tree.h"
#include "parser.hpp"
#include "globals.h"
-#define YY_DECL int yylex YY_PROTO(( YYSTYPE* yylval ))
+#define YY_DECL int yylex(YYSTYPE* yylval)
#define YY_INPUT(buf, result, max_size) \
{ \
input->read(buf, max_size); \
result = input->gcount(); \
}
+
+std::string last_docucomment;
+std::string original_file;
+std::string current_file;
+int offset_lnum;
+
+int getCurrentLine()
+{
+ return yylineno - offset_lnum;
+}
%}
%%
+#[ \t]+[0-9]+[ \t]+.* {
+ int lnum;
+ char file[1024];
+ if(sscanf(yytext, "# %d \"%1023[^\"]\"", &lnum, file) == 2) {
+ offset_lnum = yylineno - lnum + 1;
+ current_file = file;
+ if(original_file == "")
+ original_file = file;
+ } else {
+ std::cerr << "Warning: Parse error in processor info directive.\n";
+ }
+}
#.* /* ignore preprocessor directives */
[[:space:]]+ /* eat spaces */
-\/\*.*\*\/ /* eat comment */
-\/\/[^\n]*\n /* eat comment */
+\/\*.*\*\/ {
+ if(yytext[2] == '*' && yytext[3] != '/') { // It's a docu comment...
+ last_docucomment = std::string(yytext+3, strlen(yytext)-5);
+ }
+}
+\/\/[^\n]*\n {
+ if(yytext[2] == '/') { // it's a docu comment...
+ last_docucomment = std::string(yytext+3, strlen(yytext)-4);
+ }
+}
class { return T_CLASS; }
struct { return T_STRUCT; }
static { return T_STATIC; }
+virtual { return T_VIRTUAL; }
const { return T_CONST; }
unsigned { return T_UNSIGNED; }
signed { return T_SIGNED; }
if(ns == 0)
ns = current_namespace;
// is it a type?
- for(std::vector<AtomicType*>::iterator i = ns->types.begin();
- i != ns->types.end(); ++i) {
- AtomicType* type = *i;
- if(type->name == yytext) {
- yylval->atomic_type = type;
- return T_ATOMIC_TYPE;
- }
- }
+ yylval->atomic_type = ns->_findType(yytext, search_down);
+ if(yylval->atomic_type)
+ return T_ATOMIC_TYPE;
// or a namespace? (hack for now...)
yylval->_namespace = ns->_findNamespace(yytext, search_down);
if(yylval->_namespace) {