@@ -81,28 +81,28 @@ module Impl {
8181 // https://doc.rust-lang.org/reference/tokens.html#integer-literals
8282 private module IntegerLiteralRegexs {
8383 bindingset [ s]
84- string paren ( string s ) { result = "(" + s + ")" }
84+ string paren ( string s ) { result = "(?: " + s + ")" }
8585
8686 string integerLiteral ( ) {
8787 result =
8888 paren ( paren ( decLiteral ( ) ) + "|" + paren ( binLiteral ( ) ) + "|" + paren ( octLiteral ( ) ) + "|" +
89- paren ( hexLiteral ( ) ) ) + paren ( suffix ( ) ) + "?"
89+ paren ( hexLiteral ( ) ) ) + "(" + suffix ( ) + ") ?"
9090 }
9191
9292 private string suffix ( ) { result = "u8|i8|u16|i16|u32|i32|u64|i64|u128|i128|usize|isize" }
9393
94- string decLiteral ( ) { result = decDigit ( ) + "(" + decDigit ( ) + "|_)*" }
94+ string decLiteral ( ) { result = decDigit ( ) + "(?: " + decDigit ( ) + "|_)*" }
9595
9696 string binLiteral ( ) {
97- result = "0b(" + binDigit ( ) + "|_)*" + binDigit ( ) + "(" + binDigit ( ) + "|_)*"
97+ result = "0b(?: " + binDigit ( ) + "|_)*" + binDigit ( ) + "(?: " + binDigit ( ) + "|_)*"
9898 }
9999
100100 string octLiteral ( ) {
101- result = "0o(" + octDigit ( ) + "|_)*" + octDigit ( ) + "(" + octDigit ( ) + "|_)*"
101+ result = "0o(?: " + octDigit ( ) + "|_)*" + octDigit ( ) + "(?: " + octDigit ( ) + "|_)*"
102102 }
103103
104104 string hexLiteral ( ) {
105- result = "0x(" + hexDigit ( ) + "|_)*" + hexDigit ( ) + "(" + hexDigit ( ) + "|_)*"
105+ result = "0x(?: " + hexDigit ( ) + "|_)*" + hexDigit ( ) + "(?: " + hexDigit ( ) + "|_)*"
106106 }
107107
108108 string decDigit ( ) { result = "[0-9]" }
@@ -135,7 +135,7 @@ module Impl {
135135 exists ( string s , string reg |
136136 s = this .getTextValue ( ) and
137137 reg = IntegerLiteralRegexs:: integerLiteral ( ) and
138- result = s .regexpCapture ( reg , 13 )
138+ result = s .regexpCapture ( reg , 1 )
139139 )
140140 }
141141
@@ -153,24 +153,25 @@ module Impl {
153153 }
154154
155155 string floatLiteralSuffix1 ( ) {
156- result = decLiteral ( ) + "\\." + decLiteral ( ) + paren ( suffix ( ) ) + "?"
156+ result = decLiteral ( ) + "\\." + decLiteral ( ) + "(" + suffix ( ) + ") ?"
157157 }
158158
159159 string floatLiteralSuffix2 ( ) {
160160 result =
161- decLiteral ( ) + paren ( "\\." + decLiteral ( ) ) + "?" + paren ( exponent ( ) ) + paren ( suffix ( ) ) + "?"
161+ decLiteral ( ) + paren ( "\\." + decLiteral ( ) ) + "?" + paren ( exponent ( ) ) + "(" + suffix ( ) + ") ?"
162162 }
163163
164164 string integerSuffixLiteral ( ) {
165165 result =
166166 paren ( paren ( decLiteral ( ) ) + "|" + paren ( binLiteral ( ) ) + "|" + paren ( octLiteral ( ) ) + "|" +
167- paren ( hexLiteral ( ) ) ) + paren ( suffix ( ) )
167+ paren ( hexLiteral ( ) ) ) + "(" + suffix ( ) + ")"
168168 }
169169
170170 private string suffix ( ) { result = "f32|f64" }
171171
172172 string exponent ( ) {
173- result = "(e|E)(\\+|-)?(" + decDigit ( ) + "|_)*" + decDigit ( ) + "(" + decDigit ( ) + "|_)*"
173+ result =
174+ "(?:e|E)(?:\\+|-)?(?:" + decDigit ( ) + "|_)*" + decDigit ( ) + "(?:" + decDigit ( ) + "|_)*"
174175 }
175176 }
176177
@@ -198,18 +199,13 @@ module Impl {
198199 * For example, `42.0f32` has the suffix `f32`.
199200 */
200201 string getSuffix ( ) {
201- exists ( string s , string reg , int group |
202- reg = FloatLiteralRegexs:: floatLiteralSuffix1 ( ) and
203- group = 3
204- or
205- reg = FloatLiteralRegexs:: floatLiteralSuffix2 ( ) and
206- group = 9
207- or
208- reg = FloatLiteralRegexs:: integerSuffixLiteral ( ) and
209- group = 13
210- |
202+ exists ( string s , string reg |
203+ reg =
204+ IntegerLiteralRegexs:: paren ( FloatLiteralRegexs:: floatLiteralSuffix1 ( ) ) + "|" +
205+ IntegerLiteralRegexs:: paren ( FloatLiteralRegexs:: floatLiteralSuffix2 ( ) ) + "|" +
206+ IntegerLiteralRegexs:: paren ( FloatLiteralRegexs:: integerSuffixLiteral ( ) ) and
211207 s = this .getTextValue ( ) and
212- result = s .regexpCapture ( reg , group )
208+ result = s .regexpCapture ( reg , [ 1 , 2 , 3 ] )
213209 )
214210 }
215211
0 commit comments