From b588f9a4c590a5e1a7f243be3d2ec64ade6aaad2 Mon Sep 17 00:00:00 2001 From: Benjamin Bannier Date: Fri, 10 Feb 2023 18:05:47 +0100 Subject: [PATCH] Expose booleans in the grammar --- corpus/test | 6 ++++-- grammar.js | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/corpus/test b/corpus/test index 65a99ca..1fa942f 100644 --- a/corpus/test +++ b/corpus/test @@ -50,13 +50,15 @@ function foo() (initializer (init_class) (expr - (constant)))) + (constant + (boolean))))) (const_decl (id) (initializer (init_class) (expr - (constant)))) + (constant + (boolean))))) (type_decl (id) (type)) diff --git a/grammar.js b/grammar.js index db4e2b6..f0c74c1 100644 --- a/grammar.js +++ b/grammar.js @@ -270,8 +270,7 @@ module.exports = grammar({ prec_l(seq($.ipv4, optional(seq('/', /[0-9]+/)))), prec_l(seq($.ipv6, optional(seq('/', /[0-9]+/)))), $.hostname, - 'T', - 'F', + $.boolean, $.hex, $.port, $.interval, @@ -346,6 +345,8 @@ module.exports = grammar({ floatp: _ => /(([0-9]*\.?[0-9]+)|([0-9]+\.[0-9]*))([eE][-+]?[0-9]+)?/, hex: _ => /0x[0-9a-fA-F]+/, + boolean: _ => choice('T', 'F'), + // For some reason I need to call out integers as a choice here // explicitly -- floatp's ability to parse an integer doesn't trigger. interval: $ => seq(choice($.integer, $.floatp), $.time_unit),