Regexp constants for parsing
==> "\"and \"bar\" and baz\" and some \"other stuff\""
--- SEC00161
--- ""
---
---
- name: TAGOPEN
desc: |+
The Regexp that is used to match directive tag openings. Must be at least 2
characters wide.
value: "%r{([<|\\[])\\?}"
- name: TAGMIDDLE
desc: |+
The Hash that maps tag-closings to tag-middle patterns.
value: "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"
- name: TAGCLOSE
desc: |+
The Hash that maps tag openings to matching tag closings with flipped
braces.
value: Hash.new {|hsh, key| compliment = key.reverse.tr('<{([', '>})]')
- name: CAPTURE
desc: |+
Paren-group map
value: Hash.new {|hsh, key| Regexp.new( '(' + key.to_s + ')' )
- name: ALTERNATION
value: Hash.new {|hsh, *keys| Regexp.new( '(?:' + keys.join('|') + ')' )
- name: DOT
desc: |+
Constant patterns for parsing
value: /\./
- name: COMMA
value: /,/
- name: WHITESPACE
value: /\s*/
- name: EQUALS
value: /=/
- name: INFIX
value: /\.|::|(?>\[)/
- name: IDENTIFIER
value: /[a-z]\w*/i
- name: LBRACKET
value: /[\[(]/
- name: RBRACKET
value: Hash.new {|hsh, key| compliment = key.tr( '<{([', '>})]' )
- name: NUMBER
value: /[-+]?\d+(?:\.\d+)?(?:e-?\d+)?/
- name: TICKQSTRING
desc: |
: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]
<pre>
==> "\"and \"bar\" and baz\" and some \"other stuff\""
</pre>
value: /'((?:[^']|\\')*)'/
- name: DBLQSTRING
value: /"((?:[^"]|\\")*)"/
- name: SLASHQSTRING
value: "%r{/((?:[^/]|\\\\/)*)/}"
- name: QUOTEDSTRING
value: ALTERNATION[[ TICKQSTRING, DBLQSTRING, SLASHQSTRING ]]
- name: SYMBOL
value: /:[@$]?[a-z]\w+/ | /:/ + ALTERNATION[[ DBLQSTRING, TICKQSTRING ]]
- name: VARIABLE
value: /(?:\$|@@?)?_?/ + IDENTIFIER
- name: REGEXP
value: "%r{/((?:[^/]|\\\\.)+)/}"
- name: REBINDOP
value: /\s*(?:=~|matches)(?=\s)/
- name: PATHNAME
value: "%r{((?:[-\\w.,:+@#$\\%\\(\\)/]|\\\\ |\\?(?!>))+)}"
- name: ARGUMENT
value: /[*&]?/ + IDENTIFIER
- name: ARGDEFAULT
value: EQUALS + WHITESPACE + ALTERNATION[[ IDENTIFIER, NUMBER, QUOTEDSTRING, SYMBOL, VARIABLE ]]
Generated with the Darkfish Rdoc Generator.