first commit - working example - needs pointer type recognition (actualy more than...
[CppToLua.git] / cpptolua.y
blobbdd451c4447c97f8e803c24642d8a003d2dca509
1 %{
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <stdarg.h>
7 int yylex(void);
8 void yyerror(char *);
12 /* yyval type */
13 %union {
14 char *name;
17 %token <name> IDF TYPE
18 %token CLASS
19 %type <name> types
23 program:
24 CLASS IDF '{' functions '}' ';' { printf("ClassName: %s\n",$2); }
27 functions:
28 functions types IDF '(' parameters ')' ';' { printf("MethodName: %s\n", $3); }
29 | /* empty */
32 types:
33 TYPE types
34 | /* empty */ { $$ = "NoType"; }
37 parameters:
38 parameter
39 | parameter ',' parameters
40 | /* empty */ { printf("NoParameter\n"); }
43 parameter:
44 types IDF { printf("ParameterType: %s\nParameterName: %s\n", $1, $2); }
49 int main(int argc, char **argv)
51 yyparse();
52 return 0;
55 void yyerror(char *s) {
56 fprintf(stdout, "%s\n", s);