File tree 2 files changed +7
-6
lines changed
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):
240
240
p [0 ] = ScadModule (p [2 ], params )
241
241
242
242
def 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 } ' )
245
244
246
245
def parseFile (scadFile ):
247
246
248
247
lexer = lex .lex ()
248
+ lexer .filename = scadFile
249
249
parser = yacc .yacc ()
250
250
251
251
uses = []
Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ def t_NUMBER(t):
84
84
return t
85
85
86
86
def 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 ]} "' )
88
88
t .lexer .skip (1 )
89
89
90
90
if __name__ == "__main__" :
@@ -97,9 +97,10 @@ def t_error(t):
97
97
98
98
p = Path (sys .argv [1 ])
99
99
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 ):
103
104
if tok .type == "MODULE" :
104
105
print ("" )
105
106
print (repr (tok .type ), repr (tok .value ), end = '' )
You can’t perform that action at this time.
0 commit comments