Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
ObserverOfTime committed Mar 4, 2024
1 parent c373351 commit a2e446a
Show file tree
Hide file tree
Showing 18 changed files with 887 additions and 1,169 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,13 @@ jobs:
uses: tree-sitter/[email protected]
with:
test-library: ${{runner.os == 'Linux'}}
corpus-files: examples/*
invalid-files: examples/invalid.tst
- name: Check for scanner changes
uses: tj-actions/changed-files@v42
id: scanner-check
with:
files: src/scanner.c
- name: Fuzz scanner
uses: tree-sitter/fuzz-action@v4
if: steps.scanner-check.outputs.any_changed == 'true'
1 change: 1 addition & 0 deletions Package.swift

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

1 change: 1 addition & 0 deletions binding.gyp

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

1 change: 1 addition & 0 deletions bindings/go/binding.go

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

4 changes: 4 additions & 0 deletions bindings/rust/build.rs

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

17 changes: 17 additions & 0 deletions bindings/rust/lib.rs

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

39 changes: 39 additions & 0 deletions examples/attributes.tst
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
=========================
Test that will be skipped
:skip
=========================

int main() {}

-------------------------

====================================
Test that will run on Linux or macOS

:platform(linux)
:platform(macos)
====================================

int main() {}

------------------------------------

========================================================================
Test that expects an error, and will fail fast if there's no parse error
:fail-fast
:error
========================================================================

int main ( {}

------------------------------------------------------------------------

=================================================
Test that will parse with both Typescript and TSX
:language(typescript)
:language(tsx)
=================================================

console.log('Hello, world!');

-------------------------------------------------
9 changes: 9 additions & 0 deletions examples/invalid.tst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
==================|||
Invalid suffix
==================|||

foo

---||

(foo)
17 changes: 17 additions & 0 deletions examples/simple.tst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
==================
Return statements
==================

func x() int {
return 1;
}

---

(source_file
(function_definition
(identifier)
(parameter_list)
(primitive_type)
(block
(return_statement (number)))))
15 changes: 15 additions & 0 deletions examples/suffix.tst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
==================|||
Basic module
==================|||

---- MODULE Test ----
increment(n) == n + 1
====

---|||

(source_file
(module (identifier)
(operator (identifier)
(parameter_list (identifier))
(plus (identifier_ref) (number)))))
48 changes: 28 additions & 20 deletions grammar.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
/// <reference types="./types/dsl" />
// @ts-check

const I = token.immediate;

module.exports = grammar({
name: "test",

externals: $ => [
$._equals_begin,
$._equals_end,
$._extra_delimiter_equals_begin,
$._extra_delimiter_equals_end,
$._extra_delimiter_dashes,
$._equals_begin_ext,
$._equals_end_ext,
$._suffix_equals_begin,
$._suffix_equals_end,
$._suffix_dashes,
$.__error_recovery,
],

Expand All @@ -22,19 +20,16 @@ module.exports = grammar({

test: $ => seq(
$.header,
optional(alias(/.+/, $.input)),
alias(repeat1(/./), $.input),
alias($._dashes, $.separator),
optional(alias($._extra_delimiter_dashes, $.extra_delimiter)),
optional(alias(/.+/, $.output)),
alias(repeat(/./), $.output),
),

header: $ => seq(
alias($._equals_begin, $.separator),
optional(alias($._extra_delimiter_equals_begin, $.extra_delimiter)),
alias(/[^\r\n]+/, $.name),
alias(repeat1(/[^\r\n]/), $.name),
optional($.attributes),
alias($._equals_end, $.separator),
optional(alias($._extra_delimiter_equals_end, $.extra_delimiter)),
),

attributes: $ => repeat1(
Expand All @@ -55,21 +50,21 @@ module.exports = grammar({

language: $ => seq(
":language",
I("("),
token.immediate("("),
alias($._lang, $.parameter),
I(")")
token.immediate(")")
),

platform: $ => seq(
":platform",
I("("),
token.immediate("("),
alias($._os, $.parameter),
I(")")
token.immediate(")")
),

_lang: _ => I(repeat1(/[\w.-]/)),
_lang: _ => token.immediate(repeat1(/[\w.-]/)),

_os: _ => I(choice(
_os: _ => token.immediate(choice(
"linux",
"macos",
"ios",
Expand All @@ -82,6 +77,19 @@ module.exports = grammar({
"windows",
)),

_dashes: _ => token(prec(1, seq("---", repeat("-"))))
_equals_begin: $ => prec(1, seq(
$._equals_begin_ext,
optional($._suffix_equals_begin)
)),

_equals_end: $ => prec(1, seq(
$._equals_end_ext,
optional($._suffix_equals_end)
)),

_dashes: $ => prec(1, seq(
token(seq("---", repeat("-"))),
optional($._suffix_dashes)
)),
}
});
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
{
"scope": "text.test",
"highlights": "queries/highlights.scm",
"injections": "queries/injections.scm"
"injections": "queries/injections.scm",
"file-types": ["tst"]
}
]
}
1 change: 1 addition & 0 deletions setup.py

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

Loading

0 comments on commit a2e446a

Please sign in to comment.