bnf

How to build parse tree?

亡梦爱人 提交于 2019-12-22 14:30:11
问题 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. 回答1: Conditional statements have a simple recursive structure. The corresponding recursive descent parser has a similarly

init-declarator-list and the GNU GCC attribute grammar

ぐ巨炮叔叔 提交于 2019-12-22 06:45:09
问题 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

Use existing languages in BNF with TinyPG?

≯℡__Kan透↙ 提交于 2019-12-21 05:52:57
问题 How can I use these BNF grammars which are in GOLD meta-syntax (RegExp + BNF) with TinyPG? I'm new to BNF so approximately what sort of conversion will I have to do to convert BNF to EBNF? I believe it should be pretty simple since TinyPG needs RegExp + EBNF in comparison to the GOLD grammars which are RegExp + BNF . Also, is there any TinyPG source code for any language available, just to see what sort of conversion I would have to do? 回答1: EBNF is not entirely backwards compatible with BNF,

Use existing languages in BNF with TinyPG?

余生颓废 提交于 2019-12-21 05:52:12
问题 How can I use these BNF grammars which are in GOLD meta-syntax (RegExp + BNF) with TinyPG? I'm new to BNF so approximately what sort of conversion will I have to do to convert BNF to EBNF? I believe it should be pretty simple since TinyPG needs RegExp + EBNF in comparison to the GOLD grammars which are RegExp + BNF . Also, is there any TinyPG source code for any language available, just to see what sort of conversion I would have to do? 回答1: EBNF is not entirely backwards compatible with BNF,

EBNF or BNF for the LOGO programming language

只愿长相守 提交于 2019-12-20 12:23:47
问题 Does anyone know where I can get the BNF or EBNF for the LOGO programming language? 回答1: A BNF grammar might not be too useful in certain circumstances... Writing a LOGO that's accurately compatible with existing/historical implementation isn't an easy task (I worked on such a project). The problem is that the parser doesn't do the full job, and the evaluator (interpreter) has to work with partial data. Consider this example: proc1 a b proc2 c It could mean proc1(a, b, proc2(c)) or proc1(a, b

EBNF or BNF for the LOGO programming language

…衆ロ難τιáo~ 提交于 2019-12-20 12:22:06
问题 Does anyone know where I can get the BNF or EBNF for the LOGO programming language? 回答1: A BNF grammar might not be too useful in certain circumstances... Writing a LOGO that's accurately compatible with existing/historical implementation isn't an easy task (I worked on such a project). The problem is that the parser doesn't do the full job, and the evaluator (interpreter) has to work with partial data. Consider this example: proc1 a b proc2 c It could mean proc1(a, b, proc2(c)) or proc1(a, b

BNF vs EBNF vs ABNF: which to choose?

有些话、适合烂在心里 提交于 2019-12-20 09:48:35
问题 I want to come up with a language syntax. I have read a bit about these three, and can't really see anything that one can do that another can't. Is there any reason to use one over another? Or is it just a matter of preference? 回答1: You have to think about EBNF and ABNF as extensions that help you just to be more concise and expressive while developing your grammars. For example think about an optional non-terminal symbol, in a BNF grammar you would define it by using intermediate symbols

What do square brackets in Java method declarations mean?

放肆的年华 提交于 2019-12-19 03:45:14
问题 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? 回答1: The square brackets are to indicate the method returns

Is there a BNF mode for Emacs?

不想你离开。 提交于 2019-12-18 15:51:03
问题 I have to edit lots of grammar files in .bnf format. Is there a mode for this in Emacs? I've looked at CEDET's semantic package, and it seems that it USED to have a bnf-mode, but not any more. This snippet is googlable, but semantic-bnf-mode doesn't seem to exist: (autoload 'semantic-bnf-mode "semantic-bnf" "Mode for Bovine Normal Form." t) (add-to-list 'auto-mode-alist '("\\.bnf$" . semantic-bnf-mode)) 回答1: Thanks Don. I improved the code very slightly, here's a new version. (define-generic

Ruby Grammar

[亡魂溺海] 提交于 2019-12-17 10:21:43
问题 I'm looking for Ruby grammar in BNF form. Is there an official version? 回答1: Yes, there is one Ruby BNF syntax by the University of buffalo. Edit: I've also found this alternate Ruby BNF syntax. 回答2: The YACC syntax is in the Ruby source. Download it and run the bundled utiliy to get the readable syntax. wget ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p195.tar.gz tar xvzf ruby-2.0.0-p195.tar.gz cd ruby-2.0.0-p195 ruby sample/exyacc.rb < parse.y Output sample (total 918 lines for the v2.0