Line:column for embedded languages
See original GitHub issueQuestion: how to address line:column
mismatches for embedded languages?
For example, I have the following file:
---
foo: bar
---
Baz
in FrontMatter format and the following parser, working with fm.body
:
let P = require("parsimmon")
let s = `
Baz
`
let lang = P.createLanguage({
Baz: function (L) {
return P.string("Baz+").trim(P.optWhitespace)
},
})
console.log(lang.Baz.tryParse(s))
The error says:
Error: expected 'Baz+' at line 2 column 1, got '...Baz
While the real line, as the user perceives it is 5
. The solution of catching and parsing exception messages with .replace(/line (\d+)/, "...")
is obviously a last resort hack. Those messages aren’t an API part and can be changed any day.
What should we do instead, ideally? Accept some parser options?
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
A list of embedded scripting languages - GitHub
Project name/link Implementation language GC
AbcDatalog Java JVM's GC
AngelScript C++ Ref. counting + cycle‑detecting tracing GC
Anko Go Go's GC
Read more >Embedded Software Programming Languages: Pros, Cons ...
Learn about programming languages for embedded systems, pros & cons of popular languages, download a comparison table, and expert advice.
Read more >Top 10 Best Embedded Systems Programming Languages
This article deals with programming languages for Embedded Systems. And also Bollywood… Why Bollywood you ask? Well, that's because Embedded ...
Read more >Top 17 Programming Languages for Embedded Systems Work
As with so many other arenas, Python, C, and C++ are immensely useful when it comes to embedded systems, although many lesser-known languages...
Read more >Embedded software programming languages you should learn
Learn which software programming languages you should consider learning if you're interested in a career in embedded software development.
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
Yeah, I thought of this version but wanted to avoid writing a YAML parser.
Now I see I can create just-an-FM parser like:
combined with body parser as you said.
Then parse YAML with a 3-rd party lib after that, on a separate step. That would raise the original problem again, now for the YAML, which would be 1 line shifted from it’s initial position. But then I can spoof it by adding one empty line to the YAML before parsing. Problem solved 😃
Like instead of doing:
You could do like:
or something like that?