Questions tagged [superpower]

SuperPower is a parser combinator library based on Sprache. Superpower generates friendlier error messages through its support for token-based parsers.

23 questions
8
votes
2 answers

Parsing a simple text grammar with Superpower

I'm trying to create a parser with Superpower. I have already taken a look to the samples I've found in the repo, but they are a bit difficult to understand, at least for a beginner like me :) So I came with this little challenge. I have invented a…
SuperJMN
  • 13,110
  • 16
  • 86
  • 185
4
votes
1 answer

Superpower parser for nested string representation of object tree

I'm struggling to understand how recursive parsing works in Superpower. I've studied the blog posts and the examples on github but still don't understand. Can somebody tell me how, from the Tokenizer I wrote, I could rebuild the AST with the…
3
votes
0 answers

Is there any GLL parser combinator library in C# / Java?

I'm really interested in parser combinators, especially those who can deal with left-recursive and ambiguous grammars. I know the fabulous Superpower by Nicholas Blumhardt but it's unable to deal with this kind of grammars. I've found some GLL…
SuperJMN
  • 13,110
  • 16
  • 86
  • 185
2
votes
1 answer

Superpower: match a string with tokenizer only if it begins a line

When tokenizing in superpower, how to match a string only if it is the first thing in a line (note: this is a different question than this one) ? For example, assume I have a language with only the following 4 characters (' ', ':', 'X', 'Y'), each…
rednoyz
  • 1,318
  • 10
  • 24
2
votes
1 answer

Superpower parser for balanced nested parentheses

I'm struggling to come up with a superpower parser for the set of partial inputs below (nested, balanced parentheses with '|' separator). Arbitrary text can go inside the parens, including whitespace, other tokens, and "()". Only '|', '(', ')',…
rednoyz
  • 1,318
  • 10
  • 24
2
votes
0 answers

Superpower parsing delimited list of strings

I am having a problem parsing a list of of strings: syntax: "stringlist intersects ('string1','string2')" This is tokenised to: Token.Identifier, Token.Intersects, Token.LParen Token.StringValue, Token.Comma, Token.StringValue Token.RParen My…
Akilawani
  • 29
  • 3
1
vote
0 answers

Using superpower to parse simple block oriented data structures

I could use some hints to start writing a simple parser using C# (preferably superpower or perhaps sprache) to parse files defining some simple structures like: Header HeaderDataItem1 "Value of item 1" HeaderDataItem2 "Value of item 2" End…
EuroEager
  • 167
  • 1
  • 2
  • 11
1
vote
0 answers

How to ignore tokens until a certain token pattern is found in Superpower C#?

I am trying to parse objects that are interspersed with functions, and I want to skip the functions. The structure is: /datum/chemical_reaction/reagent_explosion name = "Generic explosive" id = "reagent_explosion" var/strengthdiv = 10 …
Redline
  • 441
  • 8
  • 20
1
vote
1 answer

Unable to combine 2 Superpower TextParser with Or with Span

I have 2 Superpower TextParser - each targets to parse a certain input - differentiated by prefix and parameters. I am trying to create a combined parser that gives out the result when either of the TextParser can parse the input. The output is a…
cppxaxa
  • 135
  • 1
  • 9
1
vote
2 answers

Superpower: Match any not white character except for tokenizer

I would like to use the Nuget package Superpower to match all non-white characters unless it is a tokenized value. E.g., var s = "some random text{variable}"; Should result in: ["some", "random", "text", "variable"] But what I have now…
Jon49
  • 4,444
  • 4
  • 36
  • 73
1
vote
0 answers

Tree of unary operators

I want to parse expressions like a ++a a++ ++a++ ++a++++ The pre-increment operator has precedence over the post-increment operator. The parsers I have are these: public static readonly TokenListParser Increment =…
SuperJMN
  • 13,110
  • 16
  • 86
  • 185
1
vote
1 answer

Get string from Keyword in SuperPower

I'm working on a simple scripting language for a work project and I need to create a definition statement of the form type name = value. I've been following the SuperpowerSimpleSql example and have created the tokenizer, which is correctly…
RPiAwesomeness
  • 5,009
  • 10
  • 34
  • 52
0
votes
1 answer

Unable to parse expression with ambiguity expression

Good day I have simple grammar which describe columns for select. User can specify simple column name, column name and subcolumns for them (and so on), or use '*' to select all fields. Some example: exp = "(Id)" - select only Id column exp =…
0
votes
1 answer

Parse string between a pair of delimiters (that are strings)

I would like to create a parser using Superpower to match strings like: <> That is, a string delimited by a pair of strings (left and right). In this case, the delimiting strings are << and >>. For now, all I've got is a parser that…
SuperJMN
  • 13,110
  • 16
  • 86
  • 185
0
votes
1 answer

Superpower Parser: Deal with partial match of a sub parser in a combinator?

So I have written a parser for a proprietary file type. I am 95% there, but my parser is failing on the last line of the file which is a #. This is a partial match for several other parsers. It looks like it tries to parse the line as a PropertyList…
TheColonel26
  • 2,618
  • 7
  • 25
  • 50
1
2