Fix grammar errors
Patch by: Chris Tweedie <cltweedie@gmail.com> (@cltweedie) Signed-off-by: Akira Matsuda <ronnie@dio.jp> closes #1074 [ci skip] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f12003d372
commit
d0a6339903
@ -4,12 +4,12 @@
|
|||||||
|
|
||||||
== Class Block and User Code Block
|
== Class Block and User Code Block
|
||||||
|
|
||||||
There are two blocks on toplevel. One is 'class' block, another is 'user code'
|
There are two blocks on the toplevel. One is the 'class' block, the other is the 'user code'
|
||||||
block. 'user code' block MUST be placed after 'class' block.
|
block. The 'user code' block MUST be placed after the 'class' block.
|
||||||
|
|
||||||
== Comments
|
== Comments
|
||||||
|
|
||||||
You can insert comments about all places. Two style comments can be used, Ruby style '#.....' and C style '/\*......*\/'.
|
You can insert comments about all places. Two styles of comments can be used, Ruby style '#.....' and C style '/\*......*\/'.
|
||||||
|
|
||||||
== Class Block
|
== Class Block
|
||||||
|
|
||||||
@ -25,11 +25,11 @@ The class block is formed like this:
|
|||||||
rule
|
rule
|
||||||
GRAMMARS
|
GRAMMARS
|
||||||
|
|
||||||
CLASS_NAME is a name of parser class. This is the name of generating parser
|
CLASS_NAME is a name of the parser class. This is the name of the generating parser
|
||||||
class.
|
class.
|
||||||
|
|
||||||
If CLASS_NAME includes '::', Racc outputs module clause. For example, writing
|
If CLASS_NAME includes '::', Racc outputs the module clause. For example, writing
|
||||||
"class M::C" causes creating the code below:
|
"class M::C" causes the code below to be created:
|
||||||
|
|
||||||
module M
|
module M
|
||||||
class C
|
class C
|
||||||
@ -40,7 +40,7 @@ If CLASS_NAME includes '::', Racc outputs module clause. For example, writing
|
|||||||
|
|
||||||
== Grammar Block
|
== Grammar Block
|
||||||
|
|
||||||
The grammar block describes grammar which is able to be understood by parser.
|
The grammar block describes grammar which is able to be understood by the parser.
|
||||||
Syntax is:
|
Syntax is:
|
||||||
|
|
||||||
(token): (token) (token) (token).... (action)
|
(token): (token) (token) (token).... (action)
|
||||||
@ -59,10 +59,10 @@ Note that you cannot use '%' string, here document, '%r' regexp in action.
|
|||||||
|
|
||||||
Actions can be omitted. When it is omitted, '' (empty string) is used.
|
Actions can be omitted. When it is omitted, '' (empty string) is used.
|
||||||
|
|
||||||
A return value of action is a value of left side value ($$). It is value of
|
A return value of action is a value of the left side value ($$). It is the value of the
|
||||||
result, or returned value by `return` statement.
|
result, or the returned value by `return` statement.
|
||||||
|
|
||||||
Here is an example of whole grammar block.
|
Here is an example of the whole grammar block.
|
||||||
|
|
||||||
rule
|
rule
|
||||||
goal: definition rules source { result = val }
|
goal: definition rules source { result = val }
|
||||||
@ -81,11 +81,11 @@ You can use the following special local variables in action:
|
|||||||
|
|
||||||
* result ($$)
|
* result ($$)
|
||||||
|
|
||||||
The value of left-hand side (lhs). A default value is val[0].
|
The value of the left-hand side (lhs). A default value is val[0].
|
||||||
|
|
||||||
* val ($1,$2,$3...)
|
* val ($1,$2,$3...)
|
||||||
|
|
||||||
An array of value of right-hand side (rhs).
|
An array of value of the right-hand side (rhs).
|
||||||
|
|
||||||
* _values (...$-2,$-1,$0)
|
* _values (...$-2,$-1,$0)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user