Question: an analog of Positioned from Sprache?
See original GitHub issueIn Sprache, you provided IPositionAware
and Positioned
to make a parse result, well, aware of the position it’s parsed. I see this feature useful for giving a precise position of some syntax construct in post-parse checks (like, “this variable right here wasn’t declared” vs. the same without being able to report a position to the user, so they would have to search that place for themselves).
There is Result<T>.Location
, but I don’t see how I could apply that to the resulting value via combinators. Could I achive it here, and which way you’d advice to do it best? (Or if maybe I’m looking for the wrong thing, and the thing mentioned should be done another way.)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Why is the word for 'language' in German 'sprache' but 'taal ...
It comes from the Middle Low German word for 'German', 'Düdesch', which in Modern High German is 'Deutsch', but 2500 years ago was...
Read more >The Syntax of Question Particles
Julien (2001), Lee (2005, 2008) and Simpson & Wu (2002) argue that final particles are derived by TP-‐movement to a Topic or Focus...
Read more >Prosodic Prominence in Polar Questions and Exclamatives
This study investigates prosodic prominence in string-identical verb-first exclamatives and questions in German. It presents results from ...
Read more >overt analogue criterion
Position of the definiens. principle that a zero morpheme may not be postulated in a language unless there is an overt morpheme that...
Read more >German Word Order in Main Clauses (Hauptsätze)
German ears prefer pronouns to precede nouns wherever possible, even when the noun is the subject in "third position". Thus "Der Mann rasiert...
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
Hi!
There’s no built-in combinator; I think it would be reasonably easy to write one, using similar tactics to Sprache’s implementation - keen to explore how it might look.
If you want to drop this into your own project I think it’s roughly:
(Sketched in browser, no idea whether or not this will compile as-is 😉)
HTH, Nick
Hi @JoeMGomes - unfortunately no time to dig in properly but hopefully this helps:
The start index of the match within the input will be
inner.Location.First().Position.Absolute
.The exclusive end index will be
inner.Remainder.First().Position.Absolute
.In the second case it’s also possible that the remainder token list will be empty, which would mean “matched until end of stream”.