Skip to content

Commit d8f7928

Browse files
jmcoreyJames Corey
andauthored
Add an OpenSCAD syntax file (zyedidia#3410)
Update from PR feedback: Coalesce multiple statement rules into one. Coalesce multiple constant.number into one. Update from more PR feedback: Fix special variables (starting with $)--var must start with $, i.e. x$y is not a valid special var, but you can have x=$y. Compiled and tested again with latest changes. Co-authored-by: James Corey <[email protected]>
1 parent 2b44fc3 commit d8f7928

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

runtime/syntax/scad.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
filetype: OpenSCAD
2+
3+
# OpenSCAD is a functional programming language used for representing
4+
# 2D/3D models for use in the program of the same name.
5+
#
6+
# The following documents were used as reference material:
7+
# https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language
8+
# https://openscad.org/cheatsheet/index.html
9+
10+
detect:
11+
filename: "\\.scad$"
12+
13+
rules:
14+
- identifier: "\\b(function|module) +[a-z0-9_]+"
15+
16+
- statement: "\\b(abs|acos|asin|assert|atan|atan2|ceil|child|children|chr|circle|color|concat|cos|cross|cube|cylinder|difference|dxf_cross|dxf_dim|each|echo|else|exp|floor|for|function|hull|if|import|import_dxf|intersection|intersection_for|is_bool|is_function|is_list|is_num|is_string|is_undef|len|let|linear_extrude|ln|log|lookup|max|min|minkowski|mirror|module|multmatrix|norm|offset|ord|parent_module|polygon|polyhedron|pow|projection|rands|render|resize|rotate|rotate_extrude|round|scale|search|sign|sin|sphere|sqrt|square|str|surface|tan|text|translate|union|version|version_num)\\b"
17+
18+
- symbol: "[,\\.;:?]"
19+
- symbol.operator: "[-+*/%^<>!=]|[<=>!]=|&&|\\|\\|"
20+
- symbol.brackets: "[{(<>)}]|\\[|\\]"
21+
22+
# modifiers that change interpretation of the subtree after it
23+
- special: "[#%!*]"
24+
25+
# special variables start with a dollar sign
26+
- special: "\\B\\$[a-z]+\\b"
27+
28+
- preproc:
29+
start: "^ *(use|include) <"
30+
end: ">;?"
31+
rules: []
32+
33+
- constant.number: "\\b[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?|PI|inf|nan\\b"
34+
- constant.bool: "\\b(true|false)\\b"
35+
- constant: "\\b(undef)\\b"
36+
- constant.string:
37+
start: "\""
38+
end: "\""
39+
skip: "\\\\."
40+
rules:
41+
- constant.specialChar: "\\\\."
42+
43+
- comment:
44+
start: "//"
45+
end: "$"
46+
rules:
47+
- todo: "(TODO|XXX|FIXME):?"
48+
49+
- comment:
50+
start: "/\\*"
51+
end: "\\*/"
52+
rules:
53+
- todo: "(TODO|XXX|FIXME):?"

0 commit comments

Comments
 (0)