Skip to content

Commit cf70e85

Browse files
committed
[Lexer] Store raw 0b supermagically
1 parent 73fe7d5 commit cf70e85

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

source/compiler/lexer.hexa

+1-1
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ class Lexer {
457457
}
458458
}
459459

460-
let string = parseInt(bytes.toString('ascii', position + 2, p), 2).toString()
460+
let string = bytes.toString('ascii', position, p)
461461
addMeta(Token.Integer, string, m)
462462
position = p + offset
463463

source/compiler/parser.hexa

+2-1
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,8 @@ class Parser {
795795
// TODO rename `Default` token to `Empty`
796796
case Default:
797797
let at = i
798-
let v = parseInt(value)
798+
// TODO encode 0b flag into Meta
799+
let v = value.startsWith('0b') ? parseInt(value.substr(2), 2) : parseInt(value)
799800
if v > 2147483647 || v < -2147483647 {
800801
i = at - 1
801802
fail('Integer `\(value)` is too large for *signed* 32 bit, use `\(value)u32` or `\(value)n`')

source/data/token.hexa

+3-3
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,11 @@ enum Token : Int {
217217
return '"string"'
218218
}
219219

220-
if meta == Meta.SingleQuote {
221-
return "'\(param)'"
220+
if meta == Meta.DoubleQuote {
221+
return '"\(param)"'
222222
}
223223

224-
return '"\(param)"'
224+
return "'\(param)'"
225225

226226
case Backtick: return (param == null)? '`backtick`' : '`\(param)`'
227227
case Identifier: return (param == null)? 'identifier' : param

0 commit comments

Comments
 (0)