A Terminal is a Rule that matches directly on the input stream and may not contain any other rule. Terminals are essentially wrappers for regular expressions. As such, the Citrus notation is identical to Ruby’s regular expression notation, e.g.:
/expr/
Character classes and the dot symbol may also be used in Citrus notation for compatibility with other parsing expression implementations, e.g.:
[a-zA-Z] .
Character classes have the same semantics as character classes inside Ruby regular expressions. The dot matches any character, including newlines.
Included modules
Attributes
regexp | [R] | The actual Regexp object this rule uses to match. |
Public class methods
# File lib/citrus.rb, line 881 881: def initialize(regexp=/^/) 882: @regexp = regexp 883: end
Public instance methods
# File lib/citrus.rb, line 906 906: def ==(other) 907: case other 908: when Regexp 909: @regexp == other 910: else 911: super 912: end 913: end
Returns true if this rule is case sensitive.
# File lib/citrus.rb, line 902 902: def case_sensitive? 903: !@regexp.casefold? 904: end
Returns an array of events for this rule on the given input.
# File lib/citrus.rb, line 889 889: def exec(input, events=[]) 890: match = input.scan(@regexp) 891: 892: if match 893: events << self 894: events << CLOSE 895: events << match.length 896: end 897: 898: events 899: end