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

Fixes #234

Merged
merged 7 commits into from
Sep 23, 2024
Merged

Fixes #234

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
5 changes: 5 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import treesitter from 'eslint-config-treesitter';

export default [
...treesitter,
];
41 changes: 19 additions & 22 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ module.exports = grammar({
),

attribute_specifier: $ => seq(
'__attribute__',
choice('__attribute__', '__attribute'),
'(',
$.argument_list,
')',
Expand Down Expand Up @@ -623,6 +623,7 @@ module.exports = grammar({
'long',
'short',
)),
repeat($.type_qualifier),
field('type', optional(choice(
prec.dynamic(-1, $._type_identifier),
$.primitive_type,
Expand Down Expand Up @@ -828,7 +829,7 @@ module.exports = grammar({

// This is missing binary expressions, others were kept so that macro code can be parsed better and code examples
_top_level_expression_statement: $ => seq(
$._expression_not_binary,
optional($._expression_not_binary),
';',
),

Expand Down Expand Up @@ -1162,7 +1163,7 @@ module.exports = grammar({
)),
field('constraint', $.string_literal),
'(',
field('value', $.identifier),
field('value', $.expression),
')',
),

Expand Down Expand Up @@ -1318,7 +1319,7 @@ module.exports = grammar({
choice(
/[^xuU]/,
/\d{2,3}/,
/x[0-9a-fA-F]{2,}/,
/x[0-9a-fA-F]{1,4}/,
/u[0-9a-fA-F]{4}/,
/U[0-9a-fA-F]{8}/,
),
Expand All @@ -1335,7 +1336,6 @@ module.exports = grammar({
null: _ => choice('NULL', 'nullptr'),

identifier: _ =>
// eslint-disable-next-line max-len
/(\p{XID_Start}|\$|_|\\u[0-9A-Fa-f]{4}|\\U[0-9A-Fa-f]{8})(\p{XID_Continue}|\$|\\u[0-9A-Fa-f]{4}|\\U[0-9A-Fa-f]{8})*/,

_type_identifier: $ => alias(
Expand Down Expand Up @@ -1379,16 +1379,15 @@ module.exports.PREC = PREC;
*
* @param {number} precedence
*
* @return {RuleBuilders<string, string>}
* @returns {RuleBuilders<string, string>}
*/
function preprocIf(suffix, content, precedence = 0) {
/**
*
* @param {GrammarSymbols<string>} $
*
* @return {ChoiceRule}
*
*/
*
* @param {GrammarSymbols<string>} $
*
* @returns {ChoiceRule}
*/
function alternativeBlock($) {
return choice(
suffix ? alias($['preproc_else' + suffix], $.preproc_else) : $.preproc_else,
Expand Down Expand Up @@ -1438,12 +1437,12 @@ function preprocIf(suffix, content, precedence = 0) {
}

/**
* Creates a preprocessor regex rule
*
* @param {RegExp|Rule|String} command
*
* @return {AliasRule}
*/
* Creates a preprocessor regex rule
*
* @param {RegExp | Rule | string} command
*
* @returns {AliasRule}
*/
function preprocessor(command) {
return alias(new RegExp('#[ \t]*' + command), '#' + command);
}
Expand All @@ -1453,8 +1452,7 @@ function preprocessor(command) {
*
* @param {Rule} rule
*
* @return {ChoiceRule}
*
* @returns {ChoiceRule}
*/
function commaSep(rule) {
return optional(commaSep1(rule));
Expand All @@ -1465,8 +1463,7 @@ function commaSep(rule) {
*
* @param {Rule} rule
*
* @return {SeqRule}
*
* @returns {SeqRule}
*/
function commaSep1(rule) {
return seq(rule, repeat(seq(',', rule)));
Expand Down
Loading