Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
9 changes: 5 additions & 4 deletions Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 21 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,28 @@ The grammar currently integrates with these editors:

Given the polyglot nature of ObjectScript `.cls` files, it's recommended to ensure the following tree-sitter grammars are installed and available for injection:

- SQL
- HTML
- Python
- JavaScript
- SQL
- HTML
- Python
- JavaScript
- CSS
- XML
- Markdown

All of these grammars are all available as Rust crates (and in other languages as well).
For example, if I want to include these grammars in my rust project,
I would simply add these under dependencies in my Cargo.Toml file:
```Cargo
tree-sitter-html = "0.23.2"
tree-sitter-javascript = "0.25.0"
tree-sitter-python = "0.25.0"
tree-sitter-css = "0.25.0"
tree-sitter-sql = "0.0.2"
tree-sitter-xml = "0.7.0"
tree-sitter-md = "0.5.1"
```


## Screenshots

### Zed
Expand Down Expand Up @@ -133,13 +147,13 @@ Since there are three parsers, you'll need to cd into the directory containing t

#### Build the Parser(s)

From the parser directory, generate the state machines from the grammar and compile the native parser:
From the grammar directory, generate the state machines from the grammar and compile the native parser:
```bash
tree-sitter generate
tree-sitter build
```

**NOTE**: Use `tree-sitter --wasm` when using the playground to test the grammar.
**NOTE**: Use `tree-sitter build --wasm` when using the playground to test the grammar.

#### Running Tests

Expand Down Expand Up @@ -204,4 +218,4 @@ Once you have those prereqs complete, run `npm install` and then `npm test`
From the root directory run `go get github.com/tree-sitter/[email protected]` and then run `go test ./bindings/go/...`

### C
Run `make test`
Run `make test`
2 changes: 1 addition & 1 deletion bindings/rust/build.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 22 additions & 42 deletions bindings/rust/lib.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions cargo_readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# tree-sitter-objectscript

ObjectScript Grammars for [tree-sitter](https://github.com/tree-sitter/tree-sitter).

This crate provides ObjectScript, ObjectScript Core (routines), and ObjectScript Expr (expressions) language support for the tree-sitter parsing library.

There are three grammars:
1. **objectscript** - this is the overall grammar. This extends the other
two grammars, and should be used for .cls files.
2. **objectscript_core**: Represents ObjectScript "routine" syntax.
3. **objectscript_expr**: Represents ObjectScript expressions.

See [docs.rs](https://docs.rs/tree-sitter-objectscript/latest/tree_sitter_objectscript/)
for information on how to access the languages and their associated query files.

11 changes: 6 additions & 5 deletions common/scanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,14 @@ static inline void skip (TSLexer *lexer) { lexer->advance(lexer, true ); }
#define MARKER_BUFFER_MAX_LEN 30
struct ObjectScript_Core_Scanner {
int32_t marker_buffer[MARKER_BUFFER_MAX_LEN];
char marker_buffer_len;
int marker_buffer_len;
bool at_bol;
};

static bool ObjectScript_Core_Scanner_lex_fenced_text(
void *payload, TSLexer *lexer,
enum ObjectScript_Core_Scanner_TokenType desired_symbol, char l_delim,
TSLexer *lexer,
enum ObjectScript_Core_Scanner_TokenType desired_symbol,
char l_delim,
char r_delim) {
int leftRightDiff = 1;
while (!lexer->eof(lexer)) {
Expand Down Expand Up @@ -373,12 +374,12 @@ ObjectScript_Core_Scanner_scan(struct ObjectScript_Core_Scanner *scanner,
}
} else if (valid_symbols[ANGLED_BRACKET_FENCED_TEXT]) {
bool ok = ObjectScript_Core_Scanner_lex_fenced_text(
scanner, lexer, ANGLED_BRACKET_FENCED_TEXT, '<', '>');
lexer, ANGLED_BRACKET_FENCED_TEXT, '<', '>');
if (ok) scanner->at_bol = false;
return ok;
} else if (valid_symbols[PAREN_FENCED_TEXT]) {
bool ok = ObjectScript_Core_Scanner_lex_fenced_text(
scanner, lexer, PAREN_FENCED_TEXT, '(', ')');
lexer, PAREN_FENCED_TEXT, '(', ')');
if (ok) scanner->at_bol = false;
return ok;
} else if (valid_symbols[EMBEDDED_SQL_MARKER]) {
Expand Down
11 changes: 0 additions & 11 deletions core/.gitattributes

This file was deleted.

4 changes: 2 additions & 2 deletions core/src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading