Skip to content

Commit

Permalink
Some more work on the INI parser/scanner
Browse files Browse the repository at this point in the history
  • Loading branch information
zsuraski committed Oct 29, 2000
1 parent f01e3fb commit e04fd64
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 41 deletions.
6 changes: 3 additions & 3 deletions Zend/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ zend_language_parser.c: $(srcdir)/zend_language_parser.y
# INI parser/scanner rules

zend_ini_parser.c: $(srcdir)/zend_ini_parser.y
$(YACC) -p zend_ini -v -d $(srcdir)/zend_ini_parser.y -o zend_ini_parser.c
$(YACC) -p ini -v -d $(srcdir)/zend_ini_parser.y -o zend_ini_parser.c

zend_ini_scanner.c: $(srcdir)/zend_ini_scanner.l
$(LEX) -Pzend_ini -o$@ -i $(srcdir)/zend_ini_scanner.l
$(LEX) -Pini -o$@ -i $(srcdir)/zend_ini_scanner.l

zend_ini_scanner_cc.cc: $(srcdir)/zend_ini_scanner.l
$(LEX) -+ -B -i -S$(srcdir)/flex.skl -Pzend_ini -o$@ $(srcdir)/zend_ini_scanner.l
$(LEX) -+ -B -i -S$(srcdir)/flex.skl -Pini -o$@ $(srcdir)/zend_ini_scanner.l

depend:

Expand Down
130 changes: 114 additions & 16 deletions Zend/ZendTS.dsp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Zend/zend_ini_parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winbase.h>
#include "win32/wfile.h"
//#include "win32/wfile.h"
#endif

#define YYSTYPE zval
Expand Down
42 changes: 24 additions & 18 deletions Zend/zend_ini_scanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,23 @@

#include "zend.h"
#include "zend_ini_parser.h"
#include "zend_ini_scanner.h"

#undef YYSTYPE
#define YYSTYPE zval

#define YY_DECL cfglex(zval *cfglval)

#ifdef ZTS
#define YY_DECL int ZendIniFlexLexer::lex_scan(zval *inilval CLS_DC)
#else
#define YY_DECL int ini_lex_scan(zval *inilval CLS_DC)
#endif

#ifndef ZTS
void init_cfg_scanner()
{
cfglineno=1;
inilineno=1;
}
#endif


%}
Expand Down Expand Up @@ -68,17 +74,17 @@ void init_cfg_scanner()


<INITIAL>[ ]*("true"|"on"|"yes")[ ]* {
cfglval->value.str.val = zend_strndup("1",1);
cfglval->value.str.len = 1;
cfglval->type = IS_STRING;
inilval->value.str.val = zend_strndup("1",1);
inilval->value.str.len = 1;
inilval->type = IS_STRING;
return CFG_TRUE;
}


<INITIAL>[ ]*("false"|"off"|"no"|"none")[ ]* {
cfglval->value.str.val = zend_strndup("",0);
cfglval->value.str.len = 0;
cfglval->type = IS_STRING;
inilval->value.str.val = zend_strndup("",0);
inilval->value.str.len = 0;
inilval->type = IS_STRING;
return CFG_FALSE;
}

Expand All @@ -95,9 +101,9 @@ void init_cfg_scanner()
yytext++;
yyleng--;

cfglval->value.str.val = zend_strndup(yytext,yyleng);
cfglval->value.str.len = yyleng;
cfglval->type = IS_STRING;
inilval->value.str.val = zend_strndup(yytext,yyleng);
inilval->value.str.len = yyleng;
inilval->type = IS_STRING;
return SECTION;
}

Expand All @@ -111,9 +117,9 @@ void init_cfg_scanner()
/* eat leading " */
yytext++;

cfglval->value.str.val = zend_strndup(yytext, yyleng - 2);
cfglval->value.str.len = yyleng - 2;
cfglval->type = IS_STRING;
inilval->value.str.val = zend_strndup(yytext, yyleng - 2);
inilval->value.str.len = yyleng - 2;
inilval->type = IS_STRING;
return TC_ENCAPSULATED_STRING;
}

Expand Down Expand Up @@ -145,9 +151,9 @@ void init_cfg_scanner()
}
}
if (yyleng!=0) {
cfglval->value.str.val = zend_strndup(yytext,yyleng);
cfglval->value.str.len = yyleng;
cfglval->type = IS_STRING;
inilval->value.str.val = zend_strndup(yytext,yyleng);
inilval->value.str.len = yyleng;
inilval->type = IS_STRING;
return TC_STRING;
} else {
/* whitespace */
Expand Down
7 changes: 4 additions & 3 deletions Zend/zend_language_scanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
#else
#define YY_DECL int lex_scan(zval *zendlval CLS_DC)
#endif

#define ECHO { ZEND_WRITE( yytext, yyleng ); }

#ifdef ZTS
Expand All @@ -88,10 +89,10 @@
class istdiostream : public istream
{
private:
stdiobuf _file;
stdiobuf _file;
public:
istdiostream (FILE* __f) : istream(), _file(__f) { init(&_file); }
stdiobuf* rdbuf()/* const */ { return &_file; }
istdiostream (FILE* __f) : istream(), _file(__f) { init(&_file); }
stdiobuf* rdbuf()/* const */ { return &_file; }
};
#endif

Expand Down

0 comments on commit e04fd64

Please sign in to comment.