question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Better documentation for `createLanguage` and `lazy`

See original GitHub issue

I’d like to create a parameterized parser, much like many of the built in parser combinators (eg seq or string). I was a little confused as to why I couldn’t call the parser functions I defined with createLanguage as functions (I found out they’re not functions).

It would be nice to be able to do something like:

var L = Parsimmon.createLanguage({
   oneThenAnother: function(a,b) {
       return Parsimmon.seq(a,b)
   },
   something: function() {
       return L.oneThenAnother(string("a"),string("b"))
   }
})

But it seems the only parameter that parser functions created by createLanguage get is the language namespace that I already have access to via L. So it makes me wonder, why am I using createLangauge at all? I don’t quite understand the importance of the Lazy and createLanguage functions, which would help clarify this situation: https://github.com/jneen/parsimmon/issues/202.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:48 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
wavebeemcommented, Oct 2, 2017

Ah, I see. In that case you’d need something like this:

something: function() {
  return this.whitespace().chain(() => {
       const x = withState({line: this.line, this.column})
        return P.seq(
          x.statement(),
          x.whitespace()
       )
 })
}

Since withState returns a new Language you would have to chain off of the new object.

1reaction
wavebeemcommented, Sep 29, 2017

I should probably have some time tonight to make a branch with an example of what I mean for a (optionally) stateful and consistent replacement for createLanguage.

Read more comments on GitHub >

github_iconTop Results From Across the Web

parsimmon/API.md at master - GitHub
createLanguage is the best starting point for building a language parser in Parsimmon. It organizes all of your parsers, collects them into a...
Read more >
Translation | Django documentation
In this case, the lazy translations in result will only be converted to strings when result itself is used in a string (usually...
Read more >
Chapter 19: Internationalization - The Django Book
Django also ships with more than 50 different localization files. If you're not a native English speaker, ... Always use lazy translations in...
Read more >
Configuration Parameters | Tanzu Greenplum Docs
Larger values may improve the quality of the Postgres Planner estimates. ... of the segment file when VACUUM is run without the FULL...
Read more >
Oracle Text - Technical Overviews
Oracle Text - Technical Overviews. These technical overviews provide a developer-view of features in Oracle Text. They were originally released to cover the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found