bnf

bnf/ebnf for xml schema

≯℡__Kan透↙ 提交于 2019-12-07 22:54:35
问题 I'm looking for a BNF/EBNF of XML Schema. I just found the one for XML (http://www.w3.org/TR/REC-xml or extracted at http://www.jelks.nu/XML/xmlebnf.html). Well it's a starting point, but I'm curious that I couldn't find a more specific one for XML Schema. 回答1: I guess because nobody finds that useful, and it would be too complex. If somebody want to define an XML language, such as XML Schema, they would probably use XML primitives like elements or attributes (using XML Schema, Relax NG, DTD,

Grammar for expressions which disallows outer parentheses

て烟熏妆下的殇ゞ 提交于 2019-12-07 16:17:04
问题 I have the following grammar for expressions involving binary operators (| ^ & << >> + - * /): expression : expression BITWISE_OR xor_expression | xor_expression xor_expression : xor_expression BITWISE_XOR and_expression | and_expression and_expression : and_expression BITWISE_AND shift_expression | shift_expression shift_expression : shift_expression LEFT_SHIFT arith_expression | shift_expression RIGHT_SHIFT arith_expression | arith_expression arith_expression : arith_expression PLUS term |

why is `int test {}` a function definition in C language BNF

十年热恋 提交于 2019-12-07 03:37:13
问题 I'm interested in the famous The syntax of C in Backus-Naur Form and studied for a while, what confuse me is that some syntax looks wrong to me but is considered right according to the BNF. For example, int test {} , what's this? I think this is a ill syntax in C, but the truth is the BNF considered this a function definition: int -> type_const -> type_spec -> decl_specs test-> id -> direct_declarator -> declarator '{' '}' -> compound_stat decl_specs declarator compound_stat -> function

Generate BNF diagrams from an antlr grammar?

拈花ヽ惹草 提交于 2019-12-06 11:54:31
I may well be asking something not achievable here.. Maybe someone can point out either (a) What would be some steps (/tools?) to at least partially achieve creation of bnf diagrams from a (rather complex) antlr grammar (b) why (if it were the case) this simply can not be achieved. E.g. maybe since antlr is extended BNF and its recursive structure differs from bnf requirements.. Along those lines. ANTLRWorks 1 works for generating diagrams, one at a time, for rule. for v4, ANTLRWorks 2 also generates them though I'm not sure it can save them to disk. Ter If it is an ANTLR 3 grammar, you could

bnf/ebnf for xml schema

ε祈祈猫儿з 提交于 2019-12-06 09:38:34
I'm looking for a BNF/EBNF of XML Schema. I just found the one for XML ( http://www.w3.org/TR/REC-xml or extracted at http://www.jelks.nu/XML/xmlebnf.html ). Well it's a starting point, but I'm curious that I couldn't find a more specific one for XML Schema. I guess because nobody finds that useful, and it would be too complex. If somebody want to define an XML language, such as XML Schema, they would probably use XML primitives like elements or attributes (using XML Schema, Relax NG, DTD, etc.), not characters. One of the reasons XML was invented is to have a meta language for creating other

How to build parse tree?

拈花ヽ惹草 提交于 2019-12-06 07:02:10
Have found C++ BNF and there next lines selection-statement: if ( condition ) statement if ( condition ) statement else statement Now trying to write parser. Need to build parse tree. On input i have BNF and source file. But i'm stucked in how i can point my parser what if condition evaluated to true, then it need to execute first statement otherwise else block? Thanks. Conditional statements have a simple recursive structure. The corresponding recursive descent parser has a similarly simple recursive structure. Abstractly, the interior conditionals are parsed as follows: <cond> -> if

How to convert a regular grammar to regular expression?

时光总嘲笑我的痴心妄想 提交于 2019-12-06 01:59:57
问题 Is there an algorithm or tool to convert regular grammar to regular expression? 回答1: Answer from dalibocai: My goal is to convert regular grammer to DFA. Finally, I found an excellent tool : JFLAP. 回答2: The algorithm is pretty straightforward if you can compute an automaton from your regular expression. Once you have your automaton. For instance for (aa*b|c) , an automaton would be (arrows go to the right): a / \ a \ / b -> 0 ---> 1 ---> 2 -> \___________/ c Then just "enumerate" your

Grammar for expressions which disallows outer parentheses

老子叫甜甜 提交于 2019-12-05 20:22:58
I have the following grammar for expressions involving binary operators (| ^ & << >> + - * /): expression : expression BITWISE_OR xor_expression | xor_expression xor_expression : xor_expression BITWISE_XOR and_expression | and_expression and_expression : and_expression BITWISE_AND shift_expression | shift_expression shift_expression : shift_expression LEFT_SHIFT arith_expression | shift_expression RIGHT_SHIFT arith_expression | arith_expression arith_expression : arith_expression PLUS term | arith_expression MINUS term | term term : term TIMES factor | term DIVIDE factor | factor factor :

init-declarator-list and the GNU GCC attribute grammar

别来无恙 提交于 2019-12-05 09:06:27
I am revamping an inhouse C language bison/flex-based parser, amongst others introducing proper __ attribute__ support. Since I cannot find any official BNF-style grammar which describes GNU GCC __ attribute__ idea (except the http://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html document) I am extracting bits and pieces from the C++x11 standard and comments in various implementations found over the web. I have almost got it done (at least when it comes to parsing examples included in GCC's doc cited above) but one particular example has given me a headache with no hint of solution in

why is `int test {}` a function definition in C language BNF

依然范特西╮ 提交于 2019-12-05 06:52:44
I'm interested in the famous The syntax of C in Backus-Naur Form and studied for a while, what confuse me is that some syntax looks wrong to me but is considered right according to the BNF. For example, int test {} , what's this? I think this is a ill syntax in C, but the truth is the BNF considered this a function definition: int -> type_const -> type_spec -> decl_specs test-> id -> direct_declarator -> declarator '{' '}' -> compound_stat decl_specs declarator compound_stat -> function_definition I tried this with bison, it considered the input int test {} is a right form, but I tried this on