Skip to content

Commit

Permalink
Expose booleans in the grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
bbannier committed Mar 18, 2023
1 parent e5f8cb2 commit b588f9a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions corpus/test
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
5 changes: 3 additions & 2 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit b588f9a

Please sign in to comment.