Class | DelimScanner |
In: |
lib/Getopt/DelimScanner.rb
|
Parent: | Object |
A derivative of StringScanner that can scan for delimited constructs in addition to regular expressions.
Version | = | /([\d\.]+)/.match( %q{$Revision: 1.2 $} )[1] | Class constants | |
Rcsid | = | %q$Id: DelimScanner.rb,v 1.2 2003/01/12 20:56:51 deveiant Exp $ | ||
XmlName | = | '[a-zA-Z_:][a-zA-Z0-9:.-]*' | Pattern to match a valid XML name | |
NeedCastingDelegators | = | :scan, :skip, :match?, :check, :scan_until, :skip_until, :exist?, :check_until | A list of delegated methods that need casting. |
debugLevel | [RW] | Debugging level |
matchError | [RW] | The last match error encountered by the scanner |
Define delegating methods that cast their argument to a Regexp from a String. This allows the scanner‘s scanning methods to be called with Strings in addition to Regexps. This was mostly stolen from forwardable.rb.
Create a new DelimScanner object for the specified string. If dup is true, a duplicate of the target string will be used instead of the one given. The target string will be frozen after the scanner is created.
Starting at the scan pointer, try to match a substring delimited by balanced delimiters of the type specified, after skipping the specified prefix. On a successful match, this method advances the scan pointer and returns a Hash with the following key/value pairs:
On failure, returns nil.
Starting from the scan pointer, and skipping the specified prefix, try to to recognize and match a balanced bracket-, do/end-, or begin/end-delimited substring that may contain unbalanced delimiters inside quotes or quotelike operations.
Starting at the scan pointer, try to match a substring delimited by the specified delimiters, skipping the specified prefix and any character escaped by the specified escape character/s. If matched, advances the scan pointer and returns a Hash with the following key/value pairs on success:
If the match fails, returns nil.
Starting from the scan pointer, try to match any one of the various Ruby quotes and quotelike operators after skipping the specified prefix. Nested backslashed delimiters, embedded balanced bracket delimiters (for the quotelike operators), and trailing modifiers are all caught. If matchRawRegex is true, inline regexen (eg., /pattern/) are matched as well. Advances the scan pointer and returns a Hash with the following key/value pairs on success:
On failure, returns nil.
Extracts and segments text from the scan pointer forward that occurs between (balanced) specified tags, after skipping the specified prefix. If the opentag argument is nil, a pattern which will match any standard HTML/XML tag will be used. If the closetag argument is nil, a pattern is created which prepends a / character to the matched opening tag, after any bracketing characters. The options argument is a Hash of one or more options which govern the matching operation. They are described in more detail in the Description section of ‘lib/DelimScanner.rb’. On a successful match, this method advances the scan pointer and returns an
On failure, returns nil.
Starting at the scan pointer, try to match a substring with scanBracketed. On a successful match, this method advances the scan pointer and returns the length of the match, including the delimiters and any prefix that was skipped. On failure, returns nil.
Starting at the scan pointer, try to match a substring with scanCodeblock. On a successful match, this method advances the scan pointer and returns the length of the match, including any delimiters and any prefix that was skipped. On failure, returns nil.
Starting at the scan pointer, try to match a substring delimited by the specified delimiters, skipping the specified prefix and any character escaped by the specified escape character/s. If matched, advances the scan pointer and returns the length of the matched string; if it fails the match, returns nil.
Starting at the scan pointer, try to match a substring with scanQuotelike. On a successful match, this method advances the scan pointer and returns the length of the match, including any delimiters and any prefix that was skipped. On failure, returns nil.
Starting at the scan pointer, try to match a substring with scanTagged. On a successful match, this method advances the scan pointer and returns the length of the match, including any delimiters and any prefix that was skipped. On failure, returns nil.
Starting at the scan pointer, try to match a substring with scanVariable. On a successful match, this method advances the scan pointer and returns the length of the match, including any delimiters and any prefix that was skipped. On failure, returns nil.
Scan the string from the scan pointer forward, skipping the specified prefix and trying to match a string delimited by bracketing delimiters ldel and rdel (Regexp objects), and quoting delimiters qdel (Regexp). If quotelike is true, Ruby quotelike constructs will also be honored.
Starting from the scan pointer, skip the specified prefix, and try to match text inside a Ruby code block construct which must be delimited by the specified outerDelimPairs. It may optionally contain sub-blocks delimited with the given innerDelimPairs.
Starting from the scan pointer, skip the specified prefix, and try to match text inside a Ruby quotelike construct. If matchRawRegex is true, the regex construct /pattern/ is also matched.
Starting from the scan pointer, skip the specified prefix, and try to match text bracketed by the given left and right tag-delimiters (ldel and rdel).
Starting from the scan pointer, skip the specified prefix, and try to match text that is a valid Ruby variable or identifier, …?