From 619b8b57afc265789be233a68f1d985afc3841ca Mon Sep 17 00:00:00 2001 From: "Jip J. Dekker" Date: Mon, 5 Feb 2018 17:20:45 +1100 Subject: [PATCH] Add numeric patterns --- minizinc.iro | 80 +++++++++++++++++++--------------------------------- 1 file changed, 29 insertions(+), 51 deletions(-) diff --git a/minizinc.iro b/minizinc.iro index d39f62b..4f11e24 100644 --- a/minizinc.iro +++ b/minizinc.iro @@ -78,53 +78,9 @@ contexts [] { ############################################## main : context { - - : pattern { - regex \= $${__MY_CONSTANT} - styles [] = .keyword; - } - - : include "numeric" ; - - : inline_push { - regex \= (\{) - styles [] = .punctuation; - : pop { - regex \= (\}) - styles [] = .punctuation; - } - : include "main" ; - } - - : pattern { - regex \= (;) - styles [] = .punctuation; - } - - : inline_push { - regex \= (\") - styles [] = .punctuation; - default_style = .text - : pop { - regex \= (\") - styles [] = .punctuation; - } - } - - : inline_push { - regex \= (\() - styles [] = .punctuation; - : pop { - regex \= (\)) - styles [] = .punctuation; - } - : include "numeric" ; - : pattern { - regex \= (,) - styles [] = .punctuation; - } - } - + ####################################### + ## Comment Patterns + ####################################### : include "multi_line_comment"; : pattern { @@ -132,10 +88,10 @@ main : context { styles [] = .comment; } - : pattern { - regex \= ([^\s]) - styles [] = .illegal; - } + ####################################### + ## Literal Patterns + ####################################### + : include "numeric"; } @@ -149,11 +105,33 @@ main : context { numeric : context { : pattern { + description = integer number regex \= (\b\d+) styles [] = .numeric; } + : pattern { + description = octal integer number + regex \= (\b0o[0-7]+) + styles [] = .numeric; + } + : pattern { + description = hexadecimal number + regex \= (\b0x[0-9A-Fa-f]+) + styles [] = .numeric; + } + : pattern { + description = hexadecimal number + regex \= (\b0x[0-9A-Fa-f]+) + styles [] = .numeric; + } + : pattern { + description = floating point number + regex \= (\b\d+(.\d+|(.\d+)?[Ee][-+]?\d+)) + styles [] = .numeric, .numeric, .numeric; + } } + ########################################### ## Multi Line Comment Context ###########################################