Permalink
Browse files

added

  • Loading branch information...
1 parent 884ef7f commit b803b1a4f3f9c84f442102e1089188574f07b2e3 @zigorou committed Feb 18, 2012
Showing with 61 additions and 58 deletions.
  1. +6 −6 example6.l
  2. +55 −52 example6.y
View
@@ -1,18 +1,18 @@
%{
#include <stdio.h>
-#include <string.h>
#include "example6.tab.h"
%}
%%
-zone return ZONETOK;
-file return FILETOK;
+
+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;
\" return QUOTE;
\{ return OBRACE;
\} return EBRACE;
; return SEMICOLON;
-\n /* ignore linebreak */
-[ \t]+ /* ignore whitespaces */;
-%%
+\n /* ignore EOL */;
+[ \t]+ /* ignore whitespace */;
+%%
View
@@ -1,76 +1,79 @@
%{
#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
#define YYSTYPE char *
+
+int yydebug=0;
+
+void yyerror(const char *str)
+{
+ fprintf(stderr,"error: %s\n",str);
+}
+
+int yywrap()
+{
+ return 1;
+}
+
+main()
+{
+ yyparse();
+}
+
%}
-%token ZONETOK FILETOK WORD FILENAME QUOTE OBRACE EBRACE SEMICOLON
+%token WORD FILENAME QUOTE OBRACE EBRACE SEMICOLON ZONETOK FILETOK
%%
-commands: /* empty */
- | commands command SEMICOLON
- ;
+
+commands:
+ |
+ commands command SEMICOLON
+ ;
+
command:
- zone_set
- ;
+ zone_set
+ ;
zone_set:
- ZONETOK quotedname zonecontent
- {
- printf("Complete zone for '%s' found\n", $2);
- }
- ;
+ ZONETOK quotedname zonecontent
+ {
+ printf("Complete zone for '%s' found\n",$2);
+ }
+ ;
zonecontent:
- OBRACE zonestatements EBRACE
- ;
+ OBRACE zonestatements EBRACE
quotedname:
- QUOTE FILENAME QUOTE
- {
- $$=$2;
- }
- ;
+ QUOTE FILENAME QUOTE
+ {
+ $$=$2;
+ }
+ ;
-zonestatements: /* empty */
- |
- zonestatements zonestatement SEMICOLON
- ;
+zonestatements:
+ |
+ zonestatements zonestatement SEMICOLON
+ ;
zonestatement:
- statements
- |
- FILETOK quotedname
- {
- printf("A zonefile name '%s' was encountered\n", $2);
- }
- ;
+ statements
+ |
+ FILETOK quotedname
+ {
+ printf("A zonefile name '%s' was encountered\n", $2);
+ }
+ ;
block:
- OBRACE zonestatements EBRACE SEMICOLON
- ;
+ OBRACE zonestatements EBRACE SEMICOLON
+ ;
-statements: /* empty */
- | statements statement
- ;
-
-statement:
- WORD | block | quotedname
- ;
-%%
+statements:
+ | statements statement
+ ;
-void yyerror(const char *str) {
- fprintf(stderr,"error: %s\n",str);
-}
-
-int yywrap() {
- return 1;
-}
-
-int main(void) {
- yyparse();
- exit(0);
-}
+statement: WORD | block | quotedname

0 comments on commit b803b1a

Please sign in to comment.