1
0
Fork 0
mirror of https://github.com/pnx/tree-sitter-dotenv synced 2026-06-16 01:54:56 +02:00

adding more number types

This commit is contained in:
Henrik Hautakoski 2024-12-11 00:23:41 +01:00
parent adc9052da5
commit 527ac2368f
5 changed files with 512 additions and 236 deletions

View file

@ -4,7 +4,7 @@
module.exports = grammar({
name: "dotenv",
extras: $ => [
extras: _ => [
/\s/
],
@ -31,7 +31,7 @@ module.exports = grammar({
_value: $ => choice(
$.string,
$.string_interpolation,
$.integer,
$.number,
$.boolean,
$.value,
alias($._empty_value, $.value),
@ -49,10 +49,23 @@ module.exports = grammar({
'"',
),
// Strings
string_content: _ => token(/[^']*/),
string_interpolation_content: _ => token(/[^"]*/),
// Numbers
number: $ => choice(
$.integer,
$.float,
$.hexadecimal,
),
integer: _ => token(/(\-)?\d+/),
float: _ => seq(/(\-)?\d+/, '.', /\d+/),
hexadecimal: _ => seq('0x', /[0-9a-fA-F]+/),
boolean: _ => token(choice('true', 'false')),
value: _ => token(prec(-1, /[^\#\=\s]+/)),