Questions tagged [instaparse]

Parser generator for context-free grammars in [tag:Clojure]. Supports EBNF and ABNF notation.

Instaparse aims to be the simplest way to build parsers in . (Source)

  • Turns standard EBNF or ABNF notation for context-free grammars into an executable parser that takes a string as an input and produces a parse tree for that string.
  • No Grammar Left Behind: Works for any context-free grammar, including left-recursive, right-recursive, and ambiguous grammars.
  • Extends the power of context-free grammars with PEG-like syntax for lookahead and negative lookahead.
  • Supports both of Clojure's most popular tree formats (hiccup and enlive) as output targets.
  • Detailed reporting of parse errors.
  • Optionally produces lazy sequence of all parses (especially useful for diagnosing and debugging ambiguous grammars).
  • "Total parsing" mode where leftover string is embedded in the parse tree.
  • Optional combinator library for building grammars programmatically.
  • Performant.
19 questions
0
votes
1 answer

Matching anything with Clojure Instaparse

I want to parse a simple language which basically has a couple of special glyphs or characters in front of a line of text. If it doesn't have these, then the line of text is just taken as data. For example : + hfflsdjf dslfhsldfh sdlfkh sdlfkhs !…
interstar
  • 26,048
  • 36
  • 112
  • 180
0
votes
1 answer

Instaparse: Is negation supported?

The - operator is supposed to support negation, but I can't get it to work: raw-type = "DINT" | "REAL" | "SINT" | "BIT" custom-type = - raw-type Every time I try I get the error: RuntimeException - occurs on the right-hand side of your grammar, but…
Chris Murphy
  • 6,411
  • 1
  • 24
  • 42
0
votes
1 answer

Instaparse: there's an error but it is not reported

I am trying to build up a grammar with Instaparse. Quite often I find that this code fails the first assertion, emitting "Empty list": (defn parse-it [] (let [parser (insta/parser ebnf) res (insta/parses parser input) _ (assert…
Chris Murphy
  • 6,411
  • 1
  • 24
  • 42
0
votes
2 answers

Instaparse: How to recognise a newline

I want to parse the text of a file that contains newlines. The file could be in Windows or Unix, but for now it is a Windows file with this contents: (************** ***************) The above file contents has been read in with slurp and will…
Chris Murphy
  • 6,411
  • 1
  • 24
  • 42
1
2