grammar

Lint-ing tool for Lua [closed]

余生颓废 提交于 2019-12-03 06:04:56
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? Lua-Checker will get the job done for you. Another tool is Lua Lint There is also lua-inspect . I integrated it into ZeroBrane Studio IDE and extended the list of potential problems it reports. Here is the subset of what gets reported from one of my tests: inspect.lua(1): first assignment to global variable 'f' inspect.lua(2): first use of

Haskell Precedence: Lambda and operator

喜夏-厌秋 提交于 2019-12-03 04:57:06
I found precedence and associativity is a big obstacle for me to understand what the grammar is trying to express at first glance to haskell code. For example, blockyPlain :: Monad m => m t -> m t1 -> m (t, t1) blockyPlain xs ys = xs >>= \x -> ys >>= \y -> return (x, y) By experiment, I finally got it means, blockyPlain xs ys = xs >>= (\x -> (ys >>= (\y -> return (x, y)))) instead of blockyPlain xs ys = xs >>= (\x -> ys) >>= (\y -> return (x, y)) Which works as: *Main> blockyPlain [1,2,3] [4,5,6] [(1,4),(1,5),(1,6),(2,4),(2,5),(2,6),(3,4),(3,5),(3,6)] I can get info from ghci for (>>=) as an

W3C CSS grammar, syntax oddities

折月煮酒 提交于 2019-12-03 04:33:27
问题 I was having a look at the CSS syntax here and here and I was amazed to see both the token productions and the grammar littered with whitespace declarations. Normally whitespace is defined once in the lexer and skipped, never to be seen again. Ditto comments. I imagine the orientation towards user-agents rather than true compilers is part of the motivation here, and also the requirement to proceed in the face of errors, but it still seems pretty odd. Are real-life UAs that parse CSS really

How can I incorporate ternary operators into a precedence climbing algorithm?

本秂侑毒 提交于 2019-12-03 04:22:42
问题 I followed the explanation given in the "Precedence climbing" section on this webpage to implement an arithmetic evaluator using the precedence climbing algorithm with various unary prefix and binary infix operators. I would also like to include ternary operators (namely the ternary conditional operator ?: ). The algorithm given on the webpage uses the following grammar: E --> Exp(0) Exp(p) --> P {B Exp(q)} P --> U Exp(q) | "(" E ")" | v B --> "+" | "-" | "*" |"/" | "^" | "||" | "&&" | "=" U

ANTLR: call a rule from a different grammar

China☆狼群 提交于 2019-12-03 04:18:35
is it possible to invoke a rule from a different grammar? the purpose is to have two languages in the same file, the second language starting by an (begin ...) where ... is in the second language. the grammar should invoke another grammar to parse that second language. for example: grammar A; start_rule : '(' 'begin' B.program ')' //or something like that ; grammar B; program : something* EOF ; something : ... ; Your question could be interpreted in (at least) two ways: separate rules from a large grammar into separate grammars; parse a separate language inside your "main" language (island

Using adaptive grammars [closed]

穿精又带淫゛_ 提交于 2019-12-03 03:17:14
Closed. This question is off-topic. It is not currently accepting answers. Learn more . Want to improve this question? Update the question so it's on-topic for Stack Overflow. I'm trying to implement a language (or family of languages) whose grammar can be changed dynamically. I have found no examples that serve as study cases. Can you give me some reference to any that are actually used in the real world (even from the academic world)? Does it make sense to implement a Domain-Specific Languages with a dynamic grammar? The most famous current language that has a dynamic syntax is Perl6 . The

Implementing parser for markdown-like language

别等时光非礼了梦想. 提交于 2019-12-03 03:16:19
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]+ symbol_mark := [*_>#`%] symbol_mark_noa := [_>#`%] symbol_mark_nou := [*>#`%] symbol_mark_nop := [*_>#

Combining a Tokenizer into a Grammar and Parser with NLTK

二次信任 提交于 2019-12-03 03:11:42
问题 I am making my way through the NLTK book and I can't seem to do something that would appear to be a natural first step for building a decent grammar. My goal is to build a grammar for a particular text corpus. (Initial question: Should I even try to start a grammar from scratch or should I start with a predefined grammar? If I should start with another grammar, which is a good one to start with for English?) Suppose I have the following simple grammar: simple_grammar = nltk.parse_cfg(""" S ->

How do Java, C++, C#, etc. get around this particular syntactic ambiguity with < and >?

老子叫甜甜 提交于 2019-12-03 03:10:12
问题 I used to think C++ was the "weird" one with all the ambiguities with < and > , but after trying to implement a parser I think I found an example which breaks just about every language that uses < and > for generic types: f(g<h, i>(j)); This could be syntactically either interpreted as a generic method call ( g ), or it could be interpreted as giving f the results of two comparisons. How do such languages (especially Java, which I thought was supposed to be LALR(1)-parsable?) get around this

Looking for a Complete Delphi (object pascal) syntax

孤街浪徒 提交于 2019-12-03 02:20:00
问题 I need a complete Object Pascal syntax (preferably Delphi 2009). Some of the syntax is given by the help files, but not all information is provided. So I started collecting loose bits of information. Recently I added these to a more or less complete syntax description (EBNF like). Although it looks extensive, there are still bugs and I'm sure parts are missing (specially in the .NET syntax). So I'm asking the SO Delphi community. Do you have any information or can you correct the errors? In