Skip to content

Commit

Permalink
fix: 修正不允许注释夹空行的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
fy0 committed Apr 24, 2024
1 parent 864b2ec commit 90f6c59
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 6 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/test_and_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ jobs:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: stable
go-version: '1.18'

- run: go install github.com/pointlander/[email protected]
- run: peg -switch -inline roll.peg
- run: go mod tidy
Expand All @@ -51,7 +52,7 @@ jobs:
if: github.event.name == 'pull_request'
with:
go-version: '1.18'
version: 'v1.51.2'
version: 'v1.57.2'
args: '--timeout 9999s'
only-new-issues: true
skip-pkg-cache: true
Expand Down
2 changes: 1 addition & 1 deletion jsport/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
package main

import (
"github.com/gopherjs/gopherjs/js"
"regexp"
"strconv"

"github.com/gopherjs/gopherjs/js"
ds "github.com/sealdice/dicescript"
)

Expand Down
2 changes: 1 addition & 1 deletion jsport/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dicescript",
"version": "0.1.2",
"version": "0.1.4",
"description": "Simple script language for TRPG dice engine.",
"module": "./dist/main.mjs",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion roll.peg
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ stmtRoot <- stmtLines sp // stmtLines

stmtLines <- &{!p.Config.DisableStmts} stmtWithBlock stmtLines?
/ flagsSwitch stmtLines?
/ comment stmtLines?
/ comment sp stmtLines?
/ stmtWithSemicolon nextLine?
/ (';' sp)+ stmtLines?

Expand Down
5 changes: 4 additions & 1 deletion roll.peg.go

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

14 changes: 14 additions & 0 deletions rollvm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,20 @@ func TestComment(t *testing.T) {
}
}

func TestComment2(t *testing.T) {
// 发现注释间无法空行,予以修复
vm := NewVM()
err := vm.Run(`
//c1
//c2
a = 1; a`)
assert.NoError(t, err)
assert.Equal(t, vm.RestInput, "")
assert.True(t, valueEqual(vm.Ret, ni(1)))
}

func TestDiceAndSpaceBug(t *testing.T) {
// 一个错误的代码逻辑: 部分算符后需要跟sp1,导致f +1可以工作,但f+1不行
// 但也不能让 f1 被解析为f,剩余文本1
Expand Down

0 comments on commit 90f6c59

Please sign in to comment.