I'm trying to extend the example grammar of PEG.js for parsing mathematical expressions with all the 4 operators for my online BASIC interpreter experiment:  http://www.dantonag.it/basicjs/basicjs.html  but not all the expressions are parsed corr...
How do you build an AST (Abstract Syntax Tree) for left-associative operators using PEG.js?  I've tried to write some code based on the information I found on the internet, but I seem to have made a mistake.  The code I wrote generates an incorre...
I have essentially the same question as PEG for Python style indentation, but I'd like to get a little more direction regarding this answer.  The answer successfully generates an array of strings that are each line of input with 'INDENT'...
I'm trying to build a simple parser with PEG.js.  I want the user to be able to input a series of keywords, with an optional "AND" between them, but I can't seem to get the optional and working.  It always expects it, even though I...
I'm playing around with PEG.js  start = keyword  keyword = a:[a-z]? {return a.join("");}   Why am I getting here the error:     a.join is not a function   when I enter a valid string like abc?...
I'm trying to catch some text between parathesis with a semicolon in the end.  Example: (in here there can be 'anything' !"#¤);); any character is possible);  I've tried this:  Text  = "(" text:(.*) ");" { return...
How can I read the file within my language?  I am trying to understand how languages ??work. I would like to know how to create a simple grammar to read files using Peg.js. In Python it is something like this  f= open("testfile.txt","w+&#...
I am having trouble defining an expression that allows any text between two tags (including those tags).  Examples:  #ifdef  asdasdasdasdasdsasd asdasdasdasdasdasdasd asdasdasdasdasdasasd #endif   It should also allow  #ifdef asdasdasd asdasdsad #ifd...
I'm new to the world of formal grammars. I tried to use ANTLR for JS but couldn't figure out how to run the parser. I'm trying to develop a grammar for a DSL on PEG.js and this is what I have (http://peg.arcanis.fr/3T2PKD/):  start    = e...
Given the input <outer> Content <inner> Inner <single/> </inner> </outer>.  How would I write grammar that parses the <single> node along with the nodes that have a matching closing node?  Here's my current gra...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.