From 2eeb6682e3db5aaba550ebc58a6e1322430c5b17 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sun, 25 Dec 2016 19:51:08 -0400 Subject: - Now, only using underscores (_) as number digit separators, without using commas (,). --- lux-mode/lux-mode.el | 6 +++--- luxc/src/lux/compiler/host.clj | 2 +- luxc/src/lux/lexer.clj | 10 +++++----- stdlib/source/lux/data/number.lux | 3 +-- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/lux-mode/lux-mode.el b/lux-mode/lux-mode.el index 0dcb1247d..5713cfb5d 100644 --- a/lux-mode/lux-mode.el +++ b/lux-mode/lux-mode.el @@ -245,11 +245,11 @@ Called by `imenu--generic-function'." ; Char literals - #"1", #"a", #"\n", #"\u0000" ("#\".+\"" 0 font-lock-constant-face) ; Nat literals - ("\\<\\+\\(0\\|[1-9][0-9,_]*\\)\\>" 0 font-lock-constant-face) + ("\\<\\+\\(0\\|[1-9][0-9_]*\\)\\>" 0 font-lock-constant-face) ; Int|Real literals - ("\\<-?\\(0\\|[1-9][0-9,_]*\\)\\(\\.[0-9,_]+\\)?\\>" 0 font-lock-constant-face) + ("\\<-?\\(0\\|[1-9][0-9_]*\\)\\(\\.[0-9_]+\\)?\\>" 0 font-lock-constant-face) ; Frac literals - ("\\<\\(\\.[0-9,_]+\\)\\>" 0 font-lock-constant-face) + ("\\<\\(\\.[0-9_]+\\)\\>" 0 font-lock-constant-face) ; Tags ("#;[a-zA-Z0-9-\\+_=!@\\$%\\^&\\*<>\.,/\\\\\\|':~\\?]+" 0 font-lock-type-face) ("#;;[a-zA-Z0-9-\\+_=!@\\$%\\^&\\*<>\.,/\\\\\\|':~\\?]+" 0 font-lock-type-face) diff --git a/luxc/src/lux/compiler/host.clj b/luxc/src/lux/compiler/host.clj index ceaa35755..4c2ff9d24 100644 --- a/luxc/src/lux/compiler/host.clj +++ b/luxc/src/lux/compiler/host.clj @@ -1722,7 +1722,7 @@ _ (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "clean_separators" "(Ljava/lang/String;)Ljava/lang/String;" nil nil) (.visitCode) (.visitVarInsn Opcodes/ALOAD 0) - (.visitLdcInsn ",|_") + (.visitLdcInsn "_") (.visitLdcInsn "") (.visitMethodInsn Opcodes/INVOKEVIRTUAL "java/lang/String" "replaceAll" "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;") (.visitInsn Opcodes/ARETURN) diff --git a/luxc/src/lux/lexer.clj b/luxc/src/lux/lexer.clj index f519aa563..819c130f0 100644 --- a/luxc/src/lux/lexer.clj +++ b/luxc/src/lux/lexer.clj @@ -164,12 +164,12 @@ (do-template [ ] (def (|do [[meta _ token] (&reader/read-regex )] - (return (&/T [meta ( (string/replace token #",|_" ""))])))) + (return (&/T [meta ( (string/replace token #"_" ""))])))) - lex-nat $Nat #"^\+(0|[1-9][0-9,_]*)" - lex-int $Int #"^-?(0|[1-9][0-9,_]*)" - lex-frac $Frac #"^(\.[0-9,_]+)" - lex-real $Real #"^-?(0\.[0-9,_]+|[1-9][0-9,_]*\.[0-9,_]+)(e-?[1-9][0-9,_]*)?" + lex-nat $Nat #"^\+(0|[1-9][0-9_]*)" + lex-int $Int #"^-?(0|[1-9][0-9_]*)" + lex-frac $Frac #"^(\.[0-9_]+)" + lex-real $Real #"^-?(0\.[0-9_]+|[1-9][0-9_]*\.[0-9_]+)(e-?[1-9][0-9_]*)?" ) (def lex-char diff --git a/stdlib/source/lux/data/number.lux b/stdlib/source/lux/data/number.lux index 7d33da387..1a104071f 100644 --- a/stdlib/source/lux/data/number.lux +++ b/stdlib/source/lux/data/number.lux @@ -158,8 +158,7 @@ (def: clean-number (-> Text Text) - (|>. (text.replace "," "") - (text.replace "_" ""))) + (text.replace "_" "")) (do-template [ ] [(struct: #export _ (Codec Text ) -- cgit v1.2.3