commit dc162c015020da4032da000ba22dc48f53b778a5
parent 0c40e01737012026635a59dd783e0cfbe2a7aa6e
Author: Eyal Sawady <ecs@d2evs.net>
Date: Mon, 18 Jan 2021 00:59:41 -0500
Fix highlighting of numbers
- Octal numbers are /0o[0-7]*/, not /0[0-7]*/. This also means that we
don't need to display the leading 0 as something special
- Remove trailing `\>`s. Numbers don't need to be at the end of words -
`1foo` is lexed as T_LITERAL T_NAME
- Standardize on \? instead of \=. They do the same thing
- Disallow floats which start with a dot. The Hare grammar requires a
leading 0 in this case
- Fix a few typos in hareFloat which were causing it not to work
- Remove unused hareNumbersCom
Diffstat:
1 file changed, 7 insertions(+), 14 deletions(-)
diff --git a/syntax/hare.vim b/syntax/hare.vim
@@ -20,22 +20,15 @@ syn region hareString start=+\z(["']\)+ end=+\z1+ skip=+\\\\\|\\\z1+
"adapted from c.vim
"integer number, or floating point number without a dot and with "f".
syn case ignore
-syn match hareNumbers display transparent "\<\d" contains=hareNumber,hareOctalError,hareOctal
-" Same, but without octal error (for comments)
-syn match hareNumbersCom display contained transparent "\<\d\|\.\d" contains=hareNumber,hareFloat,hareOctal
-syn match hareNumber display contained "\d\+\([ziu]\d*\)\?\>"
+syn match hareNumbers display transparent "\<\d" contains=hareNumber,hareOctal,hareFloat
+syn match hareNumber display contained "\d\+\(e[-+]\?\d\+\)\?\([ziu]\d*\)\?"
"hex number
-syn match hareNumber display contained "0x\x\+\([ziu]\d*\)\?\>"
-" Flag the first zero of an octal number as something special
-syn match hareOctal display contained "0\o\+\([ziu]\d*\)\?\>" contains=hareOctalZero
-syn match hareOctalZero display contained "\<0"
-syn match hareFloat display contained "\d\+\(f32\|f64\)"
+syn match hareNumber display contained "0x\x\+\([ziu]\d*\)\?"
+"octal number
+syn match hareOctal display contained "0o\o\+\([ziu]\d*\)\?"
+syn match hareFloat display contained "\d\+\(e[-+]\?\d\+\)\?\(f32\|f64\)"
"floating point number, with dot, optional exponent
-syn match hareFloat display contained "\d\+\.\d+\(e[-+]\=\d\+\)\=\(f32\|f64\)\="
-"floating point number, starting with a dot, optional exponent
-syn match hareFloat display contained "\.\d\+\(e[-+]\=\d\+\)\=\(f32\|f64\)\=\>"
-"floating point number, without dot, with exponent
-syn match hareFloat display contained "\d\+e[-+]\=\d\+\(f32\|f64\)\=\>"
+syn match hareFloat display contained "\d\+\.\d\+\(e[-+]\?\d\+\)\?\(f32\|f64\)\?"
syn keyword hareTodo contained TODO FIXME XXX
syn region hareComment start="//" end="$" contains=hareTodo,@Spell