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

Added syntax for Bend programming language #3330

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions runtime/syntax/bend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Author: https://github.com/RohanVashisht1234
filetype: bend

detect:
filename: "\\.bend$"

rules:
# keywords
- statement: "\\b(def|switch|case|return|if|else|when|match|λ|Some|data|let|use|object|fold|open|do|bind|Name|identity|Bool|ask|with)\\b"
# special method names
- symbol.operator: "\\b(bend|None|Nil|Result|type|lambda)\\b"
# definitions
- identifier: "def [a-zA-Z_0-9]+"
# keywords (declaration)
- statement: "\\b(Node|Leaf|Tree)\\b"
# constants (true, false, null, this)
- constant: "\\b(true|false|True|False)\\b"
# constants (types)
- type: "\\b(ud|str|int|float|obj|fib|bool|pat|type|any)\\b\\??"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried looking at this file but I do not think these types are in Bend:
https://github.com/HigherOrderCO/Bend/blob/main/docs/builtins.md

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry added -type thing, but can we keep true false? because people do use true false in bend by declaring this on their side.

Copy link
Contributor

@niten94 niten94 Jul 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I did not mean removing the pattern matching true and false but I realized there is null and this in the comment even though those are not highlighted. The types at the link I referenced can still be higlighted.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, fixed that because the null and this isn't a actual type in bend afaik

# parentheses
- symbol.brackets: "([(){}]|\\[|\\])"
# extra operators
- symbol.operator: "(\\+|\\-|\\/|%|\\*|>>|<<|\\\\|\\^|&|~|!>)"
# Comparision operators
- symbol.operator: "(==|!=|<=?|>=?|\\bis\\b|\\?\\?)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried looking at documentation and examples a bit but is the is operator in Bend syntax?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I have removed is

# 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: "\\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: "\\#"
end: "$"
rules:
- todo: "(TODO|FIXME|HACK|BUG|NOTE|FAQ|MNEMONIC|REQ|RFE|IDEA|PORT|\\?\\?\\?|!!!|GLOSS|SEE|TODOC|STAT|RVD|CRED):?"