Permalink
Browse files

added

  • Loading branch information...
1 parent b803b1a commit 0466274b4ee201336a8ad58cd156c8d3d5fdfabd @zigorou committed Feb 21, 2012
Showing with 26 additions and 22 deletions.
  1. +3 −0 CMakeLists.txt
  2. +2 −3 example6.l
  3. +21 −19 example6.y
View
@@ -1,7 +1,10 @@
cmake_minimum_required (VERSION 2.8)
project (lex_yacc_howto)
+set(CMAKE_CXX_FLAGS_DEBUG "-g")
+set(CMAKE_C_FLAGS_DEBUG "-g")
include_directories(${CMAKE_CURRENT_BINARY_DIR})
+
find_package(BISON)
find_package(FLEX)
View
@@ -4,11 +4,10 @@
%}
%%
-
zone return ZONETOK;
file return FILETOK;
-[a-zA-Z][a-zA-Z0-9]* yylval=strdup(yytext); return WORD;
-[a-zA-Z0-9\/.-]+ yylval=strdup(yytext); return FILENAME;
+[a-zA-Z][a-zA-Z0-9]* yylval.text = strdup(yytext); return WORD;
+[a-zA-Z0-9\/.-]+ yylval.text = strdup(yytext); return FILENAME;
\" return QUOTE;
\{ return OBRACE;
\} return EBRACE;
View
@@ -4,29 +4,15 @@
#define YYSTYPE char *
-int yydebug=0;
-
-void yyerror(const char *str)
-{
- fprintf(stderr,"error: %s\n",str);
-}
-
-int yywrap()
-{
- return 1;
-}
-
-main()
-{
- yyparse();
-}
-
+int yydebug = 1;
%}
+%union{
+ text char[256];
+}
%token WORD FILENAME QUOTE OBRACE EBRACE SEMICOLON ZONETOK FILETOK
%%
-
commands:
|
commands command SEMICOLON
@@ -40,7 +26,7 @@ command:
zone_set:
ZONETOK quotedname zonecontent
{
- printf("Complete zone for '%s' found\n",$2);
+ printf("Complete zone for '%s' found\n", $3);
}
;
@@ -77,3 +63,19 @@ statements:
;
statement: WORD | block | quotedname
+%%
+
+void yyerror(const char *str)
+{
+ fprintf(stderr,"error: %s\n",str);
+}
+
+int yywrap()
+{
+ return 1;
+}
+
+void main(void)
+{
+ yyparse();
+}

0 comments on commit 0466274

Please sign in to comment.