Module: sip-router
Branch: master
Commit: 47b81cd070197a3d8780afb4a30e5b704756439a
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=47b81cd…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Sun May 22 15:20:21 2011 +0200
core: defined preprocessor directive start token in lex
- PREP_START defined as '#!' or '!!'
- '!!' can be used as alternative to '#!' for preprocessor directive,
being easier to distinguish it out of commented lines
---
cfg.lex | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/cfg.lex b/cfg.lex
index 5b863ac..28e4fbc 100644
--- a/cfg.lex
+++ b/cfg.lex
@@ -548,6 +548,9 @@ COM_LINE #
COM_START "/\*"
COM_END "\*/"
+/* start of pre-processing directives */
+PREP_START "#!"|"!!"
+
DEFINE "define"|"def"
IFDEF ifdef
IFNDEF ifndef
@@ -1207,7 +1210,7 @@ SUBST subst
<INITIAL>{COM_LINE}!{MAXCOMPAT_CFG}{CR} { count();
sr_cfg_compat=SR_COMPAT_MAX;}
-<INITIAL>{COM_LINE}!{DEFINE}{EAT_ABLE}+ { count();
+<INITIAL>{PREP_START}{DEFINE}{EAT_ABLE}+ { count();
state = DEFINE_S; BEGIN(DEFINE_ID); }
<DEFINE_ID>{ID} { count();
if (pp_define(yyleng, yytext)) return 1;
@@ -1226,12 +1229,12 @@ SUBST subst
<DEFINE_DATA>. { count();
addstr(&s_buf, yytext, yyleng); }
-<INITIAL>{COM_LINE}!{SUBST} { count(); return SUBST;}
+<INITIAL>{PREP_START}{SUBST} { count(); return SUBST;}
-<INITIAL,IFDEF_SKIP>{COM_LINE}!{IFDEF}{EAT_ABLE}+ { count();
+<INITIAL,IFDEF_SKIP>{PREP_START}{IFDEF}{EAT_ABLE}+ { count();
if (pp_ifdef_type(1)) return 1;
state = IFDEF_S; BEGIN(IFDEF_ID); }
-<INITIAL,IFDEF_SKIP>{COM_LINE}!{IFNDEF}{EAT_ABLE}+ { count();
+<INITIAL,IFDEF_SKIP>{PREP_START}{IFNDEF}{EAT_ABLE}+ { count();
if (pp_ifdef_type(0)) return 1;
state = IFDEF_S; BEGIN(IFDEF_ID); }
<IFDEF_ID>{ID} { count();
@@ -1239,9 +1242,9 @@ SUBST subst
state = IFDEF_EOL_S; BEGIN(IFDEF_EOL); }
<IFDEF_EOL>{EAT_ABLE}*{CR} { count(); pp_ifdef(); }
-<INITIAL,IFDEF_SKIP>{COM_LINE}!{ELSE}{EAT_ABLE}*{CR} { count(); pp_else(); }
+<INITIAL,IFDEF_SKIP>{PREP_START}{ELSE}{EAT_ABLE}*{CR} { count(); pp_else(); }
-<INITIAL,IFDEF_SKIP>{COM_LINE}!{ENDIF}{EAT_ABLE}*{CR} { count();
+<INITIAL,IFDEF_SKIP>{PREP_START}{ENDIF}{EAT_ABLE}*{CR} { count();
pp_endif(); }
/* we're in an ifdef that evaluated to false -- throw it away */