projects
/
henge
/
apc.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
c2cc9f9
)
added dprintf macro, finally
author
Jordan
<jordanlavatai@gmail.com>
Mon, 16 Jan 2017 22:50:43 +0000
(14:50 -0800)
committer
Jordan
<jordanlavatai@gmail.com>
Mon, 16 Jan 2017 22:50:43 +0000
(14:50 -0800)
src/lexer.rl
patch
|
blob
|
history
diff --git
a/src/lexer.rl
b/src/lexer.rl
index
da397c0
..
7f65276
100644
(file)
--- a/
src/lexer.rl
+++ b/
src/lexer.rl
@@
-28,7
+28,7
@@
uint8_t lval_offs;
PUSHTOK(T,lval_stack + lval_offs); \
lval_offs++; \
ntok++; \
PUSHTOK(T,lval_stack + lval_offs); \
lval_offs++; \
ntok++; \
- } while (0)
;
+ } while (0)
#define PUSHFACE(F) LEXTOK(FACING, face, F)
#define PUSHREF(R) LEXTOK(REF, ref, R)
#define PUSHLINK() LEXTOK(LINK, val, 0)
#define PUSHFACE(F) LEXTOK(FACING, face, F)
#define PUSHREF(R) LEXTOK(REF, ref, R)
#define PUSHLINK() LEXTOK(LINK, val, 0)
@@
-38,6
+38,10
@@
uint8_t lval_offs;
#define PUSHPATH(P) LEXTOK(PATH, str, P)
#define DEBUG 1
#define PUSHPATH(P) LEXTOK(PATH, str, P)
#define DEBUG 1
+#define dprintf(_B, ...) do { \
+ if(_B) printf(__VA_ARGS__); \
+ } while (0)
+
/* Lexstring is the main lexer for APC and is generated by ragel. It lexes file names of files
that have been scanned and pushes their types and values into the tok_stack, which yyparse
/* Lexstring is the main lexer for APC and is generated by ragel. It lexes file names of files
that have been scanned and pushes their types and values into the tok_stack, which yyparse
@@
-64,45
+68,45
@@
uint8_t lval_offs;
}
PUSHNUM(lval.val);
}
}
PUSHNUM(lval.val);
}
- action push_name {
if(DEBUG) printf(
"Lexer_lexstring:: action:push_name: from %s to %s\n", ts, p);
+ action push_name {
dprintf(DEBUG,
"Lexer_lexstring:: action:push_name: from %s to %s\n", ts, p);
PUSHNAME(ts);
}
PUSHNAME(ts);
}
- action push_map {
if(DEBUG) printf(
"Lexer_lexstring:: action:push_map: pushing map token\n");
+ action push_map {
dprintf(DEBUG,
"Lexer_lexstring:: action:push_map: pushing map token\n");
PUSHOP(MAP);
}
PUSHOP(MAP);
}
- action set_ts {
if(DEBUG) printf(
"Lexer_lexstring:: action:set_ts. ts = %s\n", p);
+ action set_ts {
dprintf(DEBUG,
"Lexer_lexstring:: action:set_ts. ts = %s\n", p);
ts = p; }
ts = p; }
- action push_SS {
if(DEBUG) printf(
"Lexer_lexstring:: action:push_SS. p = %s\n",p);
+ action push_SS {
dprintf(DEBUG,
"Lexer_lexstring:: action:push_SS. p = %s\n",p);
PUSHOP(SS);
}
PUSHOP(SS);
}
- action push_S {
if(DEBUG) printf(
"Lexer_lexstring:: action:push_S. p = %s\n", p);
+ action push_S {
dprintf(DEBUG,
"Lexer_lexstring:: action:push_S. p = %s\n", p);
PUSHFACE(SFACE);
}
PUSHFACE(SFACE);
}
- action push_SW {
if(DEBUG) printf(
"Lexer_lexstring:: action:push_SW. p = %s\n", p);
+ action push_SW {
dprintf(DEBUG,
"Lexer_lexstring:: action:push_SW. p = %s\n", p);
PUSHFACE(SWFACE);
}
PUSHFACE(SWFACE);
}
- action push_W {
if(DEBUG) printf(
"Lexer_lexstring:: action:push_W. p = %s\n", p);
+ action push_W {
dprintf(DEBUG,
"Lexer_lexstring:: action:push_W. p = %s\n", p);
PUSHFACE(WFACE);
}
PUSHFACE(WFACE);
}
- action push_NW {
if(DEBUG) printf(
"Lexer_lexstring:: action:push_NW. p = %s\n", p);
+ action push_NW {
dprintf(DEBUG,
"Lexer_lexstring:: action:push_NW. p = %s\n", p);
PUSHFACE(NWFACE);
}
PUSHFACE(NWFACE);
}
- action push_N {
if(DEBUG) printf(
"Lexer_lexstring:: action:push_N. p = %s\n", p);
+ action push_N {
dprintf(DEBUG,
"Lexer_lexstring:: action:push_N. p = %s\n", p);
PUSHFACE(NFACE);
}
PUSHFACE(NFACE);
}
- action push_NE {
if(DEBUG) printf(
"Lexer_lexstring:: action:push_NE. p = %s\n", p);
+ action push_NE {
dprintf(DEBUG,
"Lexer_lexstring:: action:push_NE. p = %s\n", p);
PUSHFACE(NEFACE);
}
PUSHFACE(NEFACE);
}
- action push_E {
if(DEBUG) printf(
"Lexer_lexstring:: action:push_N. p = %s\n", p);
+ action push_E {
dprintf(DEBUG,
"Lexer_lexstring:: action:push_N. p = %s\n", p);
PUSHFACE(EFACE);
}
PUSHFACE(EFACE);
}
- action push_SE {
if(DEBUG) printf(
"Lexer_lexstring:: action:push_N. p = %s\n", p);
+ action push_SE {
dprintf(DEBUG,
"Lexer_lexstring:: action:push_N. p = %s\n", p);
PUSHFACE(SEFACE);
}
PUSHFACE(SEFACE);
}
- action ref_error {
if(DEBUG) printf(
"ref from %s to %s has an inappropriate amount of hex digits, it must have eight.\n", ts, p);
+ action ref_error {
dprintf(DEBUG,
"ref from %s to %s has an inappropriate amount of hex digits, it must have eight.\n", ts, p);
exit(1);
}
exit(1);
}
- action p {
if(DEBUG)
printf("Lexer_lexstring:: p = %s\n", p);
+ action p {
d
printf("Lexer_lexstring:: p = %s\n", p);
}
N = 'N' %push_N;
}
N = 'N' %push_N;
@@
-151,8
+155,7
@@
int lexer_lexstring
( uint8_t* str,
int size
)
( uint8_t* str,
int size
)
-{ uint8_t *p;
- uint8_t *ts, *pe, *eof;
+{ uint8_t* p, * ts, * pe, * eof;
int cs, ntok;
YYSTYPE lval;
int cs, ntok;
YYSTYPE lval;
@@
-160,12
+163,12
@@
int lexer_lexstring
p = ts = str;
pe = eof = p + size + 1;
p = ts = str;
pe = eof = p + size + 1;
-
if(DEBUG) printf("|---Begin lexstring on p = %s, pe = %s.\n",
p, pe);
+
dprintf("|---Begin lexstring on p = %s, pe = %s.\n", (char*)
p, pe);
%%write init;
%%write exec;
%%write init;
%%write exec;
-
if(DEBUG) printf("Ending lexstring of file %s, pushed %d tokens.\n",
str, ntok);
+
dprintf("Ending lexstring of file %s, pushed %d tokens.\n", (char*)
str, ntok);
return ntok;
}
return ntok;
}