instaparse

If you're not trampolining your parser, why bother getting up in the morning?
seylerius 2016-07-07T06:05:26.000081Z

@aengelberg: Any particular instaparse way to go multi-line, or just specify it in the regexps?

aengelberg 2016-07-07T17:10:08.000082Z

@seylerius not sure what exactly you're confused about, but here are some examples: imagine you're parsing the following input:

aaaa
bbb
cccccc
the grammar could look like
S = A '\n' B '\n' C
A = 'a'+
B = 'b'+
C = 'c'+

aengelberg 2016-07-07T17:10:45.000083Z

or

S = #'a+\n' #'b+\n' #'c+'

aengelberg 2016-07-07T17:11:45.000084Z

either \n or \\n would work if you are inside a Clojure string.

aengelberg 2016-07-07T17:13:32.000085Z

S = A ows B ows C
A = 'a'+
B = 'b'+
C = 'c'+
(* optional whitespace *)
<ows> = <#'\s*'>

aengelberg 2016-07-07T17:13:57.000086Z

For that example, inside a Clojure string you would need to change \s to \\s.

seylerius 2016-07-07T17:42:14.000087Z

@aengelberg: Also, how would you modify what would normally be a .* to not eat an optional :[a-zA-Z0-9_@]+:([a-zA-Z0-9_@]+:)* that follows it? Or would you just post-process that out after?

aengelberg 2016-07-07T17:44:36.000088Z

so you're trying to parse #"shown-part hidden-part" but only return "shown-part" in the parse result?

aengelberg 2016-07-07T17:46:57.000089Z

you could use the regex lookahead to omit it from the result, but then actually parse it (with instaparse's <> hiding feature) in order to properly advance the parser.

S = #'shown-part(?=hidden-part)' <#'hidden-part'>

aengelberg 2016-07-07T17:50:29.000090Z

or unhide the second #'hidden-part' if you actually do want it in the parse tree, but separate from #'shown-part'.

seylerius 2016-07-07T18:39:16.000091Z

@aengelberg: More like org-mode headlines allow tags at the end in that style. Not hidden so much as separate.