Skip to content

Commit 03a5cbc

Browse files
authored
feat: Add Arduino support (#202)
1 parent 2084954 commit 03a5cbc

File tree

6 files changed

+123
-1
lines changed

6 files changed

+123
-1
lines changed

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,3 +466,9 @@
466466
branch = master
467467
update = none
468468
ignore = dirty
469+
[submodule "repos/arduino"]
470+
path = repos/arduino
471+
url = https://github.com/ObserverOfTime/tree-sitter-arduino
472+
branch = master
473+
update = none
474+
ignore = dirty

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Changelog
22

33
## Unreleased
4+
- Add `Arduino` support
45

56
## 0.12.65 - 2023-10-10
67
- Fix `HLSL` highlighting

queries/arduino/highlights.scm

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
; inherits: cpp
2+
3+
((identifier) @function.builtin
4+
(#any-of? @function.builtin
5+
; Digital I/O
6+
"digitalRead"
7+
"digitalWrite"
8+
"pinMode"
9+
; Analog I/O
10+
"analogRead"
11+
"analogReference"
12+
"analogWrite"
13+
; Zero, Due & MKR Family
14+
"analogReadResolution"
15+
"analogWriteResolution"
16+
; Advanced I/O
17+
"noTone"
18+
"pulseIn"
19+
"pulseInLong"
20+
"shiftIn"
21+
"shiftOut"
22+
"tone"
23+
; Time
24+
"delay"
25+
"delayMicroseconds"
26+
"micros"
27+
"millis"
28+
; Math
29+
"abs"
30+
"constrain"
31+
"map"
32+
"max"
33+
"min"
34+
"pow"
35+
"sq"
36+
"sqrt"
37+
; Trigonometry
38+
"cos"
39+
"sin"
40+
"tan"
41+
; Characters
42+
"isAlpha"
43+
"isAlphaNumeric"
44+
"isAscii"
45+
"isControl"
46+
"isDigit"
47+
"isGraph"
48+
"isHexadecimalDigit"
49+
"isLowerCase"
50+
"isPrintable"
51+
"isPunct"
52+
"isSpace"
53+
"isUpperCase"
54+
"isWhitespace"
55+
; Random Numbers
56+
"random"
57+
"randomSeed"
58+
; Bits and Bytes
59+
"bit"
60+
"bitClear"
61+
"bitRead"
62+
"bitSet"
63+
"bitWrite"
64+
"highByte"
65+
"lowByte"
66+
; External Interrupts
67+
"attachInterrupt"
68+
"detachInterrupt"
69+
; Interrupts
70+
"interrupts"
71+
"noInterrupts"
72+
))
73+
74+
((identifier) @type.builtin
75+
(#any-of? @type.builtin
76+
"Serial"
77+
"SPI"
78+
"Stream"
79+
"Wire"
80+
"Keyboard"
81+
"Mouse"
82+
"String"
83+
))
84+
85+
((identifier) @constant.builtin
86+
(#any-of? @constant.builtin
87+
"HIGH"
88+
"LOW"
89+
"INPUT"
90+
"OUTPUT"
91+
"INPUT_PULLUP"
92+
"LED_BUILTIN"
93+
))
94+
95+
(function_definition
96+
(function_declarator
97+
declarator: (identifier) @function.builtin)
98+
(#any-of? @function.builtin "loop" "setup"))
99+
100+
(call_expression
101+
function: (primitive_type) @function.builtin)
102+
103+
(call_expression
104+
function: (identifier) @constructor
105+
(#any-of? @constructor "SPISettings" "String"))
106+
107+
(declaration
108+
(type_identifier) @type.builtin
109+
(function_declarator
110+
declarator: (identifier) @constructor)
111+
(#eq? @type.builtin "SPISettings"))

repos/arduino

Submodule arduino added at db929fc

tree-sitter-langs-build.el

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,8 @@ infrequent (grammar-only changes). It is different from the version of
247247
"List of suffixes for shared libraries that define tree-sitter languages.")
248248

249249
(defconst tree-sitter-langs--langs-with-deps
250-
'( cpp
250+
'( arduino
251+
cpp
251252
commonlisp
252253
hlsl
253254
glsl

tree-sitter-langs.el

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ See `tree-sitter-langs-repos'."
101101
'((ada-mode . ada)
102102
(agda-mode . agda)
103103
(agda2-mode . agda)
104+
(arduino-mode . arduino)
104105
(fasm-mode . asm)
105106
(masm-mode . asm)
106107
(nasm-mode . asm)
@@ -220,6 +221,7 @@ Return nil if there are no bundled patterns."
220221
;; TODO: Make this less ad-hoc.
221222
(dolist (sym (cons lang-symbol
222223
(pcase lang-symbol
224+
('arduino '(cpp c))
223225
('cpp '(c))
224226
('hlsl '(cpp c))
225227
('typescript '(javascript))

0 commit comments

Comments
 (0)