bnf

Is a JavaScript function call a LeftHandSideExpression, thus an ExpressionStatement?

99封情书 提交于 2019-12-02 02:06:01
问题 I'm trying to prove that a simple function call such as window.alert(); is valid EcmaScript 2016 (7th Edition) grammar. Working backward, with the expectation this is an ExpressionStatement , I see that it fits the pattern MemberExpression Arguments which is a CallExpression . And, section 12.3 defines LeftHandSideExpression as possibly a CallExpression . Now, my problem is that section 12.15 AssignmentExpression seems to require that LeftHandSideExpression be followed by either an

Is it easier to write a recursive-descent parser using an EBNF or a BNF?

自作多情 提交于 2019-12-01 08:29:07
I've got a BNF and EBNF for a grammar. The BNF is obviously more verbose. I have a fairly good idea as far as using the BNF to build a recursive-descent parser; there are many resources for this. I am having trouble finding resources to convert an EBNF to a recursive-descent parser. Is this because it's more difficult? I recall from my CS theory classes that we went over EBNFs, but we didn't go over converting them into a recursive-descent parser. We did go over converting BNF's into a recursive-descent parser. The reason I'm asking is because the EBNF is more compact. From looking at the EBNF

Is it easier to write a recursive-descent parser using an EBNF or a BNF?

心已入冬 提交于 2019-12-01 06:46:15
问题 I've got a BNF and EBNF for a grammar. The BNF is obviously more verbose. I have a fairly good idea as far as using the BNF to build a recursive-descent parser; there are many resources for this. I am having trouble finding resources to convert an EBNF to a recursive-descent parser. Is this because it's more difficult? I recall from my CS theory classes that we went over EBNFs, but we didn't go over converting them into a recursive-descent parser. We did go over converting BNF's into a

Are there tools to convert between ANTLR and other forms of BNF?

久未见 提交于 2019-12-01 03:23:41
Are there any tools to convert ANTLR grammar syntax to and from other BNF syntaxes? There are several forms Backus-Naur Form (BNF, EBNF, ABNF, W3C-BNF, XBNF...) with specification, e.g. see this list . The ANTLR grammar syntax only seems to be described by examples . I know that ANTLR grammar files contain more than the specification of a context-free syntax, but you should be able to convert at least the common subset - has anyone done yet automatically? Jakob wrote: The ANTLR grammar syntax only seems to be described by examples. ANTLR (v3) is written "in its own words" (as Terence Parr

What is the easiest way of telling whether a BNF grammar is ambiguous or not?

怎甘沉沦 提交于 2019-12-01 03:10:35
Namely, is there a tool out there that will automatically show the full language for a given grammar, including highlighting ambiguities (if any)? There might be some peculiarity about BNF-style grammars, but in general, deciding whether a given context-free grammar (such as BNF) is ambiguous is not possible. In short, there does not exist a tool because in general, that tool is mathematically impossible. There might be some special cases that could work for you, though. In general, no. But as a practical approach, what you can do, is given a grammar, is for each rule, to enumerate possible

Are there tools to convert between ANTLR and other forms of BNF?

可紊 提交于 2019-12-01 00:34:59
问题 Are there any tools to convert ANTLR grammar syntax to and from other BNF syntaxes? There are several forms Backus-Naur Form (BNF, EBNF, ABNF, W3C-BNF, XBNF...) with specification, e.g. see this list. The ANTLR grammar syntax only seems to be described by examples. I know that ANTLR grammar files contain more than the specification of a context-free syntax, but you should be able to convert at least the common subset - has anyone done yet automatically? 回答1: Jakob wrote: The ANTLR grammar

What is the easiest way of telling whether a BNF grammar is ambiguous or not?

梦想与她 提交于 2019-11-30 23:13:14
问题 Namely, is there a tool out there that will automatically show the full language for a given grammar, including highlighting ambiguities (if any)? 回答1: There might be some peculiarity about BNF-style grammars, but in general, deciding whether a given context-free grammar (such as BNF) is ambiguous is not possible. In short, there does not exist a tool because in general, that tool is mathematically impossible. There might be some special cases that could work for you, though. 回答2: In general,

What do square brackets in Java method declarations mean?

陌路散爱 提交于 2019-11-30 21:51:49
The grammar for method declarations in Java is something like the following: Java method declaration BNF: method_declaration ::= { modifier } type identifier "(" [ parameter_list ] ")" { "[" "]" } ( statement_block | ";" ) And I am wondering what do the square brackets mean. Can anyone give me an example? Is method declarations in Java looks like above (What about generics)? Where can I find complete and actual BNF grammar for Java? The square brackets are to indicate the method returns an array. For example, you can write a method that returns an array of int as: int method()[] { … } Many

Scala Parser Token Delimiter Problem

本秂侑毒 提交于 2019-11-30 19:20:34
I'm trying to define a grammar for the commands below. object ParserWorkshop { def main(args: Array[String]) = { ChoiceParser("todo link todo to database") ChoiceParser("todo link todo to database deadline: next tuesday context: app.model") } } The second command should be tokenized as: action = todo message = link todo to database properties = [deadline: next tuesday, context: app.model] When I run this input on the grammar defined below, I receive the following error message: [1.27] parsed: Command(todo,link todo to database,List()) [1.36] failure: string matching regex `\z' expected but `:'

Is there a formal (ideally BNF) typescript js language grammar (or only typescript subset)?

好久不见. 提交于 2019-11-30 05:14:05
I'm looking for the Typescript grammar. Not the parser-lexer, but only the formal grammar description. I want to implement ts it's code folding and basic static code analyzing as plugin to one simple linux IDE for GNOME. Tony BenBrahim The formal grammar is in Appendix A of the TypeScript Language Reference, version 1.8 if which is found here or here (for current version) Since typescript is a strict superset of Ecmascript 5 (http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf/), you could exend any ecmascript bnf with syntax definitions from the Typescript spec. A