Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: disallow whitespace in identifiers #7

Merged
merged 3 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
const newline = /\r?\n/;
const anything = /[^\r\n]+/;
const number = /[0-9]+(\.[0-9]+)?/;
const word = /[0-9a-z]+/

module.exports = grammar({
name: "ghostty",
Expand All @@ -34,7 +35,7 @@ module.exports = grammar({

basic_directive: $ => directive_seq($.property, $.value),

_kebab_case_identifier : $ => sep1(/[0-9a-z]+/, "-"),
_kebab_case_identifier : $ => sep1(token.immediate(word), token.immediate("-")),
_snake_case_identifier : $ => snake_case_seq(),

property : $ => choice($._kebab_case_identifier),
Expand All @@ -61,7 +62,7 @@ module.exports = grammar({
seq('"', /[^"]*/, '"'),
seq("'", /[^']*/, "'"),
seq(
/[^#]/,
/[^#\s]/,
$._raw_value,
)
)),
Expand Down Expand Up @@ -178,7 +179,7 @@ function hex_color_seq() {
}

function snake_case_seq() {
return sep1(/[0-9a-z]+/, "_");
return seq(word, repeat(seq(token.immediate("_"), token.immediate(word)));
}

function directive_seq(key, value) {
Expand Down
65 changes: 46 additions & 19 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading