-
Notifications
You must be signed in to change notification settings - Fork 15
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
Sample Usage of Myna in TypeScript #23
Comments
All JavaScript is also valid TypeScript, so you can start by just renaming the file from .js to .ts. For more information perhaps see: https://www.typescriptlang.org/docs/handbook/migrating-from-javascript.html. It depends on how strict your TypeScript is, I suppose. I've never really tried. If you give it a shot, let me know how it works, and I can help you out with specific issues along the way. |
Not sure that property chaining is the problem there, you are missing a closing parentheses. If you fix that, what happens next? |
error TS2339: Property 'opt' does not exist on type 'Rule'. |
This seems like a configuration problem: the opt property does exists on Rule: https://github.com/cdiggins/myna-parser/blob/master/myna.ts#L343. I'll be honest, this kind of silliness, is why I stopped coding in TypeScript, and went back to C#. |
I think the language and tooling for TypeScript is mediocre. |
Following code works without error in my env. ( import { Myna } from "myna-parser";
export class MyGrammar {
public fraction: Myna.Rule = Myna.seq(".", Myna.digit.zeroOrMore).ast;
public number: Myna.Rule = Myna.seq(Myna.integer, this.fraction.opt).ast;
public plainText: Myna.Rule = Myna.notChar("\n\r").oneOrMore;
public document: Myna.Rule = Myna.choice(this.plainText, this.number)
.zeroOrMore;
}
const myGrammar = new MyGrammar();
const input = "11111";
const ast = Myna.parse(myGrammar.document, input);
console.log(ast); |
How would you create grammar_markdown.js in TypeScript?
The text was updated successfully, but these errors were encountered: