Browse Source

Attempt to silence yacc

Reference #65
pull/66/head
Louis 10 years ago
parent
commit
5084a0b418
  1. 15
      patacrep/latex/syntax.py

15
patacrep/latex/syntax.py

@ -224,13 +224,20 @@ class Parser:
else: else:
symbols[0] = symbols[2].prepend(symbols[1]) symbols[0] = symbols[2].prepend(symbols[1])
def silent_yacc(*args, **kwargs):
"""Call yacc, suppressing (as far as possible) output and generated files.
"""
return yacc.yacc(
write_tables=0,
debug=0,
*args,
**kwargs
)
def tex2plain(string): def tex2plain(string):
"""Parse string and return its plain text version.""" """Parse string and return its plain text version."""
return detex( return detex(
yacc.yacc( silent_yacc(
write_tables=0,
debug=0,
module=Parser(), module=Parser(),
).parse( ).parse(
string, string,
@ -241,7 +248,7 @@ def tex2plain(string):
def parsesong(string, filename=None): def parsesong(string, filename=None):
"""Parse song and return its metadata.""" """Parse song and return its metadata."""
return detex( return detex(
yacc.yacc(module=Parser(filename)).parse( silent_yacc(module=Parser(filename)).parse(
string, string,
lexer=SongLexer().lexer, lexer=SongLexer().lexer,
).metadata ).metadata

Loading…
Cancel
Save