~ahelwer/tree-sitter-tlaplus

c10ad7e82aa4d77fcb5c4aaec193c9f2dfd3afcb — Andrew Helwer 2 months ago cc72973 main
Add additional checks to release workflow (#107)

* Upgraded release workflow, fixed scanner warnings
Signed-off-by: Andrew Helwer <2n8rn1w1f@mozmail.com>
4 files changed, 38 insertions(+), 27 deletions(-)

M .github/workflows/release.yml
M Cargo.toml
M package.json
M src/scanner.c
M .github/workflows/release.yml => .github/workflows/release.yml +27 -14
@@ 4,8 4,12 @@ on:
    types: [created]

jobs:
  node-module-npmjs:
  publish-packages:
    name: Publish all packages
    runs-on: ubuntu-latest
    environment: release
    permissions:
      id-token: write
    steps:
      - name: Clone repo
        uses: actions/checkout@v4


@@ 13,7 17,9 @@ jobs:
        uses: actions/setup-node@v4
        with:
          registry-url: https://registry.npmjs.org/
      - name: Build
      - name: Use stable rust toolchain
        run: rustup default stable
      - name: Install node.js dependencies
        run: npm install
      - name: Install Emscripten
        uses: mymindstorm/setup-emsdk@v14


@@ 21,20 27,27 @@ jobs:
          version: 3.1.6
      - name: Generate parser WASM
        run: npx tree-sitter build-wasm
      - name: Publish
      - name: Build rust crate
        run: cargo check
      - name: Test NPM publish
        run: npm publish --access public --dry-run
        env:
          NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
      - name: Test crates.io publish
        run: cargo publish --token ${{secrets.CRATES_AUTH_TOKEN}} --dry-run
      - name: Upload WASM to GitHub release
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GH_PAT }}
        with:
          upload_url: ${{ github.event.release.upload_url }}
          asset_path: tree-sitter-tlaplus.wasm
          asset_name: tree-sitter-tlaplus.wasm
          asset_content_type: application/octet-stream
      - name: Publish to NPM
        run: npm publish --access public
        env:
          NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}

  rust-crate:
    runs-on: ubuntu-latest
    steps:
      - name: Clone repo
        uses: actions/checkout@v4
      - name: Use stable rust toolchain
        run: rustup default stable
      - name: Build
        run: cargo check
      - name: Publish
      - name: Publish to crates.io
        run: cargo publish --token ${{secrets.CRATES_AUTH_TOKEN}}


M Cargo.toml => Cargo.toml +1 -1
@@ 1,7 1,7 @@
[package]
name = "tree-sitter-tlaplus"
description = "A tree-sitter grammar for TLA⁺ and PlusCal"
version = "1.2.3"
version = "1.2.4"
authors = ["Andrew Helwer", "Vasiliy Morkovkin"]
license = "MIT"
readme = "README.md"

M package.json => package.json +1 -1
@@ 1,6 1,6 @@
{
  "name": "@tlaplus/tree-sitter-tlaplus",
  "version": "1.2.3",
  "version": "1.2.4",
  "description": "A tree-sitter grammar for TLA⁺ and PlusCal",
  "main": "bindings/node",
  "types": "bindings/node",

M src/scanner.c => src/scanner.c +9 -11
@@ 24,6 24,7 @@
 */
#define ACCEPT_LEXEME(lexeme)       \
  {                                 \
    (void)result;                   \
    result_lexeme = lexeme;         \
  }



@@ 213,7 214,7 @@
      case EMTLexState_SINGLE_LINE:
        consume_codepoint(lexer, '-');
        consume_codepoint(lexer, ' ');
        if (is_next_codepoint_sequence(lexer, "MODULE")) ADVANCE(EMTLexState_MODULE);
        if (is_next_codepoint_sequence(lexer, "MODULE")) { ADVANCE(EMTLexState_MODULE); }
        has_consumed_any = true;
        GO_TO_STATE(EMTLexState_CONSUME);
        END_STATE();


@@ 225,7 226,7 @@
        END_STATE();
      case EMTLexState_END_OF_FILE:
        if (!has_consumed_any) GO_TO_STATE(EMTLexState_BLANK_BEFORE_END_OF_FILE);
        if (valid_symbols[TRAILING_EXTRAMODULAR_TEXT]) ACCEPT_TOKEN(TRAILING_EXTRAMODULAR_TEXT);
        if (valid_symbols[TRAILING_EXTRAMODULAR_TEXT]) { ACCEPT_TOKEN(TRAILING_EXTRAMODULAR_TEXT); }
        END_STATE();
      case EMTLexState_BLANK_BEFORE_END_OF_FILE:
        END_STATE();


@@ 1132,10 1133,9 @@
     * jlist.
     *
     * @param lexer The tree-sitter lexing control structure.
     * @param type The type of junction list.
     * @return Whether a BULLET token was emitted.
     */
    static bool emit_bullet(TSLexer* const lexer, enum JunctType type) {
    static bool emit_bullet(TSLexer* const lexer) {
      lexer->result_symbol = BULLET;
      return true;
    }


@@ 1150,7 1150,7 @@
    static bool emit_dedent(struct Scanner* const this, TSLexer* const lexer) {
      if (is_in_jlist(this)) {
        lexer->result_symbol = DEDENT;
        array_pop(&this->jlists);
        (void)array_pop(&this->jlists);
        return true;
      } else {
        return false;


@@ 1221,7 1221,7 @@
          /**
           * This is another entry in the jlist.
           */
          return emit_bullet(lexer, next_type);
          return emit_bullet(lexer);
        } else {
          /**
           * Disjunct in alignment with conjunct list or vice-versa; treat


@@ 1622,17 1622,15 @@
     *
     * @param this The Scanner state.
     * @param lexer The tree-sitter lexing control structure.
     * @param valid_symbols Tokens possibly expected in this spot.
     * @return Whether a token should be emitted.
     */
    static bool handle_qed_keyword_token(
      struct Scanner* const this,
      TSLexer* const lexer,
      const bool* const valid_symbols
      TSLexer* const lexer
    ) {
      if (is_in_proof(this)) {
        this->last_proof_level = get_current_proof_level(this);
        array_pop(&this->proofs);
        (void)array_pop(&this->proofs);
      }

      lexer->result_symbol = QED_KEYWORD;


@@ 1720,7 1718,7 @@
          case Token_OMITTED_KEYWORD:
            return handle_terminal_proof_keyword_token(this, lexer, valid_symbols, OMITTED_KEYWORD);
          case Token_QED_KEYWORD:
            return handle_qed_keyword_token(this, lexer, valid_symbols);
            return handle_qed_keyword_token(this, lexer);
          case Token_WEAK_FAIRNESS:
            return handle_fairness_keyword_token(this, lexer, col, WEAK_FAIRNESS);
          case Token_STRONG_FAIRNESS: