Class: Query::Parser::Number

Inherits:
Language
  • Object
show all
Defined in:
lib/query/parser/number.rb

Instance Method Summary collapse

Instance Method Details

#aObject



50
51
52
# File 'lib/query/parser/number.rb', line 50

def a
  str("a") | str("A")
end

#bObject



54
55
56
# File 'lib/query/parser/number.rb', line 54

def b
  str("b") | str("B")
end

#base_10_digitObject



91
92
93
# File 'lib/query/parser/number.rb', line 91

def base_10_digit
  zero | one | two | three | four | five | six | seven | eight | nine
end

#base_10_numberObject



131
132
133
# File 'lib/query/parser/number.rb', line 131

def base_10_number
  base_10_whole.aka(:whole) << exponent.maybe
end

#base_10_wholeObject



107
108
109
# File 'lib/query/parser/number.rb', line 107

def base_10_whole
  base_10_digit << (underscore.ignore | base_10_digit).repeat
end

#base_16_digitObject



86
87
88
89
# File 'lib/query/parser/number.rb', line 86

def base_16_digit
  zero | one | two | three | four | five | six | seven | eight | nine |
    a | b | c | d | e | f
end

#base_16_numberObject



127
128
129
# File 'lib/query/parser/number.rb', line 127

def base_16_number
  zero.ignore << x.ignore << base_16_whole
end

#base_16_wholeObject



103
104
105
# File 'lib/query/parser/number.rb', line 103

def base_16_whole
  base_16_digit << (underscore.ignore | base_16_digit).repeat
end

#base_2_digitObject



99
100
101
# File 'lib/query/parser/number.rb', line 99

def base_2_digit
  zero | one
end

#base_2_numberObject



139
140
141
# File 'lib/query/parser/number.rb', line 139

def base_2_number
  zero.ignore << b.ignore << base_2_whole
end

#base_2_wholeObject



115
116
117
# File 'lib/query/parser/number.rb', line 115

def base_2_whole
  base_2_digit << (underscore.ignore | base_2_digit).repeat
end

#base_8_digitObject



95
96
97
# File 'lib/query/parser/number.rb', line 95

def base_8_digit
  zero | one | two | three | four | five | six | seven
end

#base_8_numberObject



135
136
137
# File 'lib/query/parser/number.rb', line 135

def base_8_number
  zero.ignore << o.ignore << base_8_whole
end

#base_8_wholeObject



111
112
113
# File 'lib/query/parser/number.rb', line 111

def base_8_whole
  base_8_digit << (underscore.ignore | base_8_digit).repeat
end

#cObject



58
59
60
# File 'lib/query/parser/number.rb', line 58

def c
  str("c") | str("C")
end

#dObject



62
63
64
# File 'lib/query/parser/number.rb', line 62

def d
  str("d") | str("D")
end

#decimalObject



123
124
125
# File 'lib/query/parser/number.rb', line 123

def decimal
  (base_10_whole << dot << base_10_whole).aka(:decimal) << exponent.maybe
end

#dotObject



46
47
48
# File 'lib/query/parser/number.rb', line 46

def dot
  str(".")
end

#eObject



66
67
68
# File 'lib/query/parser/number.rb', line 66

def e
  str("e") | str("E")
end

#eightObject



38
39
40
# File 'lib/query/parser/number.rb', line 38

def eight
  str("8")
end

#exponentObject



119
120
121
# File 'lib/query/parser/number.rb', line 119

def exponent
  (e << Number).aka(:exponent)
end

#fObject



70
71
72
# File 'lib/query/parser/number.rb', line 70

def f
  str("f") | str("F")
end

#fiveObject



26
27
28
# File 'lib/query/parser/number.rb', line 26

def five
  str("5")
end

#fourObject



22
23
24
# File 'lib/query/parser/number.rb', line 22

def four
  str("4")
end

#nineObject



42
43
44
# File 'lib/query/parser/number.rb', line 42

def nine
  str("9")
end

#oObject



74
75
76
# File 'lib/query/parser/number.rb', line 74

def o
  str("o") | str("O")
end

#oneObject



10
11
12
# File 'lib/query/parser/number.rb', line 10

def one
  str("1")
end

#rootObject



143
144
145
146
147
148
149
150
151
# File 'lib/query/parser/number.rb', line 143

def root
  (
    (
      decimal.aka(:decimal) | base_16_number.aka(:base_16) |
        base_8_number.aka(:base_8) | base_2_number.aka(:base_2) |
        base_10_number.aka(:base_10)
    ) << Special.present
  ).aka(:number)
end

#sevenObject



34
35
36
# File 'lib/query/parser/number.rb', line 34

def seven
  str("7")
end

#sixObject



30
31
32
# File 'lib/query/parser/number.rb', line 30

def six
  str("6")
end

#threeObject



18
19
20
# File 'lib/query/parser/number.rb', line 18

def three
  str("3")
end

#twoObject



14
15
16
# File 'lib/query/parser/number.rb', line 14

def two
  str("2")
end

#underscoreObject



82
83
84
# File 'lib/query/parser/number.rb', line 82

def underscore
  str("_")
end

#xObject



78
79
80
# File 'lib/query/parser/number.rb', line 78

def x
  str("x") | str("X")
end

#zeroObject



6
7
8
# File 'lib/query/parser/number.rb', line 6

def zero
  str("0")
end