Module: Sexpr::Grammar::Tagging
- Included in:
- Sexpr::Grammar
- Defined in:
- lib/sexpr/grammar/tagging.rb
Instance Method Summary collapse
Instance Method Details
#mod2rulename(mod) ⇒ Object
9 10 11 12 |
# File 'lib/sexpr/grammar/tagging.rb', line 9 def mod2rulename(mod) mod = mod.name.to_s.split('::').last.to_sym if mod.is_a?(Module) mod.to_s.gsub(/[A-Z]/){|x| "_#{x.downcase}"}[1..-1].to_sym end |
#rule2modname(rule) ⇒ Object
5 6 7 |
# File 'lib/sexpr/grammar/tagging.rb', line 5 def rule2modname(rule) rule.to_s.gsub(/(^|_)([a-z])/){|x| $2.capitalize}.to_sym end |
#sexpr(input, options = {}) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/sexpr/grammar/tagging.rb', line 14 def sexpr(input, = {}) case input when Array tag_sexpr input else tag_sexpr parser!.sexpr(input, ) end end |