[前][次][番号順一覧][スレッド一覧]

ruby-changes:56170

From: Hiroshi <ko1@a...>
Date: Thu, 20 Jun 2019 22:27:31 +0900 (JST)
Subject: [ruby-changes:56170] Hiroshi SHIBATA: 93356576fe (trunk): Revert "Removed needless file with the upstream repository."

https://git.ruby-lang.org/ruby.git/commit/?id=93356576fe

From 93356576fec17b1c7cafd56fc4a633776cb8169f Mon Sep 17 00:00:00 2001
From: Hiroshi SHIBATA <hsbt@r...>
Date: Thu, 20 Jun 2019 22:27:06 +0900
Subject: Revert "Removed needless file with the upstream repository."

This reverts commit 5bbfca7b1d4be89d4728203b4610de17bccbefd7.

diff --git a/lib/racc/parser-text.rb b/lib/racc/parser-text.rb
new file mode 100644
index 0000000..07ff41a
--- /dev/null
+++ b/lib/racc/parser-text.rb
@@ -0,0 +1,640 @@ https://github.com/ruby/ruby/blob/trunk/lib/racc/parser-text.rb#L1
+module Racc
+  PARSER_TEXT = <<'__end_of_file__'
+#
+# $Id: 1c0ef52c0f41acc465725e9e44b5b9d74d392ba5 $
+#
+# Copyright (c) 1999-2006 Minero Aoki
+#
+# This program is free software.
+# You can distribute/modify this program under the same terms of ruby.
+#
+# As a special exception, when this code is copied by Racc
+# into a Racc output file, you may use that output file
+# without restriction.
+#
+
+require 'racc/info'
+
+unless defined?(NotImplementedError)
+  NotImplementedError = NotImplementError # :nodoc:
+end
+
+module Racc
+  class ParseError < StandardError; end
+end
+unless defined?(::ParseError)
+  ParseError = Racc::ParseError
+end
+
+# Racc is a LALR(1) parser generator.
+# It is written in Ruby itself, and generates Ruby programs.
+#
+# == Command-line Reference
+#
+#     racc [-o<var>filename</var>] [--output-file=<var>filename</var>]
+#          [-e<var>rubypath</var>] [--embedded=<var>rubypath</var>]
+#          [-v] [--verbose]
+#          [-O<var>filename</var>] [--log-file=<var>filename</var>]
+#          [-g] [--debug]
+#          [-E] [--embedded]
+#          [-l] [--no-line-convert]
+#          [-c] [--line-convert-all]
+#          [-a] [--no-omit-actions]
+#          [-C] [--check-only]
+#          [-S] [--output-status]
+#          [--version] [--copyright] [--help] <var>grammarfile</var>
+#
+# [+filename+]
+#   Racc grammar file. Any extention is permitted.
+# [-o+outfile+, --output-file=+outfile+]
+#   A filename for output. default is <+filename+>.tab.rb
+# [-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 debuggin information,
+#   use this '-g' option and set @yydebug true in parser class.
+# [-E, --embedded]
+#   Output parser which doesn't need runtime files (racc/parser.rb).
+# [-C, --check-only]
+#   Check syntax of racc grammer 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.
+# [--version]
+#   print Racc version and quit.
+# [--copyright]
+#   Print copyright and quit.
+# [--help]
+#   Print usage and quit.
+#
+# == Generating Parser Using Racc
+#
+# To compile Racc grammar file, simply type:
+#
+#   $ racc parse.y
+#
+# This creates Ruby script file "parse.tab.y". The -o option can change the output filename.
+#
+# == Writing A Racc Grammar File
+#
+# If you want your own parser, you have to write a grammar file.
+# A grammar file contains the name of your parser class, grammar for the parser,
+# user code, and anything else.
+# When writing a grammar file, yacc's knowledge is helpful.
+# If you have not used yacc before, Racc is not too difficult.
+#
+# Here's an example Racc grammar file.
+#
+#   class Calcparser
+#   rule
+#     target: exp { print val[0] }
+#
+#     exp: exp '+' exp
+#        | exp '*' exp
+#        | '(' exp ')'
+#        | NUMBER
+#   end
+#
+# Racc grammar files resemble yacc files.
+# But (of course), this is Ruby code.
+# yacc's $$ is the 'result', $0, $1... is
+# an array called 'val', and $-1, $-2... is an array called '_values'.
+#
+# See the {Grammar File Reference}[rdoc-ref:lib/racc/rdoc/grammar.en.rdoc] for
+# more information on grammar files.
+#
+# == Parser
+#
+# Then you must prepare the parse entry method. There are two types of
+# parse methods in Racc, Racc::Parser#do_parse and Racc::Parser#yyparse
+#
+# Racc::Parser#do_parse is simple.
+#
+# It's yyparse() of yacc, and Racc::Parser#next_token is yylex().
+# This method must returns an array like [TOKENSYMBOL, ITS_VALUE].
+# EOF is [false, false].
+# (TOKENSYMBOL is a Ruby symbol (taken from String#intern) by default.
+# If you want to change this, see the grammar reference.
+#
+# Racc::Parser#yyparse is little complicated, but useful.
+# It does not use Racc::Parser#next_token, instead it gets tokens from any iterator.
+#
+# For example, <code>yyparse(obj, :scan)</code> causes
+# calling +obj#scan+, and you can return tokens by yielding them from +obj#scan+.
+#
+# == Debugging
+#
+# When debugging, "-v" or/and the "-g" option is helpful.
+#
+# "-v" creates verbose log file (.output).
+# "-g" 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.
+#
+# === Racc reported syntax error.
+#
+# Isn't there too many "end"?
+# grammar of racc file is changed in v0.10.
+#
+# Racc does not use '%' mark, while yacc uses huge number of '%' marks..
+#
+# === Racc reported "XXXX conflicts".
+#
+# Try "racc -v xxxx.y".
+# It causes producing racc's internal log file, xxxx.output.
+#
+# === Generated parsers does not work correctly
+#
+# Try "racc -g xxxx.y".
+# This command let racc generate "debugging parser".
+# Then set @yydebug=true in your parser.
+# It produces a working log of your parser.
+#
+# == Re-distributing Racc runtime
+#
+# A parser, which is created by Racc, requires the Racc runtime module;
+# racc/parser.rb.
+#
+# Ruby 1.8.x comes with Racc runtime module,
+# you need NOT distribute Racc runtime files.
+#
+# If you want to include the Racc runtime module with your parser.
+# This can be done by using '-E' option:
+#
+#   $ racc -E -omyparser.rb myparser.y
+#
+# This command creates myparser.rb which `includes' Racc runtime.
+# Only you must do is to distribute your parser file (myparser.rb).
+#
+# Note: parser.rb is ruby license, but your parser is not.
+# Your own parser is completely yours.
+module Racc
+
+  unless defined?(Racc_No_Extentions)
+    Racc_No_Extentions = false # :nodoc:
+  end
+
+  class Parser
+
+    Racc_Runtime_Version = ::Racc::VERSION
+    Racc_Runtime_Revision = '$Id: 1c0ef52c0f41acc465725e9e44b5b9d74d392ba5 $'
+
+    Racc_Runtime_Core_Version_R = ::Racc::VERSION
+    Racc_Runtime_Core_Revision_R = '$Id: 1c0ef52c0f41acc465725e9e44b5b9d74d392ba5 $'.split[1]
+    begin
+      if Object.const_defined?(:RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
+        require 'racc/cparse-jruby.jar'
+        com.headius.racc.Cparse.new.load(JRuby.runtime, false)
+      else
+        require 'racc/cparse'
+      end
+    # Racc_Runtime_Core_Version_C  = (defined in extention)
+      Racc_Runtime_Core_Revision_C = Racc_Runtime_Core_Id_C.split[2]
+      unless new.respond_to?(:_racc_do_parse_c, true)
+        raise LoadError, 'old cparse.so'
+      end
+      if Racc_No_Extentions
+        raise LoadError, 'selecting ruby version of racc runtime core'
+      end
+
+      Racc_Main_Parsing_Routine    = :_racc_do_parse_c # :nodoc:
+      Racc_YY_Parse_Method         = :_racc_yyparse_c # :nodoc:
+      Racc_Runtime_Core_Version    = Racc_Runtime_Core_Version_C # :nodoc:
+      Racc_Runtime_Core_Revision   = Racc_Runtime_Core_Revision_C # :nodoc:
+      Racc_Runtime_Type            = 'c' # :nodoc:
+    rescue LoadError
+puts $!
+puts $!.backtrace
+      Racc_Main_Parsing_Routine    = :_racc_do_parse_rb
+      Racc_YY_Parse_Method         = :_racc_yyparse_rb
+      Racc_Runtime_Core_Version    = Racc_Runtime_Core_Version_R
+      Racc_Runtime_Core_Revision   = Racc_Runtime_Core_Revision_R
+      Racc_Runtime_Type            = 'ruby'
+    end
+
+    def Parser.racc_runtime_type # :nodoc:
+      Racc_Runtime_Type
+    end
+
+    def _racc_setup
+      @yydebug = false unless self.class::Racc_debug_parser
+      @yydebug = false unless defined?(@yydebug)
+      if @yydebug
+        @racc_debug_out = $stderr unless defined?(@racc_debug_out)
+        @racc_debug_out ||= $stderr
+      end
+      arg = self.class::Racc_arg
+      arg[13] = true if arg.size < 14
+      arg
+    end
+
+    def _racc_init_sysvars
+      @racc_state  = [0]
+      @racc_tstack = []
+      @racc_vstack = []
+
+      @racc_t = nil
+      @racc_val = nil
+
+      @racc_read_next = true
+
+      @racc_user_yyerror = false
+      @racc_error_status = 0
+    end
+
+    # The entry point of the parser. This method is used with #next_token.
+    # If Racc wants to get token (and its value), calls next_token.
+    #
+    # Example:
+    #     def parse
+    #       @q = [[1,1],
+    #             [2,2],
+    #             [3,3],
+    #             [false, '$']]
+    #       do_parse
+    #     end
+    #
+    #     def next_token
+    #       @q.shift
+    #     end
+    def do_parse
+      __send__(Racc_Main_Parsing_Routine, _racc_setup(), false)
+    end
+
+    # The method to fetch next token.
+    # If you use #do_parse method, you must implement #next_token.
+    #
+    # The format of return value is [TOKEN_SYMBOL, VALUE].
+    # +token-symbol+ is represented by Ruby's symbol by default, e.g. :IDENT
+    # for 'IDENT'.  ";" (String) for ';'.
+    #
+    # The final symbol (End of file) must be false.
+    def next_token
+      raise NotImplementedError, "#{self.class}\#next_token is not defined"
+    end
+
+    def _racc_do_parse_rb(arg, in_debug)
+      action_table, action_check, action_d (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]