def __init__(self, verbose=False): '''构造函数 :param verbose: 是否有log提示 :type verbose: boolean ''' if verbose: self._logger = None else: self._logger = yacc.PlyLogger(self._NullStream())
def __init__(self): self.tokens = [ t_name[2:] for t_name in dir(self) if len(t_name) > 2 and t_name[:2] == 't_' ] self.tokens.remove('error') self.tokens.remove('ignore') self.lexer = lex.lex(module=self) # (Change logger output stream if debugging) self.parser = yacc.yacc(module=self, write_tables=False, \ errorlog=yacc.PlyLogger(sys.stderr)) #open(os.devnull, 'w')))
def __init__(self): self.lexer = SpecifyLexer() self.specparams = {} self.constraintchecks = [] self.pathdelays = [] self.ifstatements = defaultdict(list) self.logger = yacc.PlyLogger(sys.stdout) self.parser = yacc.yacc(module=self, debug=False, optimize=1, write_tables=False)
def __init__(self, log=yacc.PlyLogger(sys.stderr)): self.log = log self.tokens = scanner.tokens # Precedence among scalar expression operators in ascending order; this # is necessary to disambiguate the grammar. Operator precedence is # identical to Python: # http://docs.python.org/2/reference/expressions.html#comparisons self.precedence = ( ('left', 'OR'), ('left', 'AND'), ('right', 'NOT'), ('left', 'EQ', 'EQUALS', 'NE', 'GT', 'LT', 'LE', 'GE', 'LIKE'), ('left', 'PLUS', 'MINUS'), ('left', 'TIMES', 'DIVIDE', 'IDIVIDE', 'MOD'), ('right', 'UMINUS'), # Unary minus )
Usage: lxs_to_lbm2 <input file> <output file> [debug] <input file> should be a well-formed LXM or LXS file, containing only MakeNamedVolume, MakeNamedMaterial or Texture blocks <output file> is the name of the .lbm2 file to write [debug] enables debugging output """) sys.exit() dbg = len(sys.argv) > 3 and sys.argv[3] == 'debug' try: lex.lex(debug=dbg) yacc.yacc(debug=dbg, write_tables=0, errorlog=yacc.NullLogger() if not dbg else yacc.PlyLogger(sys.stdout)) lxm = '' with open(sys.argv[1], 'r') as infile: lxm = infile.read() objs = yacc.parse(lxm) lbm2 = { 'name': LAST_OBJECT_NAME, 'version': '0.8', 'objects': [o.asValue() for o in objs], 'metadata': { 'comment': 'Converted from LXS data' } }
def __init__(self, log=yacc.PlyLogger(sys.stderr)): self.log = log self.tokens = scanner.tokens