• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqtwindows誰得cocoapythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

Demonstration of groff .psbb request handling code, for EPS and PDF input files


Commit MetaInfo

修订版83e2f88ecc190e4d8e57701fa9af747ea9bc4bc1 (tree)
时间2017-10-11 20:11:24
作者Keith Marshall <keith@user...>
CommiterKeith Marshall

Log Message

Add more comprehensive DEBUGGING mode lexer trace logging.

* psbblex.l (RETURN_VALUE): New macro, expanded in terms of...
(DEBUG_RETURN_VALUE) [DEBUGGING]: ...this, replacing RETURN(VALUE), to
include the associated yylval result in the token return log message.
(DEBUG_PUSH_STATE) [DEBUGGING]: New macro; it logs the change of lexer
state, when used to wrap calls to yy_push_state().

更改概述

差异

--- a/psbblex.l
+++ b/psbblex.l
@@ -38,11 +38,25 @@
3838
3939 # define DEBUG_MSG(ARGLIST) do { debug_msg ARGLIST; } while(0)
4040
41+# define DEBUG_PUSH_STATE(NAME) \
42+ do { debug_msg("%d: switching to temporary state %s (%d)\n", \
43+ YYSTATE, #NAME, NAME \
44+ ); \
45+ yy_push_state( NAME ); \
46+ } while(0)
47+
4148 # define DEBUG_RETURN(TOKEN, NAME) \
42- do { debug_msg("%d: return token %s (%d)\n", YYSTATE, NAME, TOKEN); \
49+ do { debug_msg("%d: return token %s (%d)\n", YYSTATE, NAME, TOKEN); \
4350 return TOKEN; \
4451 } while(0)
4552
53+# define DEBUG_RETURN_VALUE \
54+ do { debug_msg("%d: return token VALUE (%d); value = %d\n", \
55+ YYSTATE, VALUE, yylval \
56+ ); \
57+ return VALUE; \
58+ } while(0)
59+
4660 static void debug_msg (const char *fmt, ...)
4761 { va_list av; va_start(av, fmt); vfprintf(stderr, fmt, av); va_end(av); }
4862
@@ -50,10 +64,13 @@ static void debug_msg (const char *fmt, ...)
5064 # define DEBUG(FOO)
5165 # define DEBUG_ECHO
5266 # define DEBUG_MSG(ARGLIST)
67+# define DEBUG_PUSH_STATE(NAME) yy_push_state( NAME )
5368 # define DEBUG_RETURN(TOKEN, NAME) return TOKEN
69+# define DEBUG_RETURN_VALUE return VALUE
5470 #endif
5571
5672 #define RETURN(TOKEN) DEBUG_RETURN(TOKEN, #TOKEN)
73+#define RETURN_VALUE DEBUG_RETURN_VALUE
5774
5875 static int ref[2] = { 0, 0 };
5976 static size_t xrefbase, xrefptr;
@@ -209,8 +226,8 @@ static int pdf_trailer( void )
209226 */
210227 <PSBB>{
211228 [ \t]+
212-{INTVAL}/{SEP} { yylval = atol( yytext ); RETURN(VALUE); }
213-{FLOATVAL}/{SEP} { yylval = lround( atof( yytext )); RETURN(VALUE); }
229+{INTVAL}/{SEP} { yylval = atol( yytext ); RETURN_VALUE; }
230+{FLOATVAL}/{SEP} { yylval = lround( atof( yytext )); RETURN_VALUE; }
214231 "(atend)" { if( psbb_phase == PSBB_IN_HEADER )
215232 {
216233 /* In header comments, `%%BoundingBox: (atend)'
@@ -316,11 +333,13 @@ static int pdf_trailer( void )
316333 "/Prev"/{PDFSEP} { if( yy_top_state() == PDFXREFCONT ) BEGIN PDFXREFWALK;
317334 else yy_push_state( PDFIGNORE );
318335 }
319-"/Type"/{PDFSEP} { yy_push_state( PDFOBJTYPE ); }
320-"/Pages"/{PDFSEP} { yy_push_state( PDFREFER ); }
321-"/Kids"/{PDFSEP} { yy_push_state( PDFALLKIDS ); }
322-"/MediaBox"/{PDFSEP} { yy_push_state( PDFMEDIABOX ); }
323-"/"{PDFNAME}/{PDFSEP} { yy_push_state( PDFIGNORE ); }
336+"/Type"/{PDFSEP} { DEBUG_PUSH_STATE( PDFOBJTYPE ); }
337+"/Pages"/{PDFSEP} { DEBUG_PUSH_STATE( PDFREFER ); }
338+"/Kids"/{PDFSEP} { DEBUG_PUSH_STATE( PDFALLKIDS ); }
339+"/MediaBox"/{PDFSEP} { DEBUG_PUSH_STATE( PDFMEDIABOX ); }
340+"/"{PDFNAME}/{PDFSEP} { DEBUG_MSG(("%d: skipping entry with key '%s'\n", YYSTATE, yytext));
341+ DEBUG_PUSH_STATE( PDFIGNORE );
342+ }
324343 ">>" { yy_pop_state(); }
325344 .|\n
326345 }
@@ -371,7 +390,7 @@ static int pdf_trailer( void )
371390 */
372391 <PDFREFER>{
373392 "R"/{PDFSEP} { yy_pop_state(); RETURN('R'); }
374-{INTVAL}/{PDFSEP} { yylval = atol( yytext ); RETURN(VALUE); }
393+{INTVAL}/{PDFSEP} { yylval = atol( yytext ); RETURN_VALUE; }
375394 ./({EOL}|"/") { yy_pop_state(); }
376395 [ \t\r\n]+
377396 }
@@ -396,8 +415,8 @@ static int pdf_trailer( void )
396415 * so we must be prepared to interpret either.
397416 */
398417 <PDFMEDIABOXEVAL>{
399-{FLOATVAL}/{PDFSEP} { yylval = lround( atof( yytext )); RETURN(VALUE); }
400-{INTVAL}/{PDFSEP} { yylval = atol( yytext ); RETURN(VALUE); }
418+{FLOATVAL}/{PDFSEP} { yylval = lround( atof( yytext )); RETURN_VALUE; }
419+{INTVAL}/{PDFSEP} { yylval = atol( yytext ); RETURN_VALUE; }
401420 "]" { yy_pop_state(); }
402421 {SEP}+
403422 }
@@ -409,7 +428,7 @@ static int pdf_trailer( void )
409428 * revert to the state whence this condition was invoked.
410429 */
411430 <PDFEVAL>{
412-{INTVAL}/{PDFSEP} { yylval = atol( yytext ); yy_pop_state(); RETURN(VALUE); }
431+{INTVAL}/{PDFSEP} { yylval = atol( yytext ); yy_pop_state(); RETURN_VALUE; }
413432 [ \t\r\n]+
414433 }
415434
@@ -450,7 +469,7 @@ static int pdf_trailer( void )
450469 */
451470 <PDFGETREF>{
452471 {INTVAL}/{SEP} { xrefptr += yyleng; yylval = atol( yytext ); }
453-{SEP}+ { xrefptr += yyleng; RETURN(VALUE); }
472+{SEP}+ { xrefptr += yyleng; RETURN_VALUE; }
454473 }
455474
456475 /* State: PDFXREFCONT
@@ -521,7 +540,7 @@ static int pdf_trailer( void )
521540 */
522541 <PDFGETOBJECT>{
523542 "obj"/{PDFSEP} { BEGIN PDFSCANOBJECT; RETURN(PDFOBJECT); }
524-{INTVAL}/{SEP} { yylval = atol( yytext ); RETURN(VALUE); }
543+{INTVAL}/{SEP} { yylval = atol( yytext ); RETURN_VALUE; }
525544 {SEP}+
526545 }
527546