mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-16 22:07:09 +09:00
Add an OpenSCAD syntax file (#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 <jc-git@neniam.net>
This commit is contained in:
53
runtime/syntax/scad.yaml
Normal file
53
runtime/syntax/scad.yaml
Normal file
@@ -0,0 +1,53 @@
|
||||
filetype: OpenSCAD
|
||||
|
||||
# OpenSCAD is a functional programming language used for representing
|
||||
# 2D/3D models for use in the program of the same name.
|
||||
#
|
||||
# The following documents were used as reference material:
|
||||
# https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language
|
||||
# https://openscad.org/cheatsheet/index.html
|
||||
|
||||
detect:
|
||||
filename: "\\.scad$"
|
||||
|
||||
rules:
|
||||
- identifier: "\\b(function|module) +[a-z0-9_]+"
|
||||
|
||||
- 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"
|
||||
|
||||
- symbol: "[,\\.;:?]"
|
||||
- symbol.operator: "[-+*/%^<>!=]|[<=>!]=|&&|\\|\\|"
|
||||
- symbol.brackets: "[{(<>)}]|\\[|\\]"
|
||||
|
||||
# modifiers that change interpretation of the subtree after it
|
||||
- special: "[#%!*]"
|
||||
|
||||
# special variables start with a dollar sign
|
||||
- special: "\\B\\$[a-z]+\\b"
|
||||
|
||||
- preproc:
|
||||
start: "^ *(use|include) <"
|
||||
end: ">;?"
|
||||
rules: []
|
||||
|
||||
- constant.number: "\\b[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?|PI|inf|nan\\b"
|
||||
- constant.bool: "\\b(true|false)\\b"
|
||||
- constant: "\\b(undef)\\b"
|
||||
- constant.string:
|
||||
start: "\""
|
||||
end: "\""
|
||||
skip: "\\\\."
|
||||
rules:
|
||||
- constant.specialChar: "\\\\."
|
||||
|
||||
- comment:
|
||||
start: "//"
|
||||
end: "$"
|
||||
rules:
|
||||
- todo: "(TODO|XXX|FIXME):?"
|
||||
|
||||
- comment:
|
||||
start: "/\\*"
|
||||
end: "\\*/"
|
||||
rules:
|
||||
- todo: "(TODO|XXX|FIXME):?"
|
||||
Reference in New Issue
Block a user