Class: Rsec::PInt
- Includes:
- Prim
- Defined in:
- lib/rsec/parsers/prim.rb
Overview
primitive int parser commons
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Binary
Attributes included from Parser
Instance Method Summary collapse
Methods included from Prim
Methods included from Parser
#&, #*, #<<, #>>, #^, #cached, #eof, #fail, #inspect, #join, #map, #maybe, #parse, #parse!, #star, #|
Instance Method Details
#_parse(ctx) ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/rsec/parsers/prim.rb', line 57 def _parse ctx if (d = ctx.scan left) d = d.to_i @base return d if right.include?(d) end INVALID end |
#int_pattern(sign_strategy, base) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/rsec/parsers/prim.rb', line 45 def int_pattern sign_strategy, base sign = sign_strategy_to_pattern sign_strategy if base > 10 d_hi = 9 char_range = "a-#{('a'.ord + base - 11).chr}" else d_hi = base - 1 char_range = '' end /#{sign}[0-#{d_hi}#{char_range}]+/i end |