diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lux/compiler/host.clj | 3 | ||||
-rw-r--r-- | src/lux/lexer.clj | 13 |
2 files changed, 13 insertions, 3 deletions
diff --git a/src/lux/compiler/host.clj b/src/lux/compiler/host.clj index e143ff92b..cdd17a1ee 100644 --- a/src/lux/compiler/host.clj +++ b/src/lux/compiler/host.clj @@ -826,6 +826,9 @@ (.visitMethodInsn Opcodes/INVOKEVIRTUAL "java/lang/String" "substring" "(I)Ljava/lang/String;") (.visitTryCatchBlock $from $to $handler "java/lang/Exception") (.visitLabel $from) + (.visitLdcInsn ",|_") + (.visitLdcInsn "") + (.visitMethodInsn Opcodes/INVOKEVIRTUAL "java/lang/String" "replaceAll" "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;") (.visitMethodInsn Opcodes/INVOKESTATIC "java/lang/Long" "parseUnsignedLong" "(Ljava/lang/String;)J") (.visitLabel $to) ;; (.visitJumpInsn Opcodes/GOTO $then) diff --git a/src/lux/lexer.clj b/src/lux/lexer.clj index 690a25106..f52823bfc 100644 --- a/src/lux/lexer.clj +++ b/src/lux/lexer.clj @@ -158,9 +158,16 @@ (return (&/T [meta (<tag> token)])))) lex-bool $Bool #"^(true|false)" - lex-nat $Nat #"^\+(0|[1-9][0-9]*)" - lex-int $Int #"^-?(0|[1-9][0-9]*)" - lex-real $Real #"^-?(0\.[0-9]+|[1-9][0-9]*\.[0-9]+)(e-?[1-9][0-9]*)?" + ) + +(do-template [<name> <tag> <regex>] + (def <name> + (|do [[meta _ token] (&reader/read-regex <regex>)] + (return (&/T [meta (<tag> (string/replace token #",|_" ""))])))) + + lex-nat $Nat #"^\+(0|[1-9][0-9,_]*)" + lex-int $Int #"^-?(0|[1-9][0-9,_]*)" + lex-real $Real #"^-?(0\.[0-9,_]+|[1-9][0-9,_]*\.[0-9,_]+)(e-?[1-9][0-9,_]*)?" ) (def lex-char |