def main(args, opts): global KW, tokens, Encoding Encoding = opts.encoding or sys.getdefaultencoding() cur = jdb.dbOpen('jmdict') # Get local ref to the keyword tables... KW = jdb.KW lexer, tokens = jellex.create_lexer(debug=opts.debug >> 8) parser = jelparse.create_parser(lexer, tokens, tabmodule='jelparse_tab') parser.debug = opts.debug if opts.seq: seq = opts.seq #FIXME: Corpid (used for xref resolution) is hardwired # to 1 (jmdict) below. srctxt, parsedtxt = _roundtrip(cur, lexer, parser, seq, 1) if not srctxt: print("Entry %s not found" % seq) else: print(srctxt) print("----") print(parsedtxt) else: _interactive(cur, lexer, parser)
def parse(krstext): entr = None errs = [] lexer, tokens = jellex.create_lexer() parser = jelparse.create_parser(lexer, tokens) jellex.lexreset(lexer, krstext) try: entr = parser.parse(krstext, lexer=lexer, tracking=True) except jelparse.ParseError as e: errs.append((e.args[0], e.loc)) return entr, errs
def globalSetup(): global Cur, KW, Lexer, Parser if Cur: return False try: import dbauth kwargs = dbauth.auth except ImportError: kwargs = {'database': 'jmdict'} kwargs['autocommit'] = True Cur = jdb.dbOpen(None, **kwargs) KW = jdb.KW Lexer, tokens = jellex.create_lexer() Parser = jelparse.create_parser(Lexer, tokens) return True
def main(args, opts): global KW, tokens encoding = opts.encoding or sys.getdefaultencoding() lexer, tokens = jellex.create_lexer(debug=opts.debug) if opts.seq: instr = _get_text_from_database(opts.seq, 1) print(instr) print("----------") test(lexer, instr) else: while 1: instr = _get_text_interactively(encoding) if not instr: break test(lexer, instr)
def setup(_): global Lexer, Tokens _.lexer, _.tokens = jellex.create_lexer() return True
def main(): jdb.KW = jdb.Kwds (jdb.std_csv_dir()) lexer, tokens = jellex.create_lexer (debug=0>>8) jelparse.create_parser (lexer, tokens, module=jelparse, tabmodule='jelparse_tab', write_tables=1, optimize=0, debug=1)