Class: Rack::Mount::StrexpParser

### Home Classes Methods

### In Files

- lib/rack/mount/strexp/parser.rb
- lib/rack/mount/strexp/tokenizer.rb

### Parent

Racc::Parser

### Namespace

- CLASS Rack::Mount::StrexpParser::ScanError

### Methods

- #_reduce_1
- #_reduce_2
- #_reduce_4
- #_reduce_5
- #_reduce_6
- #_reduce_7
- #_reduce_none
- #action
- #load_file
- #next_token
- #scan
- #scan_file
- #scan_setup
- #scan_str

### Class/Module Index

Quicksearch

- Rack
- Rack::Mount
- Rack::Mount::Analysis
- Rack::Mount::Analysis::Splitting
- Rack::Mount::Analysis::Splitting::Key
- Rack::Mount::GeneratableRegexp
- Rack::Mount::GeneratableRegexp::InstanceMethods
- Rack::Mount::RegexpWithNamedGroups
- Rack::Mount::Route
- Rack::Mount::RouteSet
- Rack::Mount::RoutingError
- Rack::Mount::Strexp
- Rack::Mount::StrexpParser
- Rack::Mount::StrexpParser::ScanError
- Rack::Mount::Utils
- Regin
- Regin::Alternation
- Regin::Anchor
- Regin::Atom
- Regin::Character
- Regin::CharacterClass
- Regin::Collection
- Regin::Expression
- Regin::Group
- Regin::Options
- Regin::Parser
- Regin::Parser::ScanError

No matching classes.

# Rack::Mount::StrexpParser

### Constants

REGEXP_NAMED_CAPTURE
Racc_arg
Racc_debug_parser
Racc_token_to_s_table

### Attributes

anchor[RW]
filename[R]
lineno[R]
requirements[RW]
state[RW]

### Public Instance Methods

_reduce_1(val, _values, result) click to toggle source

reduce 0 omitted

    # File lib/rack/mount/strexp/parser.rb, line 116
    def _reduce_1(val, _values, result)
     result = anchor ? "\\A#{val.join}\\Z" : "\\A#{val.join}"
        result
    end

_reduce_2(val, _values, result) click to toggle source

    # File lib/rack/mount/strexp/parser.rb, line 121
    def _reduce_2(val, _values, result)
     result = val.join
        result
    end

_reduce_4(val, _values, result) click to toggle source

reduce 3 omitted

    # File lib/rack/mount/strexp/parser.rb, line 128
    def _reduce_4(val, _values, result)
               name = val[0].to_sym
               requirement = requirements[name]
               result = REGEXP_NAMED_CAPTURE % [name, requirement]

        result
    end

_reduce_5(val, _values, result) click to toggle source

    # File lib/rack/mount/strexp/parser.rb, line 136
    def _reduce_5(val, _values, result)
               name = val[0].to_sym
               requirement = requirements.key?(name) ? requirements[name] : '.+'
               result = REGEXP_NAMED_CAPTURE % [name, requirement]

        result
    end

_reduce_6(val, _values, result) click to toggle source

    # File lib/rack/mount/strexp/parser.rb, line 144
    def _reduce_6(val, _values, result)
     result = "(?:#{val[1]})?"
        result
    end

_reduce_7(val, _values, result) click to toggle source

    # File lib/rack/mount/strexp/parser.rb, line 149
    def _reduce_7(val, _values, result)
     result = Regexp.escape(val[0])
        result
    end

_reduce_none(val, _values, result) click to toggle source

    # File lib/rack/mount/strexp/parser.rb, line 154
    def _reduce_none(val, _values, result)
      val[0]
    end

action() click to toggle source

    # File lib/rack/mount/strexp/tokenizer.rb, line 23
    def action
      yield
    end

load_file( filename ) click to toggle source

    # File lib/rack/mount/strexp/tokenizer.rb, line 33
    def load_file( filename )
      @filename = filename
      open(filename, "r") do |f|
        scan_setup(f.read)
      end
    end

next_token() click to toggle source

    # File lib/rack/mount/strexp/tokenizer.rb, line 46
    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

scan(str) click to toggle source
Alias for: scan_str
scan_file( filename ) click to toggle source

    # File lib/rack/mount/strexp/tokenizer.rb, line 40
    def scan_file( filename )
      load_file(filename)
      do_parse
    end

scan_setup(str) click to toggle source

    # File lib/rack/mount/strexp/tokenizer.rb, line 17
    def scan_setup(str)
      @ss = StringScanner.new(str)
      @lineno =  1
      @state  = nil
    end

scan_str(str) click to toggle source

    # File lib/rack/mount/strexp/tokenizer.rb, line 27
    def scan_str(str)
      scan_setup(str)
      do_parse
    end

Also aliased as: scan

[Validate]

Generated with the Darkfish Rdoc Generator 2.