pyparsing-users Mailing List for Python parsing module (Page 8)
Brought to you by:
ptmcg
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
(2) |
Sep
|
Oct
|
Nov
(2) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(2) |
Feb
|
Mar
(2) |
Apr
(12) |
May
(2) |
Jun
|
Jul
|
Aug
(12) |
Sep
|
Oct
(1) |
Nov
|
Dec
|
2006 |
Jan
(5) |
Feb
(1) |
Mar
(10) |
Apr
(3) |
May
(7) |
Jun
(2) |
Jul
(2) |
Aug
(7) |
Sep
(8) |
Oct
(17) |
Nov
|
Dec
(3) |
2007 |
Jan
(4) |
Feb
|
Mar
(10) |
Apr
|
May
(6) |
Jun
(11) |
Jul
(1) |
Aug
|
Sep
(19) |
Oct
(8) |
Nov
(32) |
Dec
(8) |
2008 |
Jan
(12) |
Feb
(6) |
Mar
(42) |
Apr
(47) |
May
(17) |
Jun
(15) |
Jul
(7) |
Aug
(2) |
Sep
(13) |
Oct
(6) |
Nov
(11) |
Dec
(3) |
2009 |
Jan
(2) |
Feb
(3) |
Mar
|
Apr
|
May
(11) |
Jun
(13) |
Jul
(19) |
Aug
(17) |
Sep
(8) |
Oct
(3) |
Nov
(7) |
Dec
(1) |
2010 |
Jan
(2) |
Feb
|
Mar
(19) |
Apr
(6) |
May
|
Jun
(2) |
Jul
|
Aug
(1) |
Sep
|
Oct
(4) |
Nov
(3) |
Dec
(2) |
2011 |
Jan
(4) |
Feb
|
Mar
(5) |
Apr
(1) |
May
(3) |
Jun
(8) |
Jul
(6) |
Aug
(8) |
Sep
(35) |
Oct
(1) |
Nov
(1) |
Dec
(2) |
2012 |
Jan
(2) |
Feb
|
Mar
(3) |
Apr
(4) |
May
|
Jun
(1) |
Jul
|
Aug
(6) |
Sep
(18) |
Oct
|
Nov
(1) |
Dec
|
2013 |
Jan
(7) |
Feb
(7) |
Mar
(1) |
Apr
(4) |
May
|
Jun
|
Jul
(1) |
Aug
(5) |
Sep
(3) |
Oct
(11) |
Nov
(3) |
Dec
|
2014 |
Jan
(3) |
Feb
(1) |
Mar
|
Apr
(6) |
May
(10) |
Jun
(4) |
Jul
|
Aug
(5) |
Sep
(2) |
Oct
(4) |
Nov
(1) |
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
(13) |
May
(1) |
Jun
|
Jul
(2) |
Aug
|
Sep
(9) |
Oct
(2) |
Nov
(11) |
Dec
(2) |
2016 |
Jan
|
Feb
(3) |
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
(3) |
Aug
|
Sep
|
Oct
(1) |
Nov
(1) |
Dec
(4) |
2017 |
Jan
(2) |
Feb
(2) |
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
(4) |
Aug
|
Sep
|
Oct
(4) |
Nov
(3) |
Dec
|
2018 |
Jan
(10) |
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
2019 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2020 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2022 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2023 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2024 |
Jan
|
Feb
(1) |
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
(1) |
Aug
(3) |
Sep
(1) |
Oct
(1) |
Nov
|
Dec
|
From: Paul M. <pt...@au...> - 2012-09-18 10:46:11
|
all_tests = { "test_1": "some plain text", "test_2": "[simple ]", "test_3": "[simple_text some plain text]", "test_4": "[onearg [one ]]", "test_5": "[twoarg [one ] [two ]]", "test_6": "[onearg_text [one some plain text]]", "test_7": "[twoarg_text [one ] [two some plain text arg]]", "test_8": "[nested_text some [not plain] text]", "test_9": "[nested_text [one text] some [not [very ] plain] text]", "test_10": "[nested_text_escaped [one text] some [not [very ] plain] bracketed \[text\]]", "test_11": """[nested_text_escaped_indented [one text] some [not [very ] plain ] bracked \[text\] ]""", } # a simple BNF: # # listExpr ::= '[' listContent ']' # listContent ::= (contentsWord | escapedChar | listExpr)* # contentsWord ::= printableCharacter+ # # # Some notes: # 1. listContent could be empty, "[]" is a valid listExpr # 2. contentsWord cannot contain '\', '[' or ']' characters, or # else we couldn't distinguish delimiters from contents, or # detect escapes # from pyparsing import * # start with the basics LBRACK,RBRACK = map(Suppress,"[]") escapedChar = Combine('\\' + oneOf(list(printables))) contentsWord = Word(printables,excludeChars=r"\[]") # define a placeholder for a nested list, since we need to # reference it before it is fully defined listExpr = Forward() # the contents of a list is one or more contents words or lists listContent = ZeroOrMore(contentsWord | escapedChar | listExpr) # a list is a listContent enclosed in []'s - enclose # in a Group so that pyparsing will maintain the nested structure # # since listExpr was already defined as a Forward, we use '<<' to # "inject" the definition into the already defined Forward listExpr << Group(LBRACK + listContent + RBRACK) # parse the test string - note that the results no longer contain # the parsed '[' and ']' characters, but they do retain the # nesting of the original string in nested lists for name,testStr in all_tests.items(): print name, listContent.parseString(testStr).asList() # pyparsing includes a short-cut to simplify defining nested # structures like this print nestedExpr('[',']').parseString(all_tests['test_9']).asList() |
From: Claus R. <cla...@ro...> - 2012-09-18 08:30:59
|
Hi, i try to parse an object structure which is using open and close tags and containing lists of another objects. Example: NetSet{ name={LAN SIDE} oid={123998333,723663,2625521122} readOnly={0} origin={} global={0} comment={Voice Server UC} list={ NetEntry{ name={} readOnly={0} origin={} global={0} comment={} addr={192.169.0.0/24} } } neglist={ } } I tried to start with following code structure and don't know if it makes sense or not. from pyparsing import * LBRACE,RBRACE,SEMI,EQ,PCT = map(Suppress,"{};=%") comment = SEMI + restOfLine keyName = Word(alphas) text = Word( alphanums, "-", ",") text = Word(printables) num = Word(nums) ip = Combine(Word(nums) + ('.' + Word(nums))*3) v_text = keyName + EQ + LBRACE + Optional(text) + RBRACE v_num = keyName + EQ + LBRACE + Optional(num) + RBRACE v_ip = keyName + EQ + LBRACE + Optional(ip) + RBRACE NETENTRY = ( "NetEntry" + LBRACE + ZeroOrMore(Group(v_text | v_num | v_ip)) + RBRACE ) NETSET_PLIST = ( "list" + EQ + LBRACE + ZeroOrMore(NETENTRY) + RBRACE ) NETSET_NLIST = "neglist" + EQ + LBRACE + ZeroOrMore(Group(NETENTRY)) + RBRACE NETSET = "NetSet" + LBRACE + ZeroOrMore(Group(v_text | v_num | NETSET_PLIST | NETSET_NLIST)) + RBRACE rule_ref = NETSET for mr in rule_ref.parseFile("sample"): print mr I get following result: pyparsing.ParseException: Expected "}" (at char 48), (line:2, col:25) It seems NETSET_PLIST does not work, perhaps my code is the wrong approach. Thanks a lot Claus |
From: Eric S.. J. <es...@es...> - 2012-09-18 02:57:26
|
refining the testing process a little more, I've come up with some simple test cases that represent actual usage. still not grocking the given example. heck, I'm having trouble generating a bnf description. funny how when you design for human speech, you get hard to parse. :-) how does a parser like this handle recursion? for example: "test_9": "[nested_text [one text] some [not [very ] plain] text]", I expect to walk depth first and on the way back, there are calls to my code so I can do "stuff". I expect something like the following calls in this sequence: call arg name=one, parent="nested_text", text="text" call found_plain_text, text="some" call arg name=very, parent="not", text="plain" call keyword name=not call found_plain_text, text="text" call keyword name = nested_text, anyway, here is my latest test cases and results. I'm really lost here. the docs are not helping. I need a mentor chat. from pyparsing import * all_tests = { "test_1": "some plain text", "test_2": "[simple ]", "test_3": "[simple_text some plain text]", "test_4": "[onearg [one ]]", "test_5": "[twoarg [one ] [two ]]", "test_6": "[onearg_text [one some plain text]]", "test_7": "[twoarg_text [one ] [two some plain text arg]]", "test_8": "[nested_text some [not plain] text]", "test_9": "[nested_text [one text] some [not [very ] plain] text]", "test_10": "[nested_text_escaped [one text] some [not [very ] plain] bracketed \[text\]]", "test_11": """[nested_text_escaped_indented [one text] some [not [very ] plain ] bracked \[text\] ]""", } LBRACK,RBRACK = map(Suppress,'[]') escapedChar = Combine('\\' + oneOf(list(printables))) keyword = Word(alphas,alphanums).setName("keyword").setDebug() argword = Word(alphas,alphanums).setName("argword").setDebug() arg = Forward() dss = Forward() text = ZeroOrMore(escapedChar | originalTextFor(OneOrMore(Word(printables,excludeChars='[]"\'\\'))) | quotedString | dss) arg << Group(LBRACK + argword("arg") + Group(text)("text") + RBRACK) arg.setName("arg").setDebug() dss << Group(LBRACK + keyword("keyword") + Group(ZeroOrMore(arg))("args") + Group(text)("text") + RBRACK) parser = ZeroOrMore(dss) j = "" for i,j in all_tests.items(): print "------", i, "---------" test = parser.parseString(j) print "keyword is: %s" % test.keyword print "arg is: %s" % test.arg print "text is: %s" % test.text ------------------------- results --------------------------- ------ test_11 --------- Match keyword at loc 1(1,2) Matched keyword -> ['nested'] Match arg at loc 7(1,8) Exception raised:Expected "[" (at char 7), (line:1, col:8) Match keyword at loc 60(2,30) Matched keyword -> ['one'] Match arg at loc 64(2,34) Exception raised:Expected "[" (at char 64), (line:2, col:34) Match keyword at loc 105(3,30) Matched keyword -> ['not'] Match arg at loc 145(4,36) Match argword at loc 146(4,37) Matched argword -> ['very'] Matched arg -> [['very', []]] Match arg at loc 152(4,43) Exception raised:Expected "[" (at char 189), (line:5, col:36) keyword is: arg is: text is: ------ test_10 --------- Match keyword at loc 1(1,2) Matched keyword -> ['nested'] Match arg at loc 7(1,8) Exception raised:Expected "[" (at char 7), (line:1, col:8) Match keyword at loc 22(1,23) Matched keyword -> ['one'] Match arg at loc 26(1,27) Exception raised:Expected "[" (at char 26), (line:1, col:27) Match keyword at loc 38(1,39) Matched keyword -> ['not'] Match arg at loc 42(1,43) Match argword at loc 43(1,44) Matched argword -> ['very'] Matched arg -> [['very', []]] Match arg at loc 49(1,50) Exception raised:Expected "[" (at char 50), (line:1, col:51) keyword is: arg is: text is: ------ test_7 --------- Match keyword at loc 1(1,2) Matched keyword -> ['twoarg'] Match arg at loc 7(1,8) Exception raised:Expected "[" (at char 7), (line:1, col:8) Match keyword at loc 14(1,15) Matched keyword -> ['one'] Match arg at loc 18(1,19) Exception raised:Expected "[" (at char 18), (line:1, col:19) Match keyword at loc 21(1,22) Matched keyword -> ['two'] Match arg at loc 25(1,26) Exception raised:Expected "[" (at char 25), (line:1, col:26) keyword is: arg is: text is: ------ test_6 --------- Match keyword at loc 1(1,2) Matched keyword -> ['onearg'] Match arg at loc 7(1,8) Exception raised:Expected "[" (at char 7), (line:1, col:8) Match keyword at loc 14(1,15) Matched keyword -> ['one'] Match arg at loc 18(1,19) Exception raised:Expected "[" (at char 18), (line:1, col:19) keyword is: arg is: text is: ------ test_5 --------- Match keyword at loc 1(1,2) Matched keyword -> ['twoarg'] Match arg at loc 8(1,9) Match argword at loc 9(1,10) Matched argword -> ['one'] Matched arg -> [['one', []]] Match arg at loc 14(1,15) Match argword at loc 16(1,17) Matched argword -> ['two'] Matched arg -> [['two', []]] Match arg at loc 21(1,22) Exception raised:Expected "[" (at char 21), (line:1, col:22) keyword is: arg is: text is: ------ test_4 --------- Match keyword at loc 1(1,2) Matched keyword -> ['onearg'] Match arg at loc 8(1,9) Match argword at loc 9(1,10) Matched argword -> ['one'] Matched arg -> [['one', []]] Match arg at loc 14(1,15) Exception raised:Expected "[" (at char 14), (line:1, col:15) keyword is: arg is: text is: ------ test_3 --------- Match keyword at loc 1(1,2) Matched keyword -> ['simple'] Match arg at loc 7(1,8) Exception raised:Expected "[" (at char 7), (line:1, col:8) keyword is: arg is: text is: ------ test_2 --------- Match keyword at loc 1(1,2) Matched keyword -> ['simple'] Match arg at loc 8(1,9) Exception raised:Expected "[" (at char 8), (line:1, col:9) keyword is: arg is: text is: ------ test_1 --------- keyword is: arg is: text is: ------ test_9 --------- Match keyword at loc 1(1,2) Matched keyword -> ['nested'] Match arg at loc 7(1,8) Exception raised:Expected "[" (at char 7), (line:1, col:8) Match keyword at loc 14(1,15) Matched keyword -> ['one'] Match arg at loc 18(1,19) Exception raised:Expected "[" (at char 18), (line:1, col:19) Match keyword at loc 30(1,31) Matched keyword -> ['not'] Match arg at loc 34(1,35) Match argword at loc 35(1,36) Matched argword -> ['very'] Matched arg -> [['very', []]] Match arg at loc 41(1,42) Exception raised:Expected "[" (at char 42), (line:1, col:43) keyword is: arg is: text is: ------ test_8 --------- Match keyword at loc 1(1,2) Matched keyword -> ['nested'] Match arg at loc 7(1,8) Exception raised:Expected "[" (at char 7), (line:1, col:8) Match keyword at loc 19(1,20) Matched keyword -> ['not'] Match arg at loc 23(1,24) Exception raised:Expected "[" (at char 23), (line:1, col:24) keyword is: arg is: text is: [Finished in 0.1s] |
From: Eric S.. J. <es...@es...> - 2012-09-16 18:10:27
|
focusing on one line line 43 in the example... line: [hidden [id active_user][name active_user] [value [reveal active_user]]] log: Match argword at loc 962(43,2) Matched argword -> ['hidden'] Match keyword at loc 970(43,10) Matched keyword -> ['id'] Match arg at loc 973(43,13) Exception raised:Expected "[" (at char 973), (line:43, col:13) Match keyword at loc 986(43,26) Matched keyword -> ['name'] Match arg at loc 991(43,31) Exception raised:Expected "[" (at char 991), (line:43, col:31) Match keyword at loc 1005(43,45) Matched keyword -> ['value'] Match arg at loc 1011(43,51) Match argword at loc 1012(43,52) Matched argword -> ['reveal'] Matched arg -> [['reveal', ['active_user']]] Match arg at loc 1031(43,71) Exception raised:Expected "[" (at char 1031), (line:43, col:71) Matched arg -> [['hidden', [['id', [], ['active_user']], ['name', [], ['active_user']], ['value', [['reveal', ['active_user']]], []]]]] Match arg at loc 1033(43,1) Exception map: [hidden [id active_user][name active_user] [value [reveal active_user]]] * * * * marks where an exception was thrown what should I be looking at? My problem does not seem to be covered in the mini-ebook I bought (yes, I bought, not bootlegged). |
From: Eric S.. J. <es...@es...> - 2012-09-16 18:02:13
|
found a couple of interesting problems. ----- Original Message ----- if you remember, only the first few lines were printing out. > > I get the below which is only the first few lines. why not the rest? > > i, j = ['script', [['url', ['/files/tw-sack.js']]], []] > i, j = ['script', [['url', ['/files/logic.js']]], []] > i, j = ['script', [['url', ['/files/ak_vacation.js']]], []] > i, j = ['script', [['body', ['onload=', '"doSomething()"']]], []] > i, j = ['title', [], ['Out-of-Office E-mail Setup']] > after a bunch of guessing, fiddling and reading, I figured out something from the debugging logs. > > Exception raised:Expected "[" (at char 1834), (line:77, col:20) [span[class label] once you've made changes to the above information, you must save it so it can take effect] I added the missing space after "span" and the problem went away. As a sidenote, while I don't think this space is technically required after a keyword or argument name, I think it's a good idea. Anyway, a new error showed up. File "/home/esj/projects/akasha/akasha_test/vacation_test.akasha", line 19 onload="doSomething()" ^ SyntaxError: invalid syntax [Finished in 0.1s with exit code 1] I've tried triple quoting it but no luck. I am not sure how to change the parser to handle this. remember that after the keyword, after all the arguments are complete, there is a free text region to the end defined as a]. The region may be triple quoted but probably won't be unless there's something that needs protecting or escaping. The free format text may also contain more keywords as in: [bold this is some [reveal special] text] Which has this whole recursive vibe going on. other generic problems [span [class label]I want the message to say:] there is no need for a space before or after a closing bracket see examples: [div [class center]] [textarea [class data] [reveal_raw message] [name message] [rows 7] [columns 50]] [div [class center] [button [name commit] [class button] [value save] [type submit]] ] ideas?? |
From: Eric S.. J. <es...@es...> - 2012-09-15 08:12:22
|
ok figured out how to inject text. the code looks like this: LBRACK,RBRACK = map(Suppress,'[]') escapedChar = Combine('\\' + oneOf(list(printables))) keyword = Word(alphas,alphanums).setName("keyword").setDebug() argword = Word(alphas,alphanums).setName("argword").setDebug() arg = Forward() dss = Forward() text = ZeroOrMore(escapedChar | originalTextFor(OneOrMore(Word(printables,excludeChars='[]"\'\\'))) | quotedString | dss) arg << Group(LBRACK + argword("arg") + Group(text)("text") + RBRACK) arg.setName("arg").setDebug() dss << Group(LBRACK + keyword("keyword") + Group(ZeroOrMore(arg))("args") + Group(text)("text") + RBRACK) parser = ZeroOrMore(dss) print vacation_test j = "" for i in parser.parseString(vacation_test): print "i, j =", str(i), str(j) I get the below which is only the first few lines. why not the rest? i, j = ['script', [['url', ['/files/tw-sack.js']]], []] i, j = ['script', [['url', ['/files/logic.js']]], []] i, j = ['script', [['url', ['/files/ak_vacation.js']]], []] i, j = ['script', [['body', ['onload=', '"doSomething()"']]], []] i, j = ['title', [], ['Out-of-Office E-mail Setup']] why?? Exception raised:Expected "[" (at char 64), (line:6, col:1) why does: [heading [level 2] User Account: [reveal active_user]] present as from debugging: Matched arg -> [['heading', [['level', [], ['2']], 'User Account:', ['reveal', [], ['active_user']]]]] specifically, heading is a keyword, why the blank "[]", after level and reveal? arguments don't have arguments, they only have text. I added a bit of story text and it "vanished" instead of being captured so I could auto paragraph it. [heading [level 1] Out-of-Office E-mail Setup] now is the time for all vacation form to come to the rescue of your vacay form [heading [level 2] User Account: [reveal active_user]] debugging logs below Match keyword at loc 2(2,2) Matched keyword -> ['script'] Match arg at loc 17(3,8) Match argword at loc 18(3,9) Matched argword -> ['url'] Matched arg -> [['url', ['/files/tw-sack.js']]] Match arg at loc 63(5,1) Exception raised:Expected "[" (at char 64), (line:6, col:1) Match keyword at loc 67(7,2) Matched keyword -> ['script'] Match arg at loc 82(8,8) Match argword at loc 83(8,9) Matched argword -> ['url'] Matched arg -> [['url', ['/files/logic.js']]] Match arg at loc 126(10,1) Exception raised:Expected "[" (at char 127), (line:11, col:1) Match keyword at loc 130(12,2) Matched keyword -> ['script'] Match arg at loc 145(13,8) Match argword at loc 146(13,9) Matched argword -> ['url'] Matched arg -> [['url', ['/files/ak_vacation.js']]] Match arg at loc 195(15,1) Exception raised:Expected "[" (at char 196), (line:16, col:1) Match keyword at loc 199(17,2) Matched keyword -> ['script'] Match arg at loc 214(18,8) Match argword at loc 215(18,9) Matched argword -> ['body'] Matched arg -> [['body', ['onload=', '"doSomething()"']]] Match arg at loc 266(20,1) Exception raised:Expected "[" (at char 267), (line:21, col:1) Match keyword at loc 271(23,2) Matched keyword -> ['title'] Match arg at loc 277(23,8) Exception raised:Expected "[" (at char 277), (line:23, col:8) Match keyword at loc 306(24,2) Matched keyword -> ['div'] Match arg at loc 310(24,6) Match argword at loc 311(24,7) Matched argword -> ['id'] Matched arg -> [['id', ['wrapper']]] Match arg at loc 322(24,1) Match argword at loc 324(25,2) Matched argword -> ['heading'] Match keyword at loc 333(25,11) Matched keyword -> ['level'] Match arg at loc 339(25,17) Exception raised:Expected "[" (at char 339), (line:25, col:17) Matched arg -> [['heading', [['level', [], ['1']], 'Out-of-Office E-mail Setup']]] Match arg at loc 369(25,1) Match argword at loc 372(27,2) Matched argword -> ['heading'] Match keyword at loc 381(27,11) Matched keyword -> ['level'] Match arg at loc 387(27,17) Exception raised:Expected "[" (at char 387), (line:27, col:17) Match keyword at loc 405(27,35) Matched keyword -> ['reveal'] Match arg at loc 412(27,42) Exception raised:Expected "[" (at char 412), (line:27, col:42) Matched arg -> [['heading', [['level', [], ['2']], 'User Account:', ['reveal', [], ['active_user']]]]] Match arg at loc 425(27,1) Match argword at loc 427(28,2) Matched argword -> ['span'] Match keyword at loc 433(28,8) Matched keyword -> ['class'] Match arg at loc 439(28,14) Exception raised:Expected "[" (at char 439), (line:28, col:14) Matched arg -> [['span', [['class', [], ['label']], 'Please answer the following questions in order to complete the setup\nof your out-of-office mode. Please note that you must login and\ndisable this mode once you return from vacation.']]] Match arg at loc 627(30,1) Match argword at loc 630(32,2) Matched argword -> ['comment'] Matched arg -> [['comment', ['preserve active user']]] Match arg at loc 659(32,1) Match argword at loc 661(33,2) Matched argword -> ['reveal'] Matched arg -> [['reveal', ['administrative_instructions']]] Match arg at loc 696(33,1) Match argword at loc 698(34,2) Matched argword -> ['reveal'] Matched arg -> [['reveal', ['administrative_incremental']]] Match arg at loc 732(34,1) Match argword at loc 734(35,2) Matched argword -> ['div'] Match keyword at loc 739(35,7) Matched keyword -> ['id'] Match arg at loc 742(35,10) Exception raised:Expected "[" (at char 742), (line:35, col:10) Match keyword at loc 751(35,19) Matched keyword -> ['class'] Match arg at loc 757(35,25) Exception raised:Expected "[" (at char 757), (line:35, col:25) Match keyword at loc 763(35,31) Matched keyword -> ['reveal'] Match arg at loc 770(35,38) Exception raised:Expected "[" (at char 770), (line:35, col:38) Matched arg -> [['div', [['id', [], ['account']], ['class', [], ['data']], ['reveal', [], ['administrative_display']]]]] Match arg at loc 794(35,1) Match argword at loc 797(37,2) Matched argword -> ['reveal'] Matched arg -> [['reveal', ['administrative_interface']]] Match arg at loc 829(37,1) Match argword at loc 832(39,2) Matched argword -> ['form'] Match keyword at loc 839(39,9) Matched keyword -> ['id'] Match arg at loc 842(39,12) Exception raised:Expected "[" (at char 842), (line:39, col:12) Match keyword at loc 864(40,9) Matched keyword -> ['action'] Match arg at loc 871(40,16) Exception raised:Expected "[" (at char 871), (line:40, col:16) Match keyword at loc 894(41,9) Matched keyword -> ['method'] Match arg at loc 901(41,16) Exception raised:Expected "[" (at char 901), (line:41, col:16) Match keyword at loc 909(43,2) Matched keyword -> ['hidden'] Match arg at loc 916(43,9) Match argword at loc 917(43,10) Matched argword -> ['id'] Matched arg -> [['id', ['active_user']]] Match arg at loc 932(43,25) Match argword at loc 933(43,26) Matched argword -> ['name'] Matched arg -> [['name', ['active_user']]] Match arg at loc 950(43,43) Match argword at loc 952(43,45) Matched argword -> ['value'] Match keyword at loc 959(43,52) Matched keyword -> ['reveal'] Match arg at loc 966(43,59) Exception raised:Expected "[" (at char 966), (line:43, col:59) Matched arg -> [['value', [['reveal', [], ['active_user']]]]] Match arg at loc 979(43,72) Exception raised:Expected "[" (at char 979), (line:43, col:72) Match keyword at loc 982(44,2) Matched keyword -> ['span'] Match arg at loc 987(44,7) Match argword at loc 988(44,8) Matched argword -> ['class'] Matched arg -> [['class', ['label']]] Match arg at loc 1000(44,20) Exception raised:Expected "[" (at char 1000), (line:44, col:20) Match keyword at loc 1041(45,2) Matched keyword -> ['radio'] Match arg at loc 1047(45,8) Match argword at loc 1048(45,9) Matched argword -> ['class'] Matched arg -> [['class', ['textentry']]] Match arg at loc 1064(45,25) Match argword at loc 1066(45,27) Matched argword -> ['name'] Matched arg -> [['name', ['active_checked']]] Match arg at loc 1086(45,47) Match argword at loc 1087(45,48) Matched argword -> ['rawbits'] Matched arg -> [['rawbits', ['onclick=', '"javascript:showField(\'message\');showField(\'exceptions\');"']]] Match arg at loc 1163(45,1) Match argword at loc 1165(46,2) Matched argword -> ['value'] Matched arg -> [['value', ['on']]] Match arg at loc 1174(46,11) Match argword at loc 1175(46,12) Matched argword -> ['checked'] Match keyword at loc 1184(46,21) Matched keyword -> ['reveal'] Match arg at loc 1191(46,28) Exception raised:Expected "[" (at char 1191), (line:46, col:28) Matched arg -> [['checked', [['reveal', [], ['enabled']]]]] Match arg at loc 1200(46,37) Exception raised:Expected "[" (at char 1200), (line:46, col:37) Match keyword at loc 1210(47,2) Matched keyword -> ['radio'] Match arg at loc 1216(47,8) Match argword at loc 1217(47,9) Matched argword -> ['class'] Matched arg -> [['class', ['textentry']]] Match arg at loc 1233(47,1) Match argword at loc 1242(48,9) Matched argword -> ['name'] Matched arg -> [['name', ['active_checked']]] Match arg at loc 1262(48,1) Match argword at loc 1271(49,9) Matched argword -> ['rawbits'] Matched arg -> [['rawbits', ['onclick=', '"javascript:hideField(\'message\');hideField(\'exceptions\');"']]] Match arg at loc 1346(49,1) Match argword at loc 1355(50,9) Matched argword -> ['value'] Matched arg -> [['value', ['off']]] Match arg at loc 1365(50,1) Match argword at loc 1374(51,9) Matched argword -> ['checked'] Match keyword at loc 1383(51,18) Matched keyword -> ['reveal'] Match arg at loc 1390(51,25) Exception raised:Expected "[" (at char 1390), (line:51, col:25) Match keyword at loc 1400(51,35) Matched keyword -> ['default'] Match arg at loc 1408(51,43) Exception raised:Expected "[" (at char 1408), (line:51, col:43) Matched arg -> [['checked', [['reveal', [], ['disabled', ['default', [], ['off']]]]]]] Match arg at loc 1414(51,1) Exception raised:Expected "[" (at char 1422), (line:52, col:8) Match keyword at loc 1434(54,2) Matched keyword -> ['div'] Match arg at loc 1438(54,6) Match argword at loc 1439(54,7) Matched argword -> ['id'] Matched arg -> [['id', ['message']]] Match arg at loc 1450(54,18) Match argword at loc 1452(54,20) Matched argword -> ['class'] Matched arg -> [['class', ['normal']]] Match arg at loc 1465(54,1) Match argword at loc 1467(55,2) Matched argword -> ['span'] Match keyword at loc 1473(55,8) Matched keyword -> ['class'] Match arg at loc 1479(55,14) Exception raised:Expected "[" (at char 1479), (line:55, col:14) Matched arg -> [['span', [['class', [], ['label']], 'Enter all of your e-mail addresses in this box, one address on a line']]] Match arg at loc 1555(55,1) Match argword at loc 1558(57,2) Matched argword -> ['div'] Match keyword at loc 1563(57,7) Matched keyword -> ['class'] Match arg at loc 1569(57,13) Exception raised:Expected "[" (at char 1569), (line:57, col:13) Match keyword at loc 1578(58,2) Matched keyword -> ['textarea'] Match arg at loc 1587(59,1) Match argword at loc 1588(59,2) Matched argword -> ['reveal'] Matched arg -> [['reveal', ['addresses']]] Match arg at loc 1605(59,1) Match argword at loc 1607(60,2) Matched argword -> ['class'] Matched arg -> [['class', ['data']]] Match arg at loc 1618(60,1) Match argword at loc 1620(61,2) Matched argword -> ['name'] Matched arg -> [['name', ['addresses']]] Match arg at loc 1635(61,1) Match argword at loc 1637(62,2) Matched argword -> ['rows'] Matched arg -> [['rows', ['5']]] Match arg at loc 1644(62,1) Match argword at loc 1646(63,2) Matched argword -> ['columns'] Matched arg -> [['columns', ['50']]] Match arg at loc 1657(63,1) Exception raised:Expected "[" (at char 1658), (line:64, col:1) Matched arg -> [['div', [['class', [], ['center']], ['textarea', [['reveal', ['addresses']], ['class', ['data']], ['name', ['addresses']], ['rows', ['5']], ['columns', ['50']]], []]]]] Match arg at loc 1660(64,1) Match argword at loc 1663(66,2) Matched argword -> ['span'] Match keyword at loc 1669(66,8) Matched keyword -> ['class'] Match arg at loc 1675(66,14) Exception raised:Expected "[" (at char 1675), (line:66, col:14) Matched arg -> [['span', [['class', [], ['label']], 'I want the message to say:']]] Match arg at loc 1708(66,1) Match argword at loc 1711(68,2) Matched argword -> ['div'] Match keyword at loc 1716(68,7) Matched keyword -> ['class'] Match arg at loc 1722(68,13) Exception raised:Expected "[" (at char 1722), (line:68, col:13) Match keyword at loc 1731(69,2) Matched keyword -> ['textarea'] Match arg at loc 1740(70,1) Match argword at loc 1741(70,2) Matched argword -> ['class'] Matched arg -> [['class', ['data']]] Match arg at loc 1752(70,1) Match argword at loc 1754(71,2) Matched argword -> ['reveal'] Matched arg -> [['reveal', ['_raw message']]] Match arg at loc 1773(71,1) Match argword at loc 1775(72,2) Matched argword -> ['name'] Matched arg -> [['name', ['message']]] Match arg at loc 1788(72,1) Match argword at loc 1790(73,2) Matched argword -> ['rows'] Matched arg -> [['rows', ['7']]] Match arg at loc 1797(73,1) Match argword at loc 1799(74,2) Matched argword -> ['columns'] Matched arg -> [['columns', ['50']]] Match arg at loc 1810(74,1) Exception raised:Expected "[" (at char 1811), (line:75, col:1) Matched arg -> [['div', [['class', [], ['center']], ['textarea', [['class', ['data']], ['reveal', ['_raw message']], ['name', ['message']], ['rows', ['7']], ['columns', ['50']]], []]]]] Match arg at loc 1813(75,1) Match argword at loc 1816(77,2) Matched argword -> ['span'] Match keyword at loc 1821(77,7) Matched keyword -> ['class'] Match arg at loc 1827(77,13) Exception raised:Expected "[" (at char 1827), (line:77, col:13) Exception raised:Expected "]" (at char 1842), (line:77, col:28) Match keyword at loc 1816(77,2) Matched keyword -> ['span'] Match arg at loc 1820(77,6) Match argword at loc 1821(77,7) Matched argword -> ['class'] Matched arg -> [['class', ['label']]] Match arg at loc 1833(77,19) Exception raised:Expected "[" (at char 1834), (line:77, col:20) Exception raised:Expected "]" (at char 1433), (line:54, col:1) Match keyword at loc 832(39,2) Matched keyword -> ['form'] Match arg at loc 838(39,8) Match argword at loc 839(39,9) Matched argword -> ['id'] Matched arg -> [['id', ['account_data']]] Match arg at loc 855(39,1) Match argword at loc 864(40,9) Matched argword -> ['action'] Matched arg -> [['action', ['edit_vacation']]] Match arg at loc 885(40,1) Match argword at loc 894(41,9) Matched argword -> ['method'] Matched arg -> [['method', ['post']]] Match arg at loc 906(41,1) Match argword at loc 909(43,2) Matched argword -> ['hidden'] Match keyword at loc 917(43,10) Matched keyword -> ['id'] Match arg at loc 920(43,13) Exception raised:Expected "[" (at char 920), (line:43, col:13) Match keyword at loc 933(43,26) Matched keyword -> ['name'] Match arg at loc 938(43,31) Exception raised:Expected "[" (at char 938), (line:43, col:31) Match keyword at loc 952(43,45) Matched keyword -> ['value'] Match arg at loc 958(43,51) Match argword at loc 959(43,52) Matched argword -> ['reveal'] Matched arg -> [['reveal', ['active_user']]] Match arg at loc 978(43,71) Exception raised:Expected "[" (at char 978), (line:43, col:71) Matched arg -> [['hidden', [['id', [], ['active_user']], ['name', [], ['active_user']], ['value', [['reveal', ['active_user']]], []]]]] Match arg at loc 980(43,1) Match argword at loc 982(44,2) Matched argword -> ['span'] Match keyword at loc 988(44,8) Matched keyword -> ['class'] Match arg at loc 994(44,14) Exception raised:Expected "[" (at char 994), (line:44, col:14) Matched arg -> [['span', [['class', [], ['label']], 'I want the out-of-office notification:']]] Match arg at loc 1039(44,1) Match argword at loc 1041(45,2) Matched argword -> ['radio'] Match keyword at loc 1048(45,9) Matched keyword -> ['class'] Match arg at loc 1054(45,15) Exception raised:Expected "[" (at char 1054), (line:45, col:15) Match keyword at loc 1066(45,27) Matched keyword -> ['name'] Match arg at loc 1071(45,32) Exception raised:Expected "[" (at char 1071), (line:45, col:32) Match keyword at loc 1087(45,48) Matched keyword -> ['rawbits'] Match arg at loc 1095(45,56) Exception raised:Expected "[" (at char 1095), (line:45, col:56) Match keyword at loc 1165(46,2) Matched keyword -> ['value'] Match arg at loc 1171(46,8) Exception raised:Expected "[" (at char 1171), (line:46, col:8) Match keyword at loc 1175(46,12) Matched keyword -> ['checked'] Match arg at loc 1183(46,20) Match argword at loc 1184(46,21) Matched argword -> ['reveal'] Matched arg -> [['reveal', ['enabled']]] Match arg at loc 1199(46,36) Exception raised:Expected "[" (at char 1199), (line:46, col:36) Matched arg -> [['radio', [['class', [], ['textentry']], ['name', [], ['active_checked']], ['rawbits', [], ['onclick=', '"javascript:showField(\'message\');showField(\'exceptions\');"']], ['value', [], ['on']], ['checked', [['reveal', ['enabled']]], []], 'Enabled']]] Match arg at loc 1208(46,1) Match argword at loc 1210(47,2) Matched argword -> ['radio'] Match keyword at loc 1217(47,9) Matched keyword -> ['class'] Match arg at loc 1223(47,15) Exception raised:Expected "[" (at char 1223), (line:47, col:15) Match keyword at loc 1242(48,9) Matched keyword -> ['name'] Match arg at loc 1247(48,14) Exception raised:Expected "[" (at char 1247), (line:48, col:14) Match keyword at loc 1271(49,9) Matched keyword -> ['rawbits'] Match arg at loc 1279(49,17) Exception raised:Expected "[" (at char 1279), (line:49, col:17) Match keyword at loc 1355(50,9) Matched keyword -> ['value'] Match arg at loc 1361(50,15) Exception raised:Expected "[" (at char 1361), (line:50, col:15) Match keyword at loc 1374(51,9) Matched keyword -> ['checked'] Match arg at loc 1382(51,17) Match argword at loc 1383(51,18) Matched argword -> ['reveal'] Match keyword at loc 1400(51,35) Matched keyword -> ['default'] Match arg at loc 1408(51,43) Exception raised:Expected "[" (at char 1408), (line:51, col:43) Matched arg -> [['reveal', ['disabled', ['default', [], ['off']]]]] Match arg at loc 1413(51,48) Exception raised:Expected "[" (at char 1413), (line:51, col:48) Matched arg -> [['radio', [['class', [], ['textentry']], ['name', [], ['active_checked']], ['rawbits', [], ['onclick=', '"javascript:hideField(\'message\');hideField(\'exceptions\');"']], ['value', [], ['off']], ['checked', [['reveal', ['disabled', ['default', [], ['off']]]]], []], 'Disabled']]] Match arg at loc 1431(52,1) Match argword at loc 1434(54,2) Matched argword -> ['div'] Match keyword at loc 1439(54,7) Matched keyword -> ['id'] Match arg at loc 1442(54,10) Exception raised:Expected "[" (at char 1442), (line:54, col:10) Match keyword at loc 1452(54,20) Matched keyword -> ['class'] Match arg at loc 1458(54,26) Exception raised:Expected "[" (at char 1458), (line:54, col:26) Match keyword at loc 1467(55,2) Matched keyword -> ['span'] Match arg at loc 1472(55,7) Match argword at loc 1473(55,8) Matched argword -> ['class'] Matched arg -> [['class', ['label']]] Match arg at loc 1485(55,20) Exception raised:Expected "[" (at char 1485), (line:55, col:20) Match keyword at loc 1558(57,2) Matched keyword -> ['div'] Match arg at loc 1562(57,6) Match argword at loc 1563(57,7) Matched argword -> ['class'] Matched arg -> [['class', ['center']]] Match arg at loc 1576(57,1) Match argword at loc 1578(58,2) Matched argword -> ['textarea'] Match keyword at loc 1588(59,2) Matched keyword -> ['reveal'] Match arg at loc 1595(59,9) Exception raised:Expected "[" (at char 1595), (line:59, col:9) Match keyword at loc 1607(60,2) Matched keyword -> ['class'] Match arg at loc 1613(60,8) Exception raised:Expected "[" (at char 1613), (line:60, col:8) Match keyword at loc 1620(61,2) Matched keyword -> ['name'] Match arg at loc 1625(61,7) Exception raised:Expected "[" (at char 1625), (line:61, col:7) Match keyword at loc 1637(62,2) Matched keyword -> ['rows'] Match arg at loc 1642(62,7) Exception raised:Expected "[" (at char 1642), (line:62, col:7) Match keyword at loc 1646(63,2) Matched keyword -> ['columns'] Match arg at loc 1654(63,10) Exception raised:Expected "[" (at char 1654), (line:63, col:10) Matched arg -> [['textarea', [['reveal', [], ['addresses']], ['class', [], ['data']], ['name', [], ['addresses']], ['rows', [], ['5']], ['columns', [], ['50']]]]] Match arg at loc 1659(64,2) Exception raised:Expected "[" (at char 1659), (line:64, col:2) Match keyword at loc 1663(66,2) Matched keyword -> ['span'] Match arg at loc 1668(66,7) Match argword at loc 1669(66,8) Matched argword -> ['class'] Matched arg -> [['class', ['label']]] Match arg at loc 1681(66,20) Exception raised:Expected "[" (at char 1681), (line:66, col:20) Match keyword at loc 1711(68,2) Matched keyword -> ['div'] Match arg at loc 1715(68,6) Match argword at loc 1716(68,7) Matched argword -> ['class'] Matched arg -> [['class', ['center']]] Match arg at loc 1729(68,1) Match argword at loc 1731(69,2) Matched argword -> ['textarea'] Match keyword at loc 1741(70,2) Matched keyword -> ['class'] Match arg at loc 1747(70,8) Exception raised:Expected "[" (at char 1747), (line:70, col:8) Match keyword at loc 1754(71,2) Matched keyword -> ['reveal'] Match arg at loc 1760(71,8) Exception raised:Expected "[" (at char 1760), (line:71, col:8) Match keyword at loc 1775(72,2) Matched keyword -> ['name'] Match arg at loc 1780(72,7) Exception raised:Expected "[" (at char 1780), (line:72, col:7) Match keyword at loc 1790(73,2) Matched keyword -> ['rows'] Match arg at loc 1795(73,7) Exception raised:Expected "[" (at char 1795), (line:73, col:7) Match keyword at loc 1799(74,2) Matched keyword -> ['columns'] Match arg at loc 1807(74,10) Exception raised:Expected "[" (at char 1807), (line:74, col:10) Matched arg -> [['textarea', [['class', [], ['data']], ['reveal', [], ['_raw message']], ['name', [], ['message']], ['rows', [], ['7']], ['columns', [], ['50']]]]] Match arg at loc 1812(75,2) Exception raised:Expected "[" (at char 1812), (line:75, col:2) Match keyword at loc 1816(77,2) Matched keyword -> ['span'] Match arg at loc 1820(77,6) Match argword at loc 1821(77,7) Matched argword -> ['class'] Matched arg -> [['class', ['label']]] Match arg at loc 1833(77,19) Exception raised:Expected "[" (at char 1834), (line:77, col:20) Exception raised:Expected "]" (at char 1815), (line:77, col:1) Match keyword at loc 1434(54,2) Matched keyword -> ['div'] Match arg at loc 1438(54,6) Match argword at loc 1439(54,7) Matched argword -> ['id'] Matched arg -> [['id', ['message']]] Match arg at loc 1450(54,18) Match argword at loc 1452(54,20) Matched argword -> ['class'] Matched arg -> [['class', ['normal']]] Match arg at loc 1465(54,1) Match argword at loc 1467(55,2) Matched argword -> ['span'] Match keyword at loc 1473(55,8) Matched keyword -> ['class'] Match arg at loc 1479(55,14) Exception raised:Expected "[" (at char 1479), (line:55, col:14) Matched arg -> [['span', [['class', [], ['label']], 'Enter all of your e-mail addresses in this box, one address on a line']]] Match arg at loc 1555(55,1) Match argword at loc 1558(57,2) Matched argword -> ['div'] Match keyword at loc 1563(57,7) Matched keyword -> ['class'] Match arg at loc 1569(57,13) Exception raised:Expected "[" (at char 1569), (line:57, col:13) Match keyword at loc 1578(58,2) Matched keyword -> ['textarea'] Match arg at loc 1587(59,1) Match argword at loc 1588(59,2) Matched argword -> ['reveal'] Matched arg -> [['reveal', ['addresses']]] Match arg at loc 1605(59,1) Match argword at loc 1607(60,2) Matched argword -> ['class'] Matched arg -> [['class', ['data']]] Match arg at loc 1618(60,1) Match argword at loc 1620(61,2) Matched argword -> ['name'] Matched arg -> [['name', ['addresses']]] Match arg at loc 1635(61,1) Match argword at loc 1637(62,2) Matched argword -> ['rows'] Matched arg -> [['rows', ['5']]] Match arg at loc 1644(62,1) Match argword at loc 1646(63,2) Matched argword -> ['columns'] Matched arg -> [['columns', ['50']]] Match arg at loc 1657(63,1) Exception raised:Expected "[" (at char 1658), (line:64, col:1) Matched arg -> [['div', [['class', [], ['center']], ['textarea', [['reveal', ['addresses']], ['class', ['data']], ['name', ['addresses']], ['rows', ['5']], ['columns', ['50']]], []]]]] Match arg at loc 1660(64,1) Match argword at loc 1663(66,2) Matched argword -> ['span'] Match keyword at loc 1669(66,8) Matched keyword -> ['class'] Match arg at loc 1675(66,14) Exception raised:Expected "[" (at char 1675), (line:66, col:14) Matched arg -> [['span', [['class', [], ['label']], 'I want the message to say:']]] Match arg at loc 1708(66,1) Match argword at loc 1711(68,2) Matched argword -> ['div'] Match keyword at loc 1716(68,7) Matched keyword -> ['class'] Match arg at loc 1722(68,13) Exception raised:Expected "[" (at char 1722), (line:68, col:13) Match keyword at loc 1731(69,2) Matched keyword -> ['textarea'] Match arg at loc 1740(70,1) Match argword at loc 1741(70,2) Matched argword -> ['class'] Matched arg -> [['class', ['data']]] Match arg at loc 1752(70,1) Match argword at loc 1754(71,2) Matched argword -> ['reveal'] Matched arg -> [['reveal', ['_raw message']]] Match arg at loc 1773(71,1) Match argword at loc 1775(72,2) Matched argword -> ['name'] Matched arg -> [['name', ['message']]] Match arg at loc 1788(72,1) Match argword at loc 1790(73,2) Matched argword -> ['rows'] Matched arg -> [['rows', ['7']]] Match arg at loc 1797(73,1) Match argword at loc 1799(74,2) Matched argword -> ['columns'] Matched arg -> [['columns', ['50']]] Match arg at loc 1810(74,1) Exception raised:Expected "[" (at char 1811), (line:75, col:1) Matched arg -> [['div', [['class', [], ['center']], ['textarea', [['class', ['data']], ['reveal', ['_raw message']], ['name', ['message']], ['rows', ['7']], ['columns', ['50']]], []]]]] Match arg at loc 1813(75,1) Match argword at loc 1816(77,2) Matched argword -> ['span'] Match keyword at loc 1821(77,7) Matched keyword -> ['class'] Match arg at loc 1827(77,13) Exception raised:Expected "[" (at char 1827), (line:77, col:13) Exception raised:Expected "]" (at char 1842), (line:77, col:28) Match keyword at loc 1816(77,2) Matched keyword -> ['span'] Match arg at loc 1820(77,6) Match argword at loc 1821(77,7) Matched argword -> ['class'] Matched arg -> [['class', ['label']]] Match arg at loc 1833(77,19) Exception raised:Expected "[" (at char 1834), (line:77, col:20) |
From: Eric S.. J. <es...@es...> - 2012-09-12 03:04:47
|
----- Original Message ----- > From: "Mario R. Osorio" <nim...@gm...> > To: "Eric S.. Johansson" <es...@es...> > Cc: "Paul McGuire" <pt...@au...>, > pyp...@li... > Sent: Tuesday, September 11, 2012 8:02:58 PM > Subject: Re: [Pyparsing] need help building parsing framework for > disability access tool > Eric > I am by no means what you would call an expert in language definition > nor python; I just had the need to use a parser for a "mini > language" that sure enough, turned into an almost full fledged one. > I tried about three solutions (all in python) and ended up using > pyparse and loving it! > I found a book on pyparse, whether it was free online or ... I'm not > sure. > a pointer to book would be great > Oh, and by the way; this tool and the book is written in a very > friendly "alien" dialect. Please restate your original question as I > missed your original post. I can send you some of my code if you > need. oh boy, friendly aliens. How would they say "take me to your leader"? --- here's the original example I gave. Below I've tried to expand and comment. [script [url /files/tw-sack.js]] [script [url /files/logic.js]] [script [url /files/ak_vacation.js]] [script [body onload="doSomething()"]] [title Out-of-Office E-mail Setup] [div [id wrapper] [heading [level 1] Out-of-Office E-mail Setup] [heading [level 2] User Account: [reveal active_user]] [span [class label]Please answer the following questions in order to complete the setup of your out-of-office mode. Please note that you must login and disable this mode once you return from vacation.] [comment preserve active user] [reveal administrative_instructions] [reveal administrative_incremental] [div [id account][class data][reveal administrative_display]] [reveal administrative_interface] [form [id account_data] [action edit_vacation] [method post] [hidden [id active_user][name active_user] [value [reveal active_user]]] [span [class label]I want the out-of-office notification:] [radio [class textentry] [name active_checked][rawbits onclick="javascript:showField('message');showField('exceptions');" ] [value on][checked [reveal enabled]]Enabled] [radio [class textentry] [name active_checked] [rawbits onclick="javascript:hideField('message');hideField('exceptions');"] [value off] [checked [reveal disabled [default off]]] Disabled] [div [id message] [class normal] [span [class label]Enter all of your e-mail addresses in this box, one address on a line] [div [class center] [textarea [reveal addresses] [class data] [name addresses] [rows 5] [columns 50] ]] [span [class label]I want the message to say:] [div [class center] [textarea [class data] [reveal_raw message] [name message] [rows 7] [columns 50] ]] [span[class label] once you've made changes to the above information, you must save it so it can take effect] ] [div [class center] [button [name commit] [class button] [value save] [type submit]] ] ]] ---------------- reference example explained -------------- [comment """each script command has a single argument. One of the interesting things about the existing implementation is that arguments for a command is defined as attributes of the parser/action code method. it looks like this: self.context_script = ["body", "URL", "page", "xfile"] the reason for the triple quotes around the comment is that I have special characters in the body of the comment. Normally a comment wouldn't need the protection of triple quotes and could just be plain text inside the body. the example below also shows how each component would be expanded below the owner of that component. I'll do this in several other places below. """ ] [script [url /files/tw-sack.js ] ] [script [url /files/logic.js]] [script [url /files/ak_vacation.js]] [script [body onload="doSomething()"]] [comment example of a simple command with data for the command immediately following the command and terminated by a close bracket] [title Out-of-Office E-mail Setup] [comment really need to rename div because while it is in the vocabulary of NaturallySpeaking, it's not really cognitively friendly. this is an example of a command with a single argument with a naked text value for the ID.] [div [id wrapper] [comment an example of command with a single argument and data following the argument] [heading [level 1] Out-of-Office E-mail Setup] [comment command with single argument and composite data consisting of text and results from another command. The order of execution needs to be revealed first then the composite data string is constructed. The argument is evaluated in a similar fashion because it could also be composite] [heading [level 2] User Account: [reveal active_user]] [comment same command as above but the argument is now generated from program data] [heading [level [reveal second_level ] ] User Account: [reveal active_user] ] ] [span [class label]Please answer the following questions in order to complete the setup of your out-of-office mode. Please note that you must login and disable this mode once you return from vacation.] [comment preserve active user] [comment the next two reveals actually inject akasha markup into the markup stream. Think in this case it's like a dynamic include except it's the program that hands the application data instead of the application getting the data from a file] [reveal administrative_instructions] [reveal administrative_incremental] [comment this is a good example of two arguments and reveal filling the data section.] [div [id account ] [class data ] [reveal administrative_display ] ] [reveal administrative_interface] [form [id account_data] [action edit_vacation] [method post] [hidden [id active_user][name active_user] [value [reveal active_user]]] [span [class label]I want the out-of-office notification:] [radio [class textentry] [name active_checked][rawbits onclick="javascript:showField('message');showField('exceptions');" ] [value on][checked [reveal enabled]]Enabled] [radio [class textentry] [name active_checked] [rawbits onclick="javascript:hideField('message');hideField('exceptions');"] [value off] [checked [reveal disabled [default off]]] Disabled] [comment if you notice the tight spacing in a lot of the lines, it's because the original parsers broken and leaks the space character when it shouldn't.] [div [id message] [class normal] [span [class label]Enter all of your e-mail addresses in this box, one address on a line] [div [class center] [textarea [reveal addresses] [class data] [name addresses] [rows 5] [columns 50] ]] [span [class label]I want the message to say:] [div [class center] [textarea [class data] [reveal_raw message] [name message] [rows 7] [columns 50] ]] [span[class label] once you've made changes to the above information, you must save it so it can take effect] ] [div [class center] [button [name commit] [class button] [value save] [type submit]] ] ]] ----------------sample code given Paul kindly gave me this example code but I'm having a hard time making heads or tails of it. For example, I can't figure out how to inject the text so can be parsed and how that information be presented so that the right bit such as the reveal where the arguments can be processed before the main command. One way to look at the markup language is that you walk the tree all the way to the bottom in that start filling in the blanks as you work your way up. It would be a depth first tree walk. One of the important features to maintain for the end user to create their own domain specific extensions. from pyparsing import * LBRACK,RBRACK = map(Suppress,'[]') escapedChar = Combine('\\' + oneOf(list(printables))) keyword = Word(alphas,alphanums).setName("keyword")#.setDebug() argword = Word(alphas,alphanums).setName("argword")#.setDebug() arg = Forward() dss = Forward() text = ZeroOrMore(escapedChar | originalTextFor(OneOrMore(Word(printables, excludeChars='[]"\'\\'))) | quotedString | dss) arg << Group(LBRACK + argword("arg") + Group(text)("text") + RBRACK) arg.setName("arg")#.setDebug() dss << Group(LBRACK + keyword("keyword") + Group(ZeroOrMore(arg))("args") + Group(text)("text") + RBRACK) parser = ZeroOrMore(dss) |
From: Mario R. O. <nim...@gm...> - 2012-09-12 00:03:26
|
Eric I am by no means what you would call an expert in language definition nor python; I just had the need to use a parser for a "mini language" that sure enough, turned into an almost full fledged one. I tried about three solutions (all in python) and ended up using pyparse and loving it! I found a book on pyparse, whether it was free online or ... I'm not sure. Oh, and by the way; this tool and the book is written in a very friendly "alien" dialect. Please restate your original question as I missed your original post. I can send you some of my code if you need. Dtb/Gby ======= Mario R. Osorio "... Begin with the end in mind ..." http://www.google.com/profiles/nimbiotics On Tue, Sep 11, 2012 at 5:46 PM, Eric S.. Johansson <es...@es...>wrote: > > > ----- Original Message ----- > > From: "Paul McGuire" <pt...@au...> > > To: "Eric S.. Johansson" <es...@es...>, > pyp...@li... > > Sent: Friday, September 7, 2012 4:59:38 AM > > Subject: RE: [Pyparsing] need help building parsing framework for > disability access tool > > > > Eric - > > > > See if this gets you close: > > No matter how well somebody does your homework for you, you still need to > study to understand the basics. > > It looks like it should do what I want but I still can't quite figure it > out. The syntax of pyparsing is "different". > > My first question is how do I inject the text stream into this. Is it > using parser as a function and the text stream is the input argument? what > is returned and in what order? You tell me to use "keyword" "arg" and > "data" but I'm not grocking how yet. > > are there any good books or online documentation for really understanding > pyparser or is it one of those "written by aliens"[1] type of things? > > > Thanks > --- eric > > [1] The phrase "written by aliens" is an affectionate tease of really > brilliant people who write something so astonishingly Brilliant yet > unintelligible to mere mortals. I've been on both sides of the line. :-) > > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Pyparsing-users mailing list > Pyp...@li... > https://lists.sourceforge.net/lists/listinfo/pyparsing-users > |
From: Eric S.. J. <es...@es...> - 2012-09-11 22:41:55
|
----- Original Message ----- > From: "Paul McGuire" <pt...@au...> > To: "Eric S.. Johansson" <es...@es...>, pyp...@li... > Sent: Friday, September 7, 2012 4:59:38 AM > Subject: RE: [Pyparsing] need help building parsing framework for disability access tool > > Eric - > > See if this gets you close: No matter how well somebody does your homework for you, you still need to study to understand the basics. It looks like it should do what I want but I still can't quite figure it out. The syntax of pyparsing is "different". My first question is how do I inject the text stream into this. Is it using parser as a function and the text stream is the input argument? what is returned and in what order? You tell me to use "keyword" "arg" and "data" but I'm not grocking how yet. are there any good books or online documentation for really understanding pyparser or is it one of those "written by aliens"[1] type of things? Thanks --- eric [1] The phrase "written by aliens" is an affectionate tease of really brilliant people who write something so astonishingly Brilliant yet unintelligible to mere mortals. I've been on both sides of the line. :-) |
From: Paul M. <pt...@au...> - 2012-09-07 08:59:59
|
Eric - See if this gets you close: =============== from pyparsing import * LBRACK,RBRACK = map(Suppress,'[]') escapedChar = Combine('\\' + oneOf(list(printables))) keyword = Word(alphas,alphanums).setName("keyword")#.setDebug() argword = Word(alphas,alphanums).setName("argword")#.setDebug() arg = Forward() dss = Forward() text = ZeroOrMore(escapedChar | originalTextFor(OneOrMore(Word(printables, excludeChars='[]"\'\\'))) | quotedString | dss) arg << Group(LBRACK + argword("arg") + Group(text)("text") + RBRACK) arg.setName("arg")#.setDebug() dss << Group(LBRACK + keyword("keyword") + Group(ZeroOrMore(arg))("args") + Group(text)("text") + RBRACK) parser = ZeroOrMore(dss) ============== I was able to parse much of the posted sample input you provided, although there seem to be a number of missing terminating ']'s in your sample. Without the matching ']', the parser will not know when a particular dss or arg is supposed to end. If you want to view the progress as the parser works through your input, uncomment one or more of the setDebug() calls. When you process the results from after parsing, please try to make use of the 'keyword', 'args', and 'text' results names, I think they will be helpful. Hope this gets you further in your project! -- Paul |
From: Eric S.. J. <es...@es...> - 2012-09-07 07:11:51
|
I have a project that needs help with. It's a web framework designed for easy use with speech recognition. Given that I'm disabled, there is a bit of a self-serving aspect of this request. :-) sadly the parser in this tool tool is broken (i.e. built out of regular expressions)and is built on a regular expression The project is a rejuvenation of something I worked on in the mid-2000. Named Akasha, it's a small scale web development framework designed to be a tool, not a career like some of the larger scale web frameworks out there. It's also designed to be usable if you're disabled like me. the meditation is easy to speak and and easy to navigate if I had the right editor support. as I said earlier, I inherited a parser that was cobbled together out of regular expressions and it's failing at odd corners. I like to place it and it shouldn't be too complicated. It's just beyond my current level of knowledge. here are a few examples. Coupled nodes is that any plain text by itself is printed out. There are two ways of dealing with special characters, but if you escape them individually as shown in the pre-format list below and the other is to enclose the text with special characters in triple quotes. after the first example is a more complicated demonstration. It was a user interface for managing vacation notifications. Again, most of this was something I could dictate and what had to be typed was encapsulated to a relatively small portion. At the end has probably the closest I've come to for a mock BNF description of the syntax. it's probably wrong since I'm out of practice so I would appreciate any feedback. Thanks in advance. Helping me rejuvenate this tool will enable speech recognition dependent disabled programmers to create web applications easily and effectively. 3x table [grid [wide 3] [cell 1] [cell 2] [cell 3] [cell 4] [cell 5] [cell 6] [cell 7] ] preformat text [preformat \[grid \[cell 1\] \[cell 2\] \[cell 3\] \[cell 4\] \[cell 5\] \[cell 6\] \[cell 7\] \] ------------- [script [url /files/tw-sack.js]] [script [url /files/logic.js]] [script [url /files/ak_vacation.js]] [script [body onload="doSomething()"]] [title Out-of-Office E-mail Setup] [div [id wrapper] [heading [level 1] Out-of-Office E-mail Setup] [heading [level 2] User Account: [reveal active_user]] [span [class label]Please answer the following questions in order to complete the setup of your out-of-office mode. Please note that you must login and disable this mode once you return from vacation.] [comment preserve active user] [reveal administrative_instructions] [reveal administrative_incremental] [div [id account][class data][reveal administrative_display]] [reveal administrative_interface] [form [id account_data] [action edit_vacation] [method post] [hidden [id active_user][name active_user] [value [reveal active_user]]] [span [class label]I want the out-of-office notification:] [radio [class textentry] [name active_checked][rawbits onclick="javascript:showField('message');showField('exceptions');" ] [value on][checked [reveal enabled]]Enabled] [radio [class textentry] [name active_checked] [rawbits onclick="javascript:hideField('message');hideField('exceptions');"] [value off] [checked [reveal disabled [default off]]] Disabled] [div [id message] [class normal] [span [class label]Enter all of your e-mail addresses in this box, one address on a line] [div [class center] [textarea [reveal addresses] [class data] [name addresses] [rows 5] [columns 50] ]] [span [class label]I want the message to say:] [div [class center] [textarea [class data] [reveal_raw message] [name message] [rows 7] [columns 50] ]] [span[class label] once you've made changes to the above information, you must save it so it can take effect] ] [div [class center] [button [name commit] [class button] [value save] [type submit]] ] ]] -------------------- dss =:: <bracket><keyword> 0*<arg> <text><bracket> arg =: <bracket>argword <text><bracket> <text> 1*(0*<words>| 0*<dss>) |
From: thomas_h <th...@gm...> - 2012-08-18 18:39:14
|
Paul, great, thanks. I was thinking briefly of the Group class during my research, but looking at the documentation thought it might serve a different purpose. I will re-check the material on Group. Cheers, Thomas On Thu, Aug 16, 2012 at 8:28 PM, <pt...@au...> wrote: > > To keep the different names of each pair separate, you'll need to enclose pp1 in a Group: > > pp1=py.Group(py.Word(py.alphanums)("name") + py.Word(py.nums)("number")) > > > Now when you parse your string, r2.list will contain a list of paired name-values: > > r2=pp2.parseString("BAR 10, ZAP 20") > > for pair in r2.list: > print pair.name, pair.number > > To get at an individual element, just using sliced indexing, just like it was a normal list: > > print r2.list[0].name > > -- Paul > > |
From: <pt...@au...> - 2012-08-16 20:43:50
|
To keep the different names of each pair separate, you'll need to enclose pp1 in a Group: pp1=py.Group(py.Word(py.alphanums)("name") + py.Word(py.nums)("number")) Now when you parse your string, r2.list will contain a list of paired name-values: r2=pp2.parseString("BAR 10, ZAP 20") for pair in r2.list: print pair.name, pair.number To get at an individual element, just using sliced indexing, just like it was a normal list: print r2.list[0].name -- Paul |
From: thomas_h <th...@gm...> - 2012-08-16 13:03:13
|
Hi, sorry if this is a trivial or often answered question, but I didn't find a solution so far. (pyparsing.__version__: 1.5.5) I want to access nested ParseResults. Here is a simple example. (My original problem is in a larger grammar, so please refrain from trivial re-writes :): import pyparsing as py pp1=py.Word(py.alphanums)("name") + py.Word(py.nums)("number") pp2 = py.delimitedList(pp1)("list") r2=pp2.parseString("BAR 10, ZAP 20") I want to access the individual "name"s and "number"s of the pp1 parses. If you just repr(r2), it's all there, part. you can see all those names and numbers: In [182]: repr(r2) Out[182]: "(['BAR', '10', 'ZAP', '20'], {'list': [((['BAR', '10', 'ZAP', '20'], {'name': [('BAR', 0), ('ZAP', 2)], 'number': [('10', 1), ('20', 3)]}), 0)], 'name': [('BAR', 0), ('ZAP', 2)], 'number': [('10', 1), ('20', 3)]})" But when I want to access the individual ParseResults, I can't: In [187]: r2.list Out[187]: (['BAR', '10', 'ZAP', '20'], {'name': [('BAR', 0), ('ZAP', 2)], 'number': [('10', 1), ('20', 3)]}) In [188]: r2.list.name Out[188]: 'ZAP' In [189]: r2.list.name[0] Out[189]: 'Z' In [190]: type(r2.list.name) Out[190]: str Everytime I try to access the "name" or "number" elements, they are treated as if it's only the last value. What am I missing? Thomas |
From: Szabo, P. \(LNG-VIE\) <pat...@le...> - 2012-08-14 14:14:25
|
Hi, We are using PyParse to find and mark certain citations in xml files. It works great for the most part (which tells me our regex and matching is correct) but sometimes it misses some stuff. The really weird thing about that is if I test those strings in Eclipse by simply giving the function a long string that represents an xml file everything works fine and all the citations are found and marked. However if I read the xml files using python's open (which should give me the very same string) it doesn't work i.e. the citations are not marked or even found. The encoding is always iso-8859-1 and that problem only occurs with certain files or sometimes even only parts of files. You can find the source here: http://pastebin.com/F6c8PTfd I can't provide everything because I'm not allowed but I hope you can help me. Best regards . . . . . . . . . . . . . . . . . . . . . . . . . . Developer Patrick Szabo Developer LexisNexis A-1030 Wien, Marxergasse 25 mailto:pat...@le... Tel.: +43 1 53452 1573 Fax: +43 1 534 52 146 |
From: Kenneth L. <ke...@lo...> - 2012-08-14 13:28:06
|
On Mon, Aug 13, 2012 at 10:15 AM, Kenneth Loafman <ke...@lo...>wrote: > HI, > > I've got a grammar which checks a search query to see if it is valid. The > problem is that the grammar is allowing through items like 'foo:bar' as > 'foo AND bar' (implicit AND). Is there a way to check that a Regex has > parsed the entire term, i.e. that the next char is a space or EOL, and fail > if not? > > I've tried '(?=$|\s)' as a positive lookahead, but that always matches. > Never mind. I needed what amounts to a negative lookahead assertion in the grammar. I was thinking one level too low. So, the new term grammar would just be 'grammar + ~other_stuff'. ...Ken |
From: Kenneth L. <ke...@lo...> - 2012-08-13 15:15:10
|
HI, I've got a grammar which checks a search query to see if it is valid. The problem is that the grammar is allowing through items like 'foo:bar' as 'foo AND bar' (implicit AND). Is there a way to check that a Regex has parsed the entire term, i.e. that the next char is a space or EOL, and fail if not? I've tried '(?=$|\s)' as a positive lookahead, but that always matches. ...Ken |
From: Duncan M. <dun...@gm...> - 2012-06-14 02:41:47
|
Hello Paul and all :-) Has anyone done any work with bootstrapping one grammar with another using PyParsing? Here's a concrete example of what I'm hoping to accomplish: * I've copied the OpenBSD pf (packet filter) grammar (from its man page) * I've adapted Paul's python BNF parser example to parse it (only partially working so far) * Once it's done, I'd like to use it to create a PyParsing grammar that can parse any legal (according to the BNF) pf commands Is this even possible? Or would it be better just to create a PyParsing grammar from scratch for the 81 identities in the pf BNF...? Thanks! d |
From: Paul M. <pt...@au...> - 2012-04-28 19:06:16
|
If you want to preserve the quotation marks, then this is just how to do it. -----Original Message----- From: Sebastian Wain [mailto:seb...@ne...] Sent: Saturday, April 28, 2012 12:53 PM To: pyp...@li... Subject: Re: [Pyparsing] Issue with sexpparser example Changing the line with: qString = Group(Optional(decimal,default=None)("len") + dblQuotedString.setParseAction(removeQuotes)).setParseAction(verifyLen) to: qString = Group(Optional(decimal,default=None)("len") + dblQuotedString).setParseAction(verifyLen) Works fine. There are any other issue with this change? Thanks, Sebastian -----Original Message----- I found that parsing '(a b c)' gives the same result of parsing '(a b "c")' and this can be problematic since c is different than "c". Is that correct? I think the correct result will be to result in an string. |
From: Sebastian W. <seb...@ne...> - 2012-04-28 17:52:57
|
Changing the line with: qString = Group(Optional(decimal,default=None)("len") + dblQuotedString.setParseAction(removeQuotes)).setParseAction(verifyLen) to: qString = Group(Optional(decimal,default=None)("len") + dblQuotedString).setParseAction(verifyLen) Works fine. There are any other issue with this change? Thanks, Sebastian -----Original Message----- From: Sebastian Wain [mailto:seb...@ne...] Sent: Saturday, April 28, 2012 1:37 PM To: pyp...@li... Subject: [Pyparsing] Issue with sexpparser example Hi, I am playing with the sexpparser example by Paul. I found that parsing '(a b c)' gives the same result of parsing '(a b "c")' and this can be problematic since c is different than "c". Is that correct? I think the correct result will be to result in an string. Thanks, Sebastian ---------------------------------------------------------------------------- -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Pyparsing-users mailing list Pyp...@li... https://lists.sourceforge.net/lists/listinfo/pyparsing-users |
From: Sebastian W. <seb...@ne...> - 2012-04-28 17:04:44
|
Hi, I am playing with the sexpparser example by Paul. I found that parsing '(a b c)' gives the same result of parsing '(a b "c")' and this can be problematic since c is different than "c". Is that correct? I think the correct result will be to result in an string. Thanks, Sebastian |
From: Haq, S. <Sal...@ne...> - 2012-04-03 21:41:32
|
Hi, I am trying to write a parser that can parse various dialects of SQL. It will be formally defined for a specific, minimal dialect. Other dialects can be expected to have unrecognized tokens and can be considered supersets of the base dialect. It should be easy to define rules for the parser so that it does not choke on unrecognized tokens. I'm still reading up on PyParsing for this specific problem. I've seen various examples of simple SQL parsers implemented using PyParsing, but none that are lenient. I've also looked at PyParsing's 'makeHTMLTags' function which leniently parses HTML tags that can have arbitrary attributes. Are there other examples of lenient parsing / malformed syntax parsing that have been implemented with PyParsing? Thanks, Shaq |
From: Mario R. O. <nim...@gm...> - 2012-03-29 21:13:30
|
In the following definition; is there any way to obtain the amounts, dates and references grouped in a list or dictionary? I tried Group() and it doesn't work, single = StringStart() +\ delimitedList(Amount('amount') +\ Optional(Date)('date') +\ Optional(QuotedString(quoteChar="'"))('reference')) +\ journalName('journalName') +\ Optional(Comments)('comments') +\ StringEnd() |
From: Ralph C. <ra...@in...> - 2012-03-25 12:13:38
|
Hi Mario, > I'm new to python Welcome! > I'm having trouble with the definition of 'grant' at line 100 (the > error message is shown at the end of the paste). I haven't run the code but at first glance I see nothing wrong with your PyParsing for that bit. However, for test in tests.splitlines(): if test.strip() != '': linea = syntax.parseString(test) are you aware that foo.strip() returns a stripped foo but doesn't modify foo? IOW, foo = foo.strip() is common to see? You're passing an unstripped `test' to parseString() above which may not be what you want. Cheers, Ralph. |
From: Mario R. O. <nim...@gm...> - 2012-03-25 07:32:40
|
Hello everyone. I'm new to python and even newer to pyparsing. I pasted my code at http://pastebin.com/fS07CCZR I'm having trouble with the definition of 'grant' at line 100 (the error message is shown at the end of the paste). Here is the ebnf of what i want: <grant> ::= <> 'grant', <permission>, <user>, [',', <user>]0, <journal>, [',', <journal>]0 Can someone please exlain me what am I doing wrong here? TIA! |