@@ -126,15 +126,40 @@ export default function(hljs) {
126126 { begin : "'" , end : "'" , relevance : 0 }
127127 ] ,
128128 } ,
129-
130129 {
131130 className : 'number' ,
132131 variants : [
133- // Special case: only hexadecimal binary powers can contain fractions.
134- { begin : / (?< ! [ a - z A - Z 0 - 9 . _ ] ) 0 [ x X ] [ 0 - 9 a - f A - F ] + \. [ 0 - 9 a - f A - F ] * [ p P ] [ + - ] ? \d + i ? / } ,
135- { begin : / (?< ! [ a - z A - Z 0 - 9 . _ ] ) 0 [ x X ] [ 0 - 9 a - f A - F ] + ( [ p P ] [ + - ] ? \d + ) ? [ L i ] ? / } ,
136- { begin : / (?< ! [ a - z A - Z 0 - 9 . _ ] ) ( \d + ( \. \d * ) ? | \. \d + ) ( [ e E ] [ + - ] ? \d + ) ? [ L i ] ? / }
132+ // TODO: replace with negative look-behind when available
133+ // { begin: /(?<![a-zA-Z0-9._])0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/ },
134+ // { begin: /(?<![a-zA-Z0-9._])0[xX][0-9a-fA-F]+([pP][+-]?\d+)?[Li]?/ },
135+ // { begin: /(?<![a-zA-Z0-9._])(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?[Li]?/ }
136+
137+ // The below rules all eat an extra character in front (for the
138+ // look-behind check) and then exclude it from the match, but I think
139+ // in many cases this will work out just fine.
140+ {
141+ // Special case: only hexadecimal binary powers can contain fractions.
142+ begin : / ( [ ^ a - z A - Z 0 - 9 . _ ] ) (? = 0 [ x X ] [ 0 - 9 a - f A - F ] + \. [ 0 - 9 a - f A - F ] * [ p P ] [ + - ] ? \d + i ? ) / ,
143+ end : / 0 [ x X ] [ 0 - 9 a - f A - F ] + \. [ 0 - 9 a - f A - F ] * [ p P ] [ + - ] ? \d + i ? / ,
144+ excludeBegin : true
145+ } ,
146+ {
147+ begin : / ( [ ^ a - z A - Z 0 - 9 . _ ] ) (? = 0 [ x X ] [ 0 - 9 a - f A - F ] + ( [ p P ] [ + - ] ? \d + ) ? [ L i ] ? ) / ,
148+ end : / 0 [ x X ] [ 0 - 9 a - f A - F ] + ( [ p P ] [ + - ] ? \d + ) ? [ L i ] ? / ,
149+ excludeBegin : true
150+ } ,
151+ {
152+ begin : / ( [ ^ a - z A - Z 0 - 9 . _ ] ) (? = ( \d + ( \. \d * ) ? | \. \d + ) ( [ e E ] [ + - ] ? \d + ) ? [ L i ] ? ) / ,
153+ end : / ( \d + ( \. \d * ) ? | \. \d + ) ( [ e E ] [ + - ] ? \d + ) ? [ L i ] ? / ,
154+ excludeBegin : true
155+ }
137156 ] ,
157+ // "on:begin": (match, response) => {
158+ // if (match.index > 0) {
159+ // let priorChar = match.input[match.index - 1];
160+ // if (priorChar.match(/[a-zA-Z0-9._]/)) response.ignoreMatch();
161+ // }
162+ // },
138163 relevance : 0
139164 } ,
140165
0 commit comments