PATH: //opt/alt/python311/share/doc/alt-python311-pyparsing-doc/examples
FILE_BARU
CREATE
FOLDER_BARU
MKDIR
UPLOAD_FILE
GO
[ .. KEMBALI ]
📄 0README.html
↓
X
📄 AcManForm.dfm
↓
X
📄 LAparser.py
↓
X
📄 Setup.ini
↓
X
📄 SimpleCalc.py
↓
X
📄 SingleForm.dfm
↓
X
📄 TAP.py
↓
X
📄 __init__.py
↓
X
📁 __pycache__/
X
📄 adventureEngine.py
↓
X
📄 antlr_grammar.py
↓
X
📄 antlr_grammar_tests.py
↓
X
📄 apicheck.py
↓
X
📄 bigquery_view_parser.py
↓
X
📄 booleansearchparser.py
↓
X
📄 btpyparse.py
↓
X
📄 builtin_parse_action_demo.py
↓
X
📄 cLibHeader.py
↓
X
📄 chemicalFormulas.py
↓
X
📄 commasep.py
↓
X
📄 configParse.py
↓
X
📄 cpp_enum_parser.py
↓
X
📄 cuneiform_python.py
↓
X
📄 datetimeParseActions.py
↓
X
📄 decaf_parser.py
↓
X
📄 delta_time.py
↓
X
📄 dfmparse.py
↓
X
📄 dhcpd_leases_parser.py
↓
X
📄 dictExample.py
↓
X
📄 dictExample2.py
↓
X
📄 ebnf.py
↓
X
📄 ebnftest.py
↓
X
📄 eval_arith.py
↓
X
📄 excelExpr.py
↓
X
📄 fourFn.py
↓
X
📄 gen_ctypes.py
↓
X
📄 getNTPserversNew.py
↓
X
📄 greeting.py
↓
X
📄 greetingInGreek.py
↓
X
📄 greetingInKorean.py
↓
X
📄 groupUsingListAllMatches.py
↓
X
📄 holaMundo.py
↓
X
📄 htmlStripper.py
↓
X
📄 htmlTableParser.py
↓
X
📄 httpServerLogParser.py
↓
X
📄 idlParse.py
↓
X
📄 include_preprocessor.py
↓
X
📄 indentedGrammarExample.py
↓
X
📄 indented_block_example.py
↓
X
📄 invRegex.py
↓
X
📄 javascript_grammar.g
↓
X
📄 jsonParser.py
↓
X
📄 left_recursion.py
↓
X
📄 linenoExample.py
↓
X
📄 listAllMatches.py
↓
X
📄 lua_parser.py
↓
X
📄 lucene_grammar.py
↓
X
📄 macroExpander.py
↓
X
📄 make_diagram.py
↓
X
📄 matchPreviousDemo.py
↓
X
📄 mozilla.ics
↓
X
📄 mozillaCalendarParser.py
↓
X
📄 nested.py
↓
X
📄 nested_markup.py
↓
X
📄 number_words.py
↓
X
📄 numerics.py
↓
X
📄 oc.py
↓
X
📄 one_to_ninety_nine.py
↓
X
📄 parsePythonValue.py
↓
X
📄 parseResultsSumExample.py
↓
X
📄 parseTabularData.py
↓
X
📄 partial_gene_match.py
↓
X
📄 pgn.py
↓
X
📄 position.py
↓
X
📄 protobuf_parser.py
↓
X
📄 pymicko.py
↓
X
📄 pythonGrammarParser.py
↓
X
📄 railroad_diagram_demo.py
↓
X
📄 rangeCheck.py
↓
X
📄 readJson.py
↓
X
📄 removeLineBreaks.py
↓
X
📄 romanNumerals.py
↓
X
📄 rosettacode.py
↓
X
📄 scanExamples.py
↓
X
📄 searchParserAppDemo.py
↓
X
📄 searchparser.py
↓
X
📄 select_parser.py
↓
X
📄 sexpParser.py
↓
X
📄 shapes.py
↓
X
📄 simpleArith.py
↓
X
📄 simpleBool.py
↓
X
📄 simpleSQL.py
↓
X
📄 simpleWiki.py
↓
X
📄 snmp_api.h
↓
X
📄 sparser.py
↓
X
📄 sql2dot.py
↓
X
📄 stackish.py
↓
X
📁 statemachine/
X
📄 test_bibparse.py
↓
X
📄 unicode_denormalizer.py
↓
X
📄 urlExtractor.py
↓
X
📄 urlExtractorNew.py
↓
X
📁 verilog/
X
📄 verilogParse.py
↓
X
📄 withAttribute.py
↓
X
📄 wordsToNum.py
↓
X
SAVING...
BERHASIL DIUBAH!
EDITING: parsePythonValue.py
# parsePythonValue.py # # Copyright, 2006, by Paul McGuire # import pyparsing as pp cvtBool = lambda t: t[0] == "True" cvtInt = lambda toks: int(toks[0]) cvtReal = lambda toks: float(toks[0]) cvtTuple = lambda toks: tuple(toks.asList()) cvtDict = lambda toks: dict(toks.asList()) cvtList = lambda toks: [toks.asList()] # define punctuation as suppressed literals lparen, rparen, lbrack, rbrack, lbrace, rbrace, colon, comma = map( pp.Suppress, "()[]{}:," ) integer = pp.Regex(r"[+-]?\d+").setName("integer").setParseAction(cvtInt) real = pp.Regex(r"[+-]?\d+\.\d*([Ee][+-]?\d+)?").setName("real").setParseAction(cvtReal) tupleStr = pp.Forward() listStr = pp.Forward() dictStr = pp.Forward() unistr = pp.unicodeString().setParseAction(lambda t: t[0][2:-1]) quoted_str = pp.quotedString().setParseAction(lambda t: t[0][1:-1]) boolLiteral = pp.oneOf("True False", asKeyword=True).setParseAction(cvtBool) noneLiteral = pp.Keyword("None").setParseAction(pp.replaceWith(None)) listItem = ( real | integer | quoted_str | unistr | boolLiteral | noneLiteral | pp.Group(listStr) | tupleStr | dictStr ) tupleStr <<= ( lparen + pp.Optional(pp.delimitedList(listItem)) + pp.Optional(comma) + rparen ) tupleStr.setParseAction(cvtTuple) listStr <<= ( lbrack + pp.Optional(pp.delimitedList(listItem) + pp.Optional(comma)) + rbrack ) listStr.setParseAction(cvtList, lambda t: t[0]) dictEntry = pp.Group(listItem + colon + listItem) dictStr <<= ( lbrace + pp.Optional(pp.delimitedList(dictEntry) + pp.Optional(comma)) + rbrace ) dictStr.setParseAction(cvtDict) if __name__ == "__main__": tests = """['a', 100, ('A', [101,102]), 3.14, [ +2.718, 'xyzzy', -1.414] ] [{0: [2], 1: []}, {0: [], 1: [], 2: []}, {0: [1, 2]}] { 'A':1, 'B':2, 'C': {'a': 1.2, 'b': 3.4} } 3.14159 42 6.02E23 6.02e+023 1.0e-7 'a quoted string'""" listItem.runTests(tests)
SIMPAN PERUBAHAN