bnf

Ruby Grammar

回眸只為那壹抹淺笑 提交于 2019-11-27 11:13:08
I'm looking for Ruby grammar in BNF form. Is there an official version? Adrian Grigore Yes, there is one Ruby BNF syntax by the University of buffalo. Edit: I've also found this alternate Ruby BNF syntax . 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.0-p195) program : top_compstmt ; top_compstmt : top_stmts opt_terms ; top_stmts : none | top

A yacc shift/reduce conflict on an unambiguous grammar

陌路散爱 提交于 2019-11-27 07:28:04
问题 A piece of code of my gramamar its driveing me crazy. I have to write a grammar that allow write functions with multiple inputs e.g. function begin a: <statments> b: <statements> end The problem with that its that is statements that are assignments like this ID = Expresion. in the following quote you can see the output produced by yacc. 0 $accept : InstanciasFuncion $end 1 InstanciasFuncion : InstanciasFuncion InstanciaFuncion 2 | InstanciaFuncion 3 InstanciaFuncion : PuntoEntrada Sentencias

What is a regular language?

社会主义新天地 提交于 2019-11-27 04:09:07
问题 I'm trying to understand the concept of languages levels (regular, context free, context sensitive, etc.). I can look this up easily, but all explanations I find are a load of symbols and talk about sets . I have two questions: Can you describe in words what a regular language is, and how the languages differ? Where do people learn to understand this stuff? As I understand it, it is formal mathematics? I had a couple of courses at uni which used it and barely anyone understood it as the

How to convert BNF to EBNF

心不动则不痛 提交于 2019-11-27 02:06:43
How can I convert this BNF to EBNF? <vardec> ::= var <vardeclist>; <vardeclist> ::= <varandtype> {;<varandtype>} <varandtype> ::= <ident> {,<ident>} : <typespec> <ident> ::= <letter> {<idchar>} <idchar> ::= <letter> | <digit> | _ EBNF or Extended Backus-Naur Form is ISO 14977:1996 , and is available in PDF from ISO for free * . It is not widely used by the computer language standards. There's also a paper that describes it, and that paper contains this table summarizing EBNF notation. Table 1: Extended BNF Extended BNF Operator Meaning ----------------------------------------------------------

Z80 ASM BNF structure… am I on the right track?

為{幸葍}努か 提交于 2019-11-27 01:59:45
I'm trying to learn BNF and attempting to assemble some Z80 ASM code. Since I'm new to both fields, my question is, am I even on the right track? I am trying to write the format of Z80 ASM as EBNF so that I can then figure out where to go from there to create machine code from the source. At the moment I have the following: Assignment = Identifier, ":" ; Instruction = Opcode, [ Operand ], [ Operand ] ; Operand = Identifier | Something* ; Something* = "(" , Identifier, ")" ; Identifier = Alpha, { Numeric | Alpha } ; Opcode = Alpha, Alpha ; Int = [ "-" ], Numeric, { Numeric } ; Alpha = "A" | "B"

How to determine whether a language is LL(1) LR(0) SLR(1)

半世苍凉 提交于 2019-11-27 00:55:34
问题 Is there a simple way to determine whether a grammar is LL(1), LR(0), SLR(1)... just from looking on the grammar without doing any complex analysis? For instance: To decide whether a BNF Grammar is LL(1) you have to calculate First and Follow sets - which can be time consuming in some cases. Has anybody got an idea how to do this faster? Any help would really be appreciated! 回答1: First off, a bit of pedantry. You cannot determine whether a language is LL(1) from inspecting a grammar for it,

Converting EBNF to BNF

岁酱吖の 提交于 2019-11-26 19:46:50
问题 It's been a few years since my computer-language class and so I've forgotten the finer points of BNF's and EBNF's and I don't have a textbook next to me. Specifically, I've forgotten how to convert an EBNF into BNF. From what little I remember, I know that one of the main points is to convert { term } into <term> | <many-terms> . But I don't remember the other rules. I've tried to look this up online but I can only find links to either homework questions, or a small comment about converting

Regex Grammar

狂风中的少年 提交于 2019-11-26 19:30:23
问题 Is there any BNF grammar for regular expression? 回答1: You can see one for Perl regexp (displayed a little more in detail here, as posted by edg) 回答2: To post them on-site: CMPT 384 Lecture Notes Robert D. Cameron November 29 - December 1, 1999 BNF Grammar of Regular Expressions Following the precedence rules given previously, a BNF grammar for Perl-style regular expressions can be constructed as follows. <RE> ::= <union> | <simple-RE> <union> ::= <RE> "|" <simple-RE> <simple-RE> ::=

Repository of BNF Grammars?

回眸只為那壹抹淺笑 提交于 2019-11-26 19:15:20
问题 Is there a place I can find Backus–Naur Form or BNF grammars for popular languages? Whenever I do a search I don't turn up much, but I figure they must be published somewhere. I'm most interested in seeing one for Objective-C and maybe MySQL. 回答1: you have to search on tools used to create grammars: "lex/yacc grammar", "antlr grammar" "railroad diagram" http://www.antlr3.org/grammar/list.html Here's some grammar files objective-c http://www.omnigroup.com/mailman/archive/macosx-dev/2001-March

How to convert BNF to EBNF

醉酒当歌 提交于 2019-11-26 12:31:54
问题 How can I convert this BNF to EBNF? <vardec> ::= var <vardeclist>; <vardeclist> ::= <varandtype> {;<varandtype>} <varandtype> ::= <ident> {,<ident>} : <typespec> <ident> ::= <letter> {<idchar>} <idchar> ::= <letter> | <digit> | _ 回答1: EBNF or Extended Backus-Naur Form is ISO 14977:1996, and is available in PDF from ISO for free * . It is not widely used by the computer language standards. There's also a paper that describes it, and that paper contains this table summarizing EBNF notation.