@@ -364,15 +364,6 @@ def p_include_once_ok(p):
364364 CURRENT_DIR = os .path .dirname (output .CURRENT_FILE [- 1 ])
365365
366366
367- def p_include (p ):
368- """include : INCLUDE STRING"""
369- if ENABLED :
370- p [0 ] = include_file (p [2 ], p .lineno (2 ), local_first = True )
371- else :
372- p [0 ] = []
373- p .lexer .next_token = "_ENDFILE_"
374-
375-
376367def p_include_fname (p ):
377368 """include : INCLUDE FILENAME"""
378369 if ENABLED :
@@ -401,7 +392,7 @@ def p_include_macro(p):
401392def p_include_once (p ):
402393 """include_once : INCLUDE ONCE STRING"""
403394 if ENABLED :
404- p [0 ] = include_once (p [3 ], p .lineno (3 ), local_first = True )
395+ p [0 ] = include_once (p [3 ][ 1 : - 1 ] , p .lineno (3 ), local_first = True )
405396 else :
406397 p [0 ] = []
407398
@@ -440,16 +431,19 @@ def p_line_file(p):
440431
441432def p_require_file (p ):
442433 """require : REQUIRE STRING NEWLINE"""
443- p [0 ] = [' #%s "%s" \n ' % (p [1 ], utils .sanitize_filename (p [2 ]))]
434+ p [0 ] = [" #%s %s \n " % (p [1 ], utils .sanitize_filename (p [2 ]))]
444435
445436
446437def p_init (p ):
447- """init : INIT ID NEWLINE
448- | INIT STRING NEWLINE
449- """
438+ """init : INIT ID NEWLINE"""
450439 p [0 ] = ['#%s "%s"\n ' % (p [1 ], p [2 ])]
451440
452441
442+ def p_init_str (p ):
443+ """init : INIT STRING NEWLINE"""
444+ p [0 ] = ["#%s %s\n " % (p [1 ], p [2 ])]
445+
446+
453447def p_undef (p ):
454448 """undef : UNDEF ID"""
455449 if ENABLED :
@@ -459,14 +453,14 @@ def p_undef(p):
459453
460454
461455def p_errormsg (p ):
462- """errormsg : ERROR STRING """
456+ """errormsg : ERROR TEXT """
463457 if ENABLED :
464458 error (p .lineno (1 ), p [2 ])
465459 p [0 ] = []
466460
467461
468462def p_warningmsg (p ):
469- """warningmsg : WARNING STRING """
463+ """warningmsg : WARNING TEXT """
470464 if ENABLED :
471465 warning (p .lineno (1 ), p [2 ])
472466 p [0 ] = []
@@ -535,12 +529,16 @@ def p_pragma_id(p):
535529
536530def p_pragma_id_expr (p ):
537531 """pragma : PRAGMA ID EQ ID
538- | PRAGMA ID EQ STRING
539532 | PRAGMA ID EQ INTEGER
540533 """
541534 p [0 ] = ["#%s %s %s %s" % (p [1 ], p [2 ], p [3 ], p [4 ])]
542535
543536
537+ def p_pragma_id_string (p ):
538+ """pragma : PRAGMA ID EQ STRING"""
539+ p [0 ] = ["#%s %s %s %s" % (p [1 ], p [2 ], p [3 ], p [4 ][1 :- 1 ])]
540+
541+
544542def p_pragma_push (p ):
545543 """pragma : PRAGMA PUSH LP ID RP
546544 | PRAGMA POP LP ID RP
@@ -644,6 +642,16 @@ def p_expr(p):
644642 p [0 ] = str (p [1 ]()).strip ()
645643
646644
645+ def p_expr_val (p ):
646+ """expr : NUMBER"""
647+ p [0 ] = p [1 ]
648+
649+
650+ def p_expr_str (p ):
651+ """expr : STRING"""
652+ p [0 ] = p [1 ]
653+
654+
647655def p_exprne (p ):
648656 """expr : expr NE expr"""
649657 p [0 ] = "1" if p [1 ] != p [3 ] else "0"
@@ -858,7 +866,7 @@ def main(argv):
858866 return global_ .has_errors
859867
860868
861- parser = utils . get_or_create ( "zxbpp" , lambda : yacc .yacc (debug = True ) )
869+ parser = yacc .yacc (debug = True )
862870parser .defaulted_states = {}
863871
864872
0 commit comments