gerando o codigo e tratando visibilidade dos métodos
[CppToLua.git] / cpptolua.l
bloba49a233193d44c9856c0a993df052d357a23f2e1
1 %{
2 #include "y.tab.h"
3 #include "node.h"
4 #include <stdlib.h>
5 #include <assert.h>
6         void yyerror(char *);
7         int idf(char *s);
8 //#define DEBUG
9 %}
13 "class" { printf("class\n"); return CLASS; }
14 [{};(),:] {
15         yylval.s = strdup(yytext);
16 #ifdef DEBUG
17         printf(": %c\n", *yytext);
18 #endif
19         return *yytext;
23         /* identifiers */
24 [a-zA-Z_0-9~>&=]+ {
25 #ifdef DEBUG
26         printf(": %s\n", yytext);
27         //printf("idf: %i\n", idf(yytext));
28 #endif
29         return idf(yytext);
32         /* skip whitespace */
33 [ \t\n]+ ;
35         /* skip comments */
36 \/\/.* ;
37 \/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/ ;
38 ^#.*$ ;
39 ^using.*$ ;
41         /* anything else is an error */
42 . {
43         printf(": '%c'\n", *yytext);
44         yyerror((char *)"invalid character");
49 int yywrap(void) {
50         return 1;
53 int idf(char *s)
55         //printf("passou por aqui: %s\n", s);
56         yylval.sv = new StringVec;
57         yylval.sv->vs.push_back(string(yytext));
58         //yylval.n = new Node;
59         //yylval.n->s = string(yytext);
61         char types[][99] = {"public", "private", "protected", ""};
62         int i;
63         for(i = 0; types[i][0]; i++) {
64                 if(!strcmp(types[i], s)) {
65                         if(i == 0) { //public index on types vector
66                                 member_scope_public = true;
67                         } else {
68                                 member_scope_public = false;
69                         }
70                         return VISIBILITY;
71                 }
72         }
73         return IDF;