Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Doc] Improve documentation for usage of racc #283

Merged
merged 3 commits into from
Feb 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
Any kind of bug report is welcome.
If you find a bug of Racc, please report an issue at
https://github.com/ruby/racc/issues. Your grammar file,
debug output generated by "racc -g", are helpful.
debug output generated by "racc -t", are helpful.


Minero Aoki
Expand Down
59 changes: 37 additions & 22 deletions lib/racc/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,48 +25,63 @@ class ParseError < StandardError; end
# == Command-line Reference
#
# racc [-o<var>filename</var>] [--output-file=<var>filename</var>]
# [-e<var>rubypath</var>] [--executable=<var>rubypath</var>]
# [-t] [--debug]
# [-g]
# [-v] [--verbose]
# [-O<var>filename</var>] [--log-file=<var>filename</var>]
# [-g] [--debug]
# [-e<var>rubypath</var>] [--executable=<var>rubypath</var>]
# [-E] [--embedded]
# [-F] [--frozen]
# [--line-convert-all]
# [-l] [--no-line-convert]
# [-c] [--line-convert-all]
# [-a] [--no-omit-actions]
# [--superclass=<var>classname</var>]
# [-C] [--check-only]
# [-S] [--output-status]
# [--version] [--copyright] [--help] <var>grammarfile</var>
# [-P]
# [-D<var>flags</var>]
# [--version] [--runtime-version] [--copyright] [--help] <var>grammarfile</var>
#
# [+grammarfile+]
# Racc grammar file. Any extension is permitted.
# [-o+outfile+, --output-file=+outfile+]
# A filename for output. default is <+filename+>.tab.rb
# [-t, --debug]
# Add debug code to parser class. To display debugging information,
# use this '-t' option and set @yydebug true in parser class.
# [-g]
# This option is obsolete. Use '-t' instead.
# [-v, --verbose]
# Verbose mode. create +filename+.output file, like yacc's y.output file.
# [-O+filename+, --log-file=+filename+]
# Place logging output in file +filename+.
# Default log file name is <+filename+>.output.
# [-e+rubypath+, --executable=+rubypath+]
# output executable file(mode 755). where +path+ is the Ruby interpreter.
# [-v, --verbose]
# verbose mode. create +filename+.output file, like yacc's y.output file.
# [-g, --debug]
# add debug code to parser class. To display debugging information,
# use this '-g' option and set @yydebug true in parser class.
# Output executable file(mode 755). where +path+ is the Ruby interpreter.
# [-E, --embedded]
# Output parser which doesn't need runtime files (racc/parser.rb).
# [-F, --frozen]
# Output parser which declares frozen_string_literals: true
# [--line-convert-all]
# Convert line number of actions, inner, header and footer.
# [-l, --no-line-convert]
# Turns off line number converting.
# [-a, --no-omit-actions]
# Call all actions, even if an action is empty.
# [--superclass=+classname+]
# Uses +classname+ instead of Racc::Parser as the superclass of the generated parser.
# [-C, --check-only]
# Check syntax of racc grammar file and quit.
# [-S, --output-status]
# Print messages time to time while compiling.
# [-l, --no-line-convert]
# turns off line number converting.
# [-c, --line-convert-all]
# Convert line number of actions, inner, header and footer.
# [-a, --no-omit-actions]
# Call all actions, even if an action is empty.
# [-P]
# Enables generator profile mode.
# [-D +flags+]
# Do not use this option. Flags for Racc debugging.
# [--version]
# print Racc version and quit.
# Print Racc version and quit.
# [--runtime-version]
# Print Racc runtime version and quit.
# [--copyright]
# Print copyright and quit.
# [--help]
Expand Down Expand Up @@ -129,14 +144,14 @@ class ParseError < StandardError; end
#
# == Debugging
#
# When debugging, "-v" or/and the "-g" option is helpful.
# When debugging, "-v" or/and the "-t" option is helpful.
#
# "-v" creates verbose log file (.output).
# "-g" creates a "Verbose Parser".
# "-t" creates a "Verbose Parser".
# Verbose Parser prints the internal status when parsing.
# But it's _not_ automatic.
# You must use -g option and set +@yydebug+ to +true+ in order to get output.
# -g option only creates the verbose parser.
# You must use -t option and set +@yydebug+ to +true+ in order to get output.
# -t option only creates the verbose parser.
#
# === Racc reported syntax error.
#
Expand All @@ -152,7 +167,7 @@ class ParseError < StandardError; end
#
# === Generated parsers does not work correctly
#
# Try "racc -g xxxx.y".
# Try "racc -t xxxx.y".
# This command let racc generate "debugging parser".
# Then set @yydebug=true in your parser.
# It produces a working log of your parser.
Expand Down