aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/vendor/rack-mount-0.6.6.pre/rack/mount/strexp
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_dispatch/vendor/rack-mount-0.6.6.pre/rack/mount/strexp')
-rw-r--r--actionpack/lib/action_dispatch/vendor/rack-mount-0.6.6.pre/rack/mount/strexp/parser.rb160
-rw-r--r--actionpack/lib/action_dispatch/vendor/rack-mount-0.6.6.pre/rack/mount/strexp/parser.y34
-rw-r--r--actionpack/lib/action_dispatch/vendor/rack-mount-0.6.6.pre/rack/mount/strexp/tokenizer.rb83
-rw-r--r--actionpack/lib/action_dispatch/vendor/rack-mount-0.6.6.pre/rack/mount/strexp/tokenizer.rex12
4 files changed, 289 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/vendor/rack-mount-0.6.6.pre/rack/mount/strexp/parser.rb b/actionpack/lib/action_dispatch/vendor/rack-mount-0.6.6.pre/rack/mount/strexp/parser.rb
new file mode 100644
index 0000000000..cfe05afc61
--- /dev/null
+++ b/actionpack/lib/action_dispatch/vendor/rack-mount-0.6.6.pre/rack/mount/strexp/parser.rb
@@ -0,0 +1,160 @@
+#
+# DO NOT MODIFY!!!!
+# This file is automatically generated by Racc 1.4.6
+# from Racc grammer file "".
+#
+
+require 'racc/parser.rb'
+
+require 'rack/mount/utils'
+require 'rack/mount/strexp/tokenizer'
+
+module Rack
+ module Mount
+ class StrexpParser < Racc::Parser
+
+
+if Regin.regexp_supports_named_captures?
+ REGEXP_NAMED_CAPTURE = '(?<%s>%s)'.freeze
+else
+ REGEXP_NAMED_CAPTURE = '(?:<%s>%s)'.freeze
+end
+
+attr_accessor :anchor, :requirements
+##### State transition tables begin ###
+
+racc_action_table = [
+ 1, 2, 3, 9, 4, 1, 2, 3, 12, 4,
+ 1, 2, 3, 11, 4, 1, 2, 3, nil, 4 ]
+
+racc_action_check = [
+ 0, 0, 0, 5, 0, 3, 3, 3, 9, 3,
+ 8, 8, 8, 8, 8, 6, 6, 6, nil, 6 ]
+
+racc_action_pointer = [
+ -2, nil, nil, 3, nil, 3, 13, nil, 8, 8,
+ nil, nil, nil ]
+
+racc_action_default = [
+ -8, -4, -5, -8, -7, -8, -1, -3, -8, -8,
+ -2, -6, 13 ]
+
+racc_goto_table = [
+ 6, 5, 10, 8, 10 ]
+
+racc_goto_check = [
+ 2, 1, 3, 2, 3 ]
+
+racc_goto_pointer = [
+ nil, 1, 0, -4 ]
+
+racc_goto_default = [
+ nil, nil, nil, 7 ]
+
+racc_reduce_table = [
+ 0, 0, :racc_error,
+ 1, 8, :_reduce_1,
+ 2, 9, :_reduce_2,
+ 1, 9, :_reduce_none,
+ 1, 10, :_reduce_4,
+ 1, 10, :_reduce_5,
+ 3, 10, :_reduce_6,
+ 1, 10, :_reduce_7 ]
+
+racc_reduce_n = 8
+
+racc_shift_n = 13
+
+racc_token_table = {
+ false => 0,
+ :error => 1,
+ :PARAM => 2,
+ :GLOB => 3,
+ :LPAREN => 4,
+ :RPAREN => 5,
+ :CHAR => 6 }
+
+racc_nt_base = 7
+
+racc_use_result_var = true
+
+Racc_arg = [
+ racc_action_table,
+ racc_action_check,
+ racc_action_default,
+ racc_action_pointer,
+ racc_goto_table,
+ racc_goto_check,
+ racc_goto_default,
+ racc_goto_pointer,
+ racc_nt_base,
+ racc_reduce_table,
+ racc_token_table,
+ racc_shift_n,
+ racc_reduce_n,
+ racc_use_result_var ]
+
+Racc_token_to_s_table = [
+ "$end",
+ "error",
+ "PARAM",
+ "GLOB",
+ "LPAREN",
+ "RPAREN",
+ "CHAR",
+ "$start",
+ "target",
+ "expr",
+ "token" ]
+
+Racc_debug_parser = false
+
+##### State transition tables end #####
+
+# reduce 0 omitted
+
+def _reduce_1(val, _values, result)
+ result = anchor ? "\\A#{val.join}\\Z" : "\\A#{val.join}"
+ result
+end
+
+def _reduce_2(val, _values, result)
+ result = val.join
+ result
+end
+
+# reduce 3 omitted
+
+def _reduce_4(val, _values, result)
+ name = val[0].to_sym
+ requirement = requirements[name]
+ result = REGEXP_NAMED_CAPTURE % [name, requirement]
+
+ result
+end
+
+def _reduce_5(val, _values, result)
+ name = val[0].to_sym
+ requirement = requirements[name]
+ result = REGEXP_NAMED_CAPTURE % [name, '.+' || requirement]
+
+ result
+end
+
+def _reduce_6(val, _values, result)
+ result = "(?:#{val[1]})?"
+ result
+end
+
+def _reduce_7(val, _values, result)
+ result = Regexp.escape(val[0])
+ result
+end
+
+def _reduce_none(val, _values, result)
+ val[0]
+end
+
+ end # class StrexpParser
+ end # module Mount
+end # module Rack
diff --git a/actionpack/lib/action_dispatch/vendor/rack-mount-0.6.6.pre/rack/mount/strexp/parser.y b/actionpack/lib/action_dispatch/vendor/rack-mount-0.6.6.pre/rack/mount/strexp/parser.y
new file mode 100644
index 0000000000..ffbd9fae11
--- /dev/null
+++ b/actionpack/lib/action_dispatch/vendor/rack-mount-0.6.6.pre/rack/mount/strexp/parser.y
@@ -0,0 +1,34 @@
+class Rack::Mount::StrexpParser
+rule
+ target: expr { result = anchor ? "\\A#{val.join}\\Z" : "\\A#{val.join}" }
+
+ expr: expr token { result = val.join }
+ | token
+
+ token: PARAM {
+ name = val[0].to_sym
+ requirement = requirements[name]
+ result = REGEXP_NAMED_CAPTURE % [name, requirement]
+ }
+ | GLOB {
+ name = val[0].to_sym
+ requirement = requirements[name]
+ result = REGEXP_NAMED_CAPTURE % [name, '.+' || requirement]
+ }
+ | LPAREN expr RPAREN { result = "(?:#{val[1]})?" }
+ | CHAR { result = Regexp.escape(val[0]) }
+end
+
+---- header ----
+require 'rack/mount/utils'
+require 'rack/mount/strexp/tokenizer'
+
+---- inner
+
+if Regin.regexp_supports_named_captures?
+ REGEXP_NAMED_CAPTURE = '(?<%s>%s)'.freeze
+else
+ REGEXP_NAMED_CAPTURE = '(?:<%s>%s)'.freeze
+end
+
+attr_accessor :anchor, :requirements
diff --git a/actionpack/lib/action_dispatch/vendor/rack-mount-0.6.6.pre/rack/mount/strexp/tokenizer.rb b/actionpack/lib/action_dispatch/vendor/rack-mount-0.6.6.pre/rack/mount/strexp/tokenizer.rb
new file mode 100644
index 0000000000..0ff7f67661
--- /dev/null
+++ b/actionpack/lib/action_dispatch/vendor/rack-mount-0.6.6.pre/rack/mount/strexp/tokenizer.rb
@@ -0,0 +1,83 @@
+#--
+# DO NOT MODIFY!!!!
+# This file is automatically generated by rex 1.0.5.beta1
+# from lexical definition file "lib/rack/mount/strexp/tokenizer.rex".
+#++
+
+require 'racc/parser'
+class Rack::Mount::StrexpParser < Racc::Parser
+ require 'strscan'
+
+ class ScanError < StandardError ; end
+
+ attr_reader :lineno
+ attr_reader :filename
+ attr_accessor :state
+
+ def scan_setup(str)
+ @ss = StringScanner.new(str)
+ @lineno = 1
+ @state = nil
+ end
+
+ def action
+ yield
+ end
+
+ def scan_str(str)
+ scan_setup(str)
+ do_parse
+ end
+ alias :scan :scan_str
+
+ def load_file( filename )
+ @filename = filename
+ open(filename, "r") do |f|
+ scan_setup(f.read)
+ end
+ end
+
+ def scan_file( filename )
+ load_file(filename)
+ do_parse
+ end
+
+
+ def next_token
+ return if @ss.eos?
+
+ text = @ss.peek(1)
+ @lineno += 1 if text == "\n"
+ token = case @state
+ when nil
+ case
+ when (text = @ss.scan(/\\(\(|\)|:|\*)/))
+ action { [:CHAR, @ss[1]] }
+
+ when (text = @ss.scan(/\:([a-zA-Z_]\w*)/))
+ action { [:PARAM, @ss[1]] }
+
+ when (text = @ss.scan(/\*([a-zA-Z_]\w*)/))
+ action { [:GLOB, @ss[1]] }
+
+ when (text = @ss.scan(/\(/))
+ action { [:LPAREN, text] }
+
+ when (text = @ss.scan(/\)/))
+ action { [:RPAREN, text] }
+
+ when (text = @ss.scan(/./))
+ action { [:CHAR, text] }
+
+ else
+ text = @ss.string[@ss.pos .. -1]
+ raise ScanError, "can not match: '" + text + "'"
+ end # if
+
+ else
+ raise ScanError, "undefined state: '" + state.to_s + "'"
+ end # case state
+ token
+ end # def next_token
+
+end # class
diff --git a/actionpack/lib/action_dispatch/vendor/rack-mount-0.6.6.pre/rack/mount/strexp/tokenizer.rex b/actionpack/lib/action_dispatch/vendor/rack-mount-0.6.6.pre/rack/mount/strexp/tokenizer.rex
new file mode 100644
index 0000000000..473bd096e1
--- /dev/null
+++ b/actionpack/lib/action_dispatch/vendor/rack-mount-0.6.6.pre/rack/mount/strexp/tokenizer.rex
@@ -0,0 +1,12 @@
+class Rack::Mount::StrexpParser
+macro
+ RESERVED \(|\)|:|\*
+ ALPHA_U [a-zA-Z_]
+rule
+ \\({RESERVED}) { [:CHAR, @ss[1]] }
+ \:({ALPHA_U}\w*) { [:PARAM, @ss[1]] }
+ \*({ALPHA_U}\w*) { [:GLOB, @ss[1]] }
+ \( { [:LPAREN, text] }
+ \) { [:RPAREN, text] }
+ . { [:CHAR, text] }
+end