Class: Rubber::TokenStringScanner
- Inherits:
-
StringScanner
- Object
- StringScanner
- Rubber::TokenStringScanner
- Defined in:
- lib/rubber/scanner.rb
Instance Method Summary collapse
- #scan(*args) ⇒ Object
- #scan_constant ⇒ Object
- #scan_float ⇒ Object
- #scan_lit_bool ⇒ Object
- #scan_lit_integer ⇒ Object
- #scan_lit_string ⇒ Object
- #scan_literal ⇒ Object
- #scan_nil ⇒ Object
- #scan_number ⇒ Object
- #scan_pc_block ⇒ Object
- #scan_upcase_constant ⇒ Object
- #skip(*args) ⇒ Object
- #skip_ws ⇒ Object
Instance Method Details
#scan(*args) ⇒ Object
26 27 28 29 30 |
# File 'lib/rubber/scanner.rb', line 26 def scan(*args) x = super #p [x, *args] if x x end |
#scan_constant ⇒ Object
43 44 45 |
# File 'lib/rubber/scanner.rb', line 43 def scan_constant scan(/([A-Z][a-z_0-9A-Z]*)/) end |
#scan_float ⇒ Object
37 38 39 |
# File 'lib/rubber/scanner.rb', line 37 def scan_float scan(/(\d[.]\d+)/) end |
#scan_lit_bool ⇒ Object
58 59 60 |
# File 'lib/rubber/scanner.rb', line 58 def scan_lit_bool scan(/TRUE|FALSE/i) end |
#scan_lit_integer ⇒ Object
40 41 42 |
# File 'lib/rubber/scanner.rb', line 40 def scan_lit_integer scan(/([0-9]+)/) end |
#scan_lit_string ⇒ Object
34 35 36 |
# File 'lib/rubber/scanner.rb', line 34 def scan_lit_string scan(/(".*?[^\\]")/) end |
#scan_literal ⇒ Object
49 50 51 |
# File 'lib/rubber/scanner.rb', line 49 def scan_literal scan(/([A-Za-z0-9_]+)/) end |
#scan_nil ⇒ Object
55 56 57 |
# File 'lib/rubber/scanner.rb', line 55 def scan_nil scan(/NULL|nil/i) end |
#scan_number ⇒ Object
31 32 33 |
# File 'lib/rubber/scanner.rb', line 31 def scan_number scan(/(0x[0-9A-Fa-f]+|[0-9]+[.][0-9]+(e[0-9]+)?|[0-9]+)/) end |
#scan_pc_block ⇒ Object
61 62 63 64 65 |
# File 'lib/rubber/scanner.rb', line 61 def scan_pc_block raw = scan_until(/%\}/) raw[-2..-1] = "" raw end |
#scan_upcase_constant ⇒ Object
46 47 48 |
# File 'lib/rubber/scanner.rb', line 46 def scan_upcase_constant scan(/([A-Z][0-9A-Z_]*)/) end |
#skip(*args) ⇒ Object
21 22 23 24 25 |
# File 'lib/rubber/scanner.rb', line 21 def skip(*args) x = super #p [x, *args] if x x end |
#skip_ws ⇒ Object
52 53 54 |
# File 'lib/rubber/scanner.rb', line 52 def skip_ws skip(/\s+/) end |