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

Buzz programming language syntax #3282

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
57 changes: 57 additions & 0 deletions runtime/syntax/buzz.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
filetype: python
RohanVashisht1234 marked this conversation as resolved.
Show resolved Hide resolved

detect:
filename: "\\.buzz$"

rules:
# built-in objects
- constant: "\\b(range|namespace|typeof|type|zdef|void|static|var|const|extern|import|export|from|test|as|in|while|if|else|fun|try|catch|throw|constructor|return|switch|default|break|for|foreach|do|until|continue|resolve|resume|yield|any|out)\\b"
RohanVashisht1234 marked this conversation as resolved.
Show resolved Hide resolved
# built-in functions
- identifier: "\\b(void|static|var|const|extern|import|export|from|test|as|in|while|if|else|fun|try|catch|throw|constructor|return|switch|default|break|for|foreach|do|until|continue|resolve|resume|yield)\\b"
RohanVashisht1234 marked this conversation as resolved.
Show resolved Hide resolved
# special method names
- identifier: "\\b(!|and|or|band|bor|xor|\\?\\?)\\b"
RohanVashisht1234 marked this conversation as resolved.
Show resolved Hide resolved
# definitions
- identifier: "def [a-zA-Z_0-9]+"
# keywords
- statement: "\\b(and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|raise|return|try|while|with|yield)\\b"
# keywords (declaration)
- statements: "\\b(enum|object|protocol)\\b"
RohanVashisht1234 marked this conversation as resolved.
Show resolved Hide resolved
# constants (true, false, null, this)
- constants: "\\b(true|false|null|this)\\b"
RohanVashisht1234 marked this conversation as resolved.
Show resolved Hide resolved
# constants (types)
- type: "\\b(ud|str|int|float|obj|fib|bool|pat|type|any)\\b\\??"
# decorators
- preproc: "^\\s*@[^(]*"
RohanVashisht1234 marked this conversation as resolved.
Show resolved Hide resolved
# operators
- symbol.operator: "(=|\\+=|\\-=|\\/=|\\*=)"
RohanVashisht1234 marked this conversation as resolved.
Show resolved Hide resolved
# parentheses
- symbol.brackets: "([(){}]|\\[|\\])"
# extra operators
- symbol.operator: "(\\+|\\-|\\/|%|\\*|>>|<<|\\\\|\\^|&|~|!>)"
# Comparision operators
- symbol.operator: "(==|!=|<=?|>=?|\\bis\\b|\\?\\?)"
# numbers
- constant.number: "\\b[0-9](_?[0-9])*(\\.([0-9](_?[0-9])*)?)?(e[0-9](_?[0-9])*)?\\b" # decimal
- constant.number: "\\b0b(_?[01])+\\b" # bin
- constant.number: "\\b0o(_?[0-7])+\\b" # oct
RohanVashisht1234 marked this conversation as resolved.
Show resolved Hide resolved
- constant.number: "\\b0x(_?[0-9a-fA-F])+\\b" # hex

- constant.string:
start: "\""
end: "(\"|$)"
skip: "\\\\."
rules:
- constant.specialChar: "\\\\."

- constant.string:
start: "'"
end: "('|$)"
skip: "\\\\."
rules:
- constant.specialChar: "\\\\."

- comment:
start: "|"
RohanVashisht1234 marked this conversation as resolved.
Show resolved Hide resolved
end: "$"
rules: # AKA Code tags (PEP 350)
- todo: "(TODO|FIXME|HACK|BUG|NOTE|FAQ|MNEMONIC|REQ|RFE|IDEA|PORT|\\?\\?\\?|!!!|GLOSS|SEE|TODOC|STAT|RVD|CRED):?"
RohanVashisht1234 marked this conversation as resolved.
Show resolved Hide resolved