-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
grammar.js
38 lines (31 loc) · 927 Bytes
/
grammar.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* @file Arduino grammar for tree-sitter
* @author ObserverOfTime
* @license MIT
*/
/// <reference types="tree-sitter-cli/dsl" />
// @ts-check
const CPP = require('tree-sitter-cpp/grammar');
module.exports = grammar(CPP, {
name: 'arduino',
rules: {
primitive_type: (_, og) => choice(og, 'byte', 'word'),
type_qualifier: (_, og) => choice(og, 'PROGMEM'),
number_literal: (_, og) => choice(og, /B[01]{1,8}/),
constructor_or_destructor_definition: $ => prec.left(seq(
repeat($._constructor_specifiers),
field('declarator', $.function_declarator),
choice(
seq(
optional($.field_initializer_list),
field('body', $.compound_statement),
optional(';')
),
alias($.constructor_try_statement, $.try_statement),
$.default_method_clause,
$.delete_method_clause,
$.pure_virtual_clause,
),
)),
}
});