racc 1.4.9 → 1.4.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,78 +0,0 @@
1
- <h1>Racc Command Reference</h1>
2
- <p>
3
- racc [-o<var>filename</var>] [--output-file=<var>filename</var>]
4
- [-e<var>rubypath</var>] [--embedded=<var>rubypath</var>]
5
- [-v] [--verbose]
6
- [-O<var>filename</var>] [--log-file=<var>filename</var>]
7
- [-g] [--debug]
8
- [-E] [--embedded]
9
- [-l] [--no-line-convert]
10
- [-c] [--line-convert-all]
11
- [-a] [--no-omit-actions]
12
- [-C] [--check-only]
13
- [-S] [--output-status]
14
- [--version] [--copyright] [--help] <var>grammarfile</var>
15
- </p>
16
-
17
- <dl>
18
- <dt><var>filename</var>
19
- <dd>
20
- Racc grammar file. Any extention is permitted.
21
- </dd>
22
- <dt>-o<var>outfile</var>, --output-file=<var>outfile</var>
23
- <dd>
24
- A filename for output. default is &lt;filename&gt;.tab.rb
25
- </dd>
26
- <dt>-O<var>filename</var>, --log-file=<var>filename</var>
27
- <dd>
28
- Place logging output in file <var>filename</var>.
29
- Default log file name is <var>filename</var>.output.
30
- </dd>
31
- <dt>-e<var>rubypath</var>, --executable=<var>rubypath</var>
32
- <dd>
33
- output executable file(mode 755). <var>path</var> is a path of ruby interpreter.
34
- </dd>
35
- <dt>-v, --verbose
36
- <dd>
37
- verbose mode. create &lt;filename&gt;.output file, like yacc's y.output file.
38
- </dd>
39
- <dt>-g, --debug
40
- <dd>
41
- add debug code to parser class. To display debuggin information,
42
- use this '-g' option and set @yydebug true in parser class.
43
- </dd>
44
- <dt>-E, --embedded
45
- <dd>
46
- Output parser which doesn't need runtime files (racc/parser.rb).
47
- </dd>
48
- <dt>-C, --check-only
49
- <dd>
50
- Check syntax of racc grammer file and quit.
51
- </dd>
52
- <dt>-S, --output-status
53
- <dd>
54
- Print messages time to time while compiling.
55
- </dd>
56
- <dt>-l, --no-line-convert
57
- <dd>
58
- turns off line number converting.
59
- </dd>
60
- <dt>-c, --line-convert-all
61
- <dd>
62
- Convert line number of actions, inner, header and footer.
63
- <dt>-a, --no-omit-actions
64
- <dd>
65
- Call all actions, even if an action is empty.
66
- </dd>
67
- <dt>--version
68
- <dd>
69
- print Racc version and quit.
70
- </dd>
71
- <dt>--copyright
72
- <dd>
73
- Print copyright and quit.
74
- <dt>--help
75
- <dd>
76
- Print usage and quit.
77
- </dd>
78
- </dl>
@@ -1,20 +0,0 @@
1
- = Debugging
2
-
3
- == Racc reported syntax error.
4
-
5
- Isn't there too many "end"?
6
- grammar of racc file is changed in v0.10.
7
-
8
- Racc does not use '%' mark, while yacc uses huge number of '%' marks..
9
-
10
- == Racc reported "XXXX conflicts".
11
-
12
- Try "racc -v xxxx.y".
13
- It causes producing racc's internal log file, xxxx.output.
14
-
15
- == Generated parsers does not work correctly
16
-
17
- Try "racc -g xxxx.y".
18
- This command let racc generate "debugging parser".
19
- Then set @yydebug=true in your parser.
20
- It produces a working log of your parser.
@@ -1,10 +0,0 @@
1
- <h1>Racc User Manual</h1>
2
- <p>updated for version 1.4</p>
3
- <ul>
4
- <li><a href="usage.html">Usage</a>
5
- <li><a href="command.html">Racc Command Reference</a>
6
- <li><a href="grammar.html">Racc Grammar File Reference</a>
7
- <li><a href="parser.html">Racc::Parser class Reference</a>
8
- <li><a href="debug.html">Debugging Parser</a>
9
- <li><a href="NEWS.html">Release Note</a>
10
- </ul>
@@ -1,74 +0,0 @@
1
- = class Racc::Parser
2
-
3
- == Super Class
4
-
5
- Object
6
-
7
- == Instance Methods
8
-
9
- : do_parse -> Object
10
- The entry point of parser. This method is used with #next_token.
11
- If Racc wants to get token (and its value), calls next_token.
12
-
13
- --
14
- # Example
15
- ---- inner
16
- def parse
17
- @q = [[1,1],
18
- [2,2],
19
- [3,3],
20
- [false, '$']]
21
- do_parse
22
- end
23
-
24
- def next_token
25
- @q.shift
26
- end
27
- --
28
-
29
- : next_token -> [Symbol, Object]
30
- [abstract method]
31
-
32
- The method to fetch next token. If you use #do_parse method,
33
- you must implement #next_token. The format of return value is
34
- [TOKEN_SYMBOL, VALUE]. token-symbol is represented by Ruby's symbol
35
- by default, e.g. :IDENT for 'IDENT'. ";" (String) for ';'.
36
-
37
- The final symbol (End of file) must be false.
38
-
39
- : yyparse( receiver, method_id )
40
- The another entry point of parser.
41
- If you use this method, you must implement RECEIVER#METHOD_ID method.
42
-
43
- RECEIVER#METHOD_ID is a method to get next token.
44
- It must 'yield's token, which format is [TOKEN-SYMBOL, VALUE].
45
-
46
- : on_error( error_token_id, error_value, value_stack )
47
- This method is called when parse error is found.
48
-
49
- ERROR_TOKEN_ID is an internal ID of token which caused error.
50
- You can get string replesentation of this ID by calling
51
- #token_to_str.
52
-
53
- ERROR_VALUE is a value of error token.
54
-
55
- value_stack is a stack of symbol values.
56
- DO NOT MODIFY this object.
57
-
58
- This method raises ParseError by default.
59
-
60
- If this method returns, parsers enter "error recovering mode".
61
-
62
- : token_to_str( t ) -> String
63
- Convert internal ID of token symbol to the string.
64
-
65
- : yyerror
66
- Enter error recovering mode.
67
- This method does not call #on_error.
68
-
69
- : yyerrok
70
- Leave error recovering mode.
71
-
72
- : yyaccept
73
- Exit parser.
74
- Return value is Symbol_Value_Stack[0].
@@ -1,92 +0,0 @@
1
- <h1>Usage</h1>
2
-
3
- <h2>Generating Parser Using Racc</h2>
4
- <p>
5
- To compile Racc grammar file, simply type:
6
- </p>
7
- <pre>
8
- $ racc parse.y
9
- </pre>
10
- <p>
11
- This creates ruby script file "parse.tab.y". -o option changes this.
12
- </p>
13
-
14
- <h2>Writing Racc Grammer File</h2>
15
- <p>
16
- If you want your own parser, you have to write grammar file.
17
- A grammar file contains name of parser class, grammar the parser can parse,
18
- user code, and any.<br>
19
- When writing grammar file, yacc's knowledge is helpful.
20
- If you have not use yacc, also racc is too difficult.
21
- </p>
22
- <p>
23
- Here's example of Racc grammar file.
24
- </p>
25
- <pre>
26
- class Calcparser
27
- rule
28
- target: exp { print val[0] }
29
-
30
- exp: exp '+' exp
31
- | exp '*' exp
32
- | '(' exp ')'
33
- | NUMBER
34
- end
35
- </pre>
36
- <p>
37
- Racc grammar file is resembles to yacc file.
38
- But (of cource), action is Ruby code. yacc's $$ is 'result', $0, $1... is
39
- an array 'val', $-1, $-2... is an array '_values'.
40
- </p>
41
- <p>
42
- Then you must prepare parse entry method. There's two types of
43
- racc's parse method,
44
- <a href="parser.html#Racc%3a%3aParser-do_parse"><code>do_parse</code></a> and
45
- <a href="parser.html#Racc%3a%3aParser-yyparse"><code>yyparse</code></a>.
46
- </p>
47
- <p>
48
- "do_parse()" is simple. it is yyparse() of yacc, and "next_token()" is
49
- yylex(). This method must returns an array like [TOKENSYMBOL, ITS_VALUE].
50
- EOF is [false, false].
51
- (token symbol is ruby symbol (got by String#intern) as default.
52
- If you want to change this, see <a href="grammar.html#token">grammar reference</a>.
53
- </p>
54
- <p>
55
- "yyparse()" is little complecated, but useful. It does not use "next_token()",
56
- it gets tokens from any iterator. For example, "yyparse(obj, :scan)" causes
57
- calling obj#scan, and you can return tokens by yielding them from obj#scan.
58
- </p>
59
- <p>
60
- When debugging, "-v" or/and "-g" option is helpful.
61
- "-v" causes creating verbose log file (.output).
62
- "-g" causes creating "Verbose Parser".
63
- Verbose Parser prints internal status when parsing.
64
- But it is <em>not</em> automatic.
65
- You must use -g option and set @yydebug true to get output.
66
- -g option only creates verbose parser.
67
- </p>
68
-
69
- <h3>re-distributing Racc runtime</h3>
70
- <p>
71
- A parser, which is created by Racc, requires Racc runtime module;
72
- racc/parser.rb.
73
- </p>
74
- <p>
75
- Ruby 1.8.x comes with racc runtime module,
76
- you need NOT distribute racc runtime files.
77
- </p>
78
- <p>
79
- If you want to run your parsers on ruby 1.6,
80
- you need re-distribute racc runtime module with your parser.
81
- It can be done by using '-E' option:
82
- <pre>
83
- $ racc -E -omyparser.rb myparser.y
84
- </pre>
85
- <p>
86
- This command creates myparser.rb which `includes' racc runtime.
87
- Only you must do is to distribute your parser file (myparser.rb).
88
- </p>
89
- <p>
90
- Note: parser.rb is LGPL, but your parser is not.
91
- Your own parser is completely yours.
92
- </p>