File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -240,12 +240,12 @@ def p_module(p):
240240 p [0 ] = ScadModule (p [2 ], params )
241241
242242def p_error (p ):
243- print (f'{ p .lineno } :{ p .lexpos } { p .type } - { p .value } ' )
244- print ("syntex error" )
243+ print (f'py_scadparser: Syntax error: { p .lexer .filename } ({ p .lineno } ) { p .type } - { p .value } ' )
245244
246245def parseFile (scadFile ):
247246
248247 lexer = lex .lex ()
248+ lexer .filename = scadFile
249249 parser = yacc .yacc ()
250250
251251 uses = []
Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ def t_NUMBER(t):
8484 return t
8585
8686def t_error (t ):
87- print (f'Illegal character ({ t .lexer .lineno } ) "{ t .value [0 ]} "' )
87+ print (f'py_scadparser: Illegal character: { t . lexer . filename } ({ t .lexer .lineno } ) "{ t .value [0 ]} "' )
8888 t .lexer .skip (1 )
8989
9090if __name__ == "__main__" :
@@ -97,9 +97,10 @@ def t_error(t):
9797
9898 p = Path (sys .argv [1 ])
9999 f = p .open ()
100- lex .lex ()
101- lex .input ('' .join (f .readlines ()))
102- for tok in iter (lex .token , None ):
100+ lexer = lex .lex ()
101+ lexer .filename = p .as_posix ()
102+ lexer .input ('' .join (f .readlines ()))
103+ for tok in iter (lexer .token , None ):
103104 if tok .type == "MODULE" :
104105 print ("" )
105106 print (repr (tok .type ), repr (tok .value ), end = '' )
You can’t perform that action at this time.
0 commit comments