New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stuck at step 0 #50
Comments
Okay, I finally got it to work with this: parser.ne
grammar.js // Generated automatically by nearley
// http://github.com/Hardmath123/nearley
(function () {
function id(x) {return x[0]; }
var grammar = {
ParserRules: [
{"name": "letter", "symbols": [" ebnf$1"]},
{"name": " ebnf$1", "symbols": [/[a-zA-Z]/]},
{"name": " ebnf$1", "symbols": [/[a-zA-Z]/, " ebnf$1"], "postprocess": function (d) {
return [d[0]].concat(d[1]);
}}
]
, ParserStart: "letter"
}
if (typeof module !== 'undefined'&& typeof module.exports !== 'undefined') {
module.exports = grammar;
} else {
window.grammar = grammar;
}
})(); Input: So maybe the problem is simply that none of the .ne files actually work with the current version of nearley? Or maybe I keep pasting in code they don't actually recognize? I tried single-line Lua statements with no success. |
Hmm, I'd need more code samples to try and guess what the issue is. |
To be fair, I'm not a Lua programmer, so there could be code constructs needed there that I'm not aware of. I was cutting / pasting different samples. For the CSV, I tried something like The javascript.ne error is:
|
Weird… I don't think the format has changed enough to outdate those examples. Have you tried using the precompiled versions in |
Did just now. The precompiled javascript.js works just fine. (Well, parses anyway.) |
Weeeeeeird. Freshly-compiled versions of the Lua grammar and the JS grammar work perfectly for me.
|
Like I said, maybe all my cut-and-pasted lua examples sucked somehow. But definitely javascript.ne was throwing an error. What about node version? Might that be an issue? Also, I did get some warnings when installing dependencies for nearley.
|
I believe those warnings are generic npm warnings being thrown about non-nearley modules (npm thinks it's a good idea to warn you about them even though you don't care about them right now). I tried reinstalling nearley, and I got a completely different set of such warnings. Nothing to worry about. I'm using nodejs for all testing. If your testing is happening in the browser, then things are slightly different because namespacing. What's your test setup like? |
Sorry for the lag in reply. My test setup is using node-webkit, so yes, the nearley module is running in a node context, and I'm just using the webkit part so I can put in new input and keep testing. I think the hardest part is that if there's any error in parsing anywhere, it simply says "error at character 0". There's no information about where, in the set of grammar, it might cause a parsing error. I mean, I guess I'm assuming it's a parsing error of the input, and not simply that the input doesn't match. Either way, the error doesn't help in figuring out what to do next. |
I'm trying to write a grammar parser for Less (Lesscss.org), and I'm starting with the documented grammar for CSS, and then adapting it to nearley. I'm just going to post what I got.
It compiles successfully to grammar.js, but thus far I haven't been able to get it to recognize any valid CSS. Are you able to help me identify the problem? Much appreciated. |
Actually, it does mean that the input doesn't match. Your problem might be that you're using 2-digit unicode values. Try adding Similarly, I'm not sure what |
Alright, I've done the following:
Result:
Error at character 0
Since I'm using all the code provided here, I'm perplexed as to what the problem could be. Even a simple, one-line grammar file fails to actually parse anything. Sooo..... o_O ?
The text was updated successfully, but these errors were encountered: