Class: JSGF::Rule
- Inherits:
-
Array
- Object
- Array
- JSGF::Rule
- Defined in:
- lib/jsgf/rule.rb
Class Method Summary collapse
-
.parse_atom(atom, optional: nil) ⇒ Object
Convert a string containing a single atom into an Atom or a rule reference.
Class Method Details
.parse_atom(atom, optional: nil) ⇒ Object
Convert a string containing a single atom into an Atom or a rule reference
5 6 7 8 9 10 11 12 13 |
# File 'lib/jsgf/rule.rb', line 5 def self.parse_atom(atom, optional:nil) case atom # Parse optionals first to prevent the reference-regex from grabbing it first when /\[(.*)\]/ then parse_atom($1, optional:true) when /\<(.*)\>/, /:(.*)/ then Atom.new($1, optional:optional, reference:true) else Atom.new(atom, optional:optional) end end |