Question
See original GitHub issueHello!
First of all let me thank you for your amazing library and willingness to answer questions 🎉
I am trying to write a parser that looks like this
type Result = { kind: 'BrackedText', text: string } | { kind: 'Text', text: string }
const result: Result[] = alt(
seq(string('['), letters, string(']')).map<Result>(...),
i_dont_know.map<Result>(...)
).many().tryParse(input)
And I expect it to parse string "Hey [hello] how are [world] you?"
into the following
[
{ kind: 'Text', text: 'hey ' },
{ kind: 'BrackedText', text: 'hello' },
{ kind: 'Text', text: ' how are ' },
{ kind: 'BrackedText', text: 'world' },
{ kind: 'Text', text: ' you?' },
]
Basically I want the entire parser to work so, that it parses pieces of string in between BrackedText
as just strings regardless of what they contain. But I am stuck writing i_dont_know
parser.
This is a very simplified example. In reality I have several different kind of structures instead of BrackedText
which I want to parse. So writing parser takeWhile(x => x !== '[')
wont do the trick.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9
Top Results From Across the Web
System Of A Down - Question! (Official HD Video) - YouTube
Official HD music video for ” Question !" by System of a DownListen to System of a Down: https://SystemOfADown.lnk.to/listenYDSubscribe to the ...
Read more >Question Definition & Meaning - Merriam-Webster
noun ; b · a subject or aspect in dispute or open for discussion : issue ; d · the specific point at...
Read more >Question Definition & Meaning | Dictionary.com
a problem for discussion or under discussion; a matter for investigation. a matter of some uncertainty or difficulty; problem (usually followed by of):...
Read more >Meaning of question in English - Cambridge Dictionary
a sentence or phrase used to find out information: The police asked me questions all day. Why won't you answer my question?
Read more >Question - Wikipedia
A question is an utterance which serves as a request for information. Questions are sometimes distinguished from interrogatives, which are the grammatical ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Something like this should work. Click “Run” to see the results.
https://runkit.com/wavebeem/parsimmon-issues-316
You could make it faster using a custom regexp for
other
that matches more characters at a time, but this is the easiest approach.Yeah, the regexp solution is often difficult, haha.
All I meant was that bread-n-butter is SemVer 0.x, so releases may contain breaking changes. Maybe I will update that text later 😃