grammar

Lint-ing tool for Lua [closed]

我是研究僧i 提交于 2019-12-09 05:20:37
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . I have recently started doing a little Lua for Minecraft's mod, Computer Craft. I've always been hooked on javascript, and the tool I found the most useful was JS Lint. My question is, is there something like JS Lint that I can use to check my Lua scripts? 回答1: Lua-Checker will get the job done for you. Another

Implementing parser for markdown-like language

我的梦境 提交于 2019-12-09 04:45:03
问题 I have markup language which is similar to markdown and the one used by SO. Legacy parser was based on regexes and was complete nightmare to maintain, so I've come up with my own solution based on EBNF grammar and implemented via mxTextTools/SimpleParse. However, there are issues with some tokens which may include each other, and I don't see a 'right' way to do it. Here is part of my grammar: newline := "\r\n"/"\n"/"\r" indent := ("\r\n"/"\n"/"\r"), [ \t] number := [0-9]+ whitespace := [ \t]+

Scala Parser Combinator, Ambiguous Grammar & Parse Forest

♀尐吖头ヾ 提交于 2019-12-09 04:44:57
问题 I am trying to get the parser to return all possible parse results (parse forest) from an ambiguous grammar and choose from the parse forest by evaluating them against user context / history and a knowledge base. For performance reason, this should probably be done with the packrat parser and a search limit / upper-bound parameter to limite the number of recursive calls in applying production rules to avoid infinite loops. Being new to both Scala and its Parser Combinators, I can't figure out

Make a calculator's grammar that make a binary tree with javacc

北城余情 提交于 2019-12-09 03:51:04
问题 I need to make a simple calculator (with infix operator) parser that handle the operators +,-,*,/ and float and variable. To make this I used javacc, and I have made this grammar with jjtree. It works but it doesn't ensure that the final tree will be a binary tree, which I need. I want something like 5*3+x-y to generate the following tree : * / \ 5 + / \ 3 - / \ x y What would be a proper grammar to do that, that would not be left-recursive ? 回答1: Something like the following will give you

Using ANTLR Parser and Lexer Separatly

若如初见. 提交于 2019-12-09 03:08:00
问题 I used ANTLR version 4 for creating compiler.First Phase was the Lexer part. I created "CompilerLexer.g4" file and putted lexer rules in it.It works fine. CompilerLexer.g4: lexer grammar CompilerLexer; INT : 'int' ; //1 FLOAT : 'float' ; //2 BEGIN : 'begin' ; //3 END : 'end' ; //4 To : 'to' ; //5 NEXT : 'next' ; //6 REAL : 'real' ; //7 BOOLEAN : 'bool' ; //8 . . . NOTEQUAL : '!=' ; //46 AND : '&&' ; //47 OR : '||' ; //48 POW : '^' ; //49 ID : [a-zA-Z]+ ; //50 WS : ' ' -> channel(HIDDEN) //50

perl6 grammar , not sure about some syntax in an example

不想你离开。 提交于 2019-12-09 02:22:00
问题 I am still learning perl6, and I am reading the example on grammar from this page: http://examples.perl6.org/categories/parsers/SimpleStrings.html ; I have read the documentations on regex multiple times, but there are still some syntax that I don't understand; can anyone enlighten me? Thank you very much !!! token string { <quote> {} <quotebody($<quote>)> $<quote> } Question 1: what is this "{}" in the token doing? Capture marker is <()>, and nesting structures is tilda '(' ~ ')'; but what

Why does the C++ compiler give errors after lines instead of on them?

萝らか妹 提交于 2019-12-08 16:00:14
问题 This question popped into my head today at work when I was having yet another domestic affair with my compiler. Despite my buff pinky (due to all the semicolon pressing I do at work), I managed to miss one before an if statement. Obviously, this resulted in a compile error: error C2143: syntax error : missing ';' before 'if' So I wondered "well gee, why can't you tell me the line that's missing the semicolon instead of the line after the problem." and I proceeded to experiment with other

Where can I find Webkit's CSS grammar files? [closed]

寵の児 提交于 2019-12-08 14:24:02
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . Unlike HTML, CSS is a context free grammar. Syntax grammar is usually described in BNF or EBNF notation. According to Tali Garsiel's articke How Browsers Work, WebKit uses Flex and Bison parser generators to create parsers automatically from CSS grammar files. As Webkit is an open source project, I would expect

checking if a sentence is grammatically correct using stanford parser [duplicate]

巧了我就是萌 提交于 2019-12-08 12:56:21
问题 This question already has answers here : How to check whether a sentence is correct (simple grammar check in Python)? (2 answers) Closed 6 years ago . Is there any method to check if a sentence is grammatically correct or not using stanford parser? As of now am able to get the parse tree of a sentence using stanford parser. I got stuck here and don't know how to proceed further. 回答1: larsmans is right that those parsers are not designed for that, but here is a hack: You can try using the

Find a grammar of binary number divisible by 5 with 1 as MSB

点点圈 提交于 2019-12-08 12:41:36
How can I find a grammar of binary number divisible by 5 with 1 as MSB and find the reversal of L So, I need a grammar that generates numbers like.. 5 = 101 10 = 1010 15 = 1111 20 = 10100 25 = 110011 and so on I'm assuming this is homework and you just want a hint. Let's consider a somewhat similar question, but in base 10. How can we write a CFG for numbers divisible by 3. At first glance, this seems unlikely, but it's actually pretty simple. We start with the observation that: 10 k ≅ 1 (mod 3) for any non-negative integer k . Now consider an integer dδ , where d is a decimal digit and δ is a