Module: Arrow::Template::Parser::Patterns
- Included in:
- ExportDirective, ForDirective, ImportDirective, IncludeDirective, Arrow::Template::Parser, State, RenderDirective, SelectListDirective, YieldDirective
- Defined in:
- lib/arrow/template/parser.rb
Overview
Regexp constants for parsing
Constant Summary collapse
- TAGOPEN =
The Regexp that is used to match directive tag openings. Must be at least 2 characters wide.
%r{([<|\[])\?}
- TAGMIDDLE =
The Hash that maps tag-closings to tag-middle patterns.
Hash.new {|hsh, key| # Extract the first and second characters from the tag-closing # pattern to build the tag-middle pattern. src = key.is_a?( Regexp ) ? key.source : key.to_s mobj = /(\\.|.)(\\.|.)/.match( src ) or raise Arrow::ParseError, "couldn't extract first and second "\ "char from closing tag '%s'" % key char1, char2 = mobj[1,2] hsh[key] = Regexp.new( /((?:[^#{char1}]|#{char1}(?!#{char2}))+)/ ) }
- TAGCLOSE =
The Hash that maps tag openings to matching tag closings with flipped braces.
Hash.new {|hsh, key| compliment = key.reverse.tr('<{([', '>})]') hsh[key] = Regexp.new( Regexp.quote(compliment) ) }
- CAPTURE =
Paren-group map
Hash.new {|hsh, key| Regexp.new( '(' + key.to_s + ')' ) }
- ALTERNATION =
Hash.new {|hsh, *keys| Regexp.new( '(?:' + keys.join('|') + ')' ) }
- DOT =
Constant patterns for parsing
/\./
- COMMA =
/,/
- WHITESPACE =
/\s*/
- EQUALS =
/=/
- INFIX =
/\.|::|(?>\[)/
- IDENTIFIER =
/[a-z]\w*/i
- LBRACKET =
/[\[(]/
- RBRACKET =
Hash.new {|hsh, key| compliment = key.tr( '<{([', '>})]' ) hsh[key] = Regexp.new( Regexp.quote(compliment) ) }
- NUMBER =
/[-+]?\d+(?:\.\d+)?(?:e-?\d+)?/
- TICKQSTRING =
:FIXME: I would do this with something like /([“‘/])((?:[^1]|\.)*)1/, but Ruby apparently doesn’t grok backreferences inside character classes: (ruby 1.8.1 (2003-10-25) [i686-linux]) irb(main):001:0> /([”‘])((?:[^1]|\.)*)1/.match( \
%{foo "and \"bar\" and baz" and some "other stuff"} )[0] ==> "\"and \"bar\" and baz\" and some \"other stuff\""
/'((?:[^']|\\')*)'/
- DBLQSTRING =
/"((?:[^"]|\\")*)"/
- SLASHQSTRING =
%r{/((?:[^/]|\\/)*)/}
- QUOTEDSTRING =
- SYMBOL =
- VARIABLE =
/(?:\$|@@?)?_?/ + IDENTIFIER
- REGEXP =
%r{/((?:[^/]|\\.)+)/}
- REBINDOP =
/\s*(?:=~|matches)(?=\s)/
- PATHNAME =
%r{((?:[-\w.,:+@#$\%\(\)/]|\\ |\?(?!>))+)}
- ARGUMENT =
/[*&]?/ + IDENTIFIER
- ARGDEFAULT =