Skip to content

Commit

Permalink
github worflow & 去除 goto
Browse files Browse the repository at this point in the history
  • Loading branch information
lollipopkit committed Sep 29, 2022
1 parent 45fab65 commit 08c1034
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 37 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/go-releaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: goreleaser

on:
push:

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33 changes: 33 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This is an example .goreleaser.yml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
before:
hooks:
# You may remove this if you don't use go modules.
- go mod download
# you may remove this if you don't need go generate
- go generate ./...
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm
- arm64
goarm:
- 6
- 7

checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,15 @@ if http.listen(':8080', handle) != nil {
## TODO
- 语法
- [x] 注释`//` `/* */`
- [x] 去除`repeat` `until`
- [x] 去除`repeat` `until` `goto`
- [x] Raw String, `\``
- [x] 支持任意对象 Concat
- Table
- [x] key为StringExp,而不是NameExp
- [x] `=` -> `:`, eg: `{a = 'a'}` -> `{a: 'a'}`
- [ ] 改变 `metatable` 设置方式
- 编译器
- [x] 自动添加`range` ( `paris` )
- Table
- [x] key为StringExp,而不是NameExp
- [x] `=` -> `:`, eg: `{a = 'a'}` -> `{a: 'a'}`
- CLI
- [x] 利用HASH,如果文件内容没变化,就不需要重新编译
- [ ] 支持传入参数
- [x] 利用HASH,文件无变化不编译
- [x] 支持传入参数
2 changes: 0 additions & 2 deletions compiler/codegen/cg_stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ func cgStat(fi *funcInfo, node Stat) {
cgLocalVarDeclStat(fi, stat)
case *LocalFuncDefStat:
cgLocalFuncDefStat(fi, stat)
case *LabelStat, *GotoStat:
panic("label and goto statements are not supported!")
}
}

Expand Down
9 changes: 2 additions & 7 deletions compiler/lexer/lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,8 @@ func (self *Lexer) NextToken() (line, kind int, token string) {
self.next(1)
return self.line, TOKEN_OP_LEN, "#"
case ':':
if self.test("::") {
self.next(2)
return self.line, TOKEN_SEP_LABEL, "::"
} else {
self.next(1)
return self.line, TOKEN_SEP_COLON, ":"
}
self.next(1)
return self.line, TOKEN_SEP_COLON, ":"
case '/':
self.next(1)
return self.line, TOKEN_OP_DIV, "/"
Expand Down
3 changes: 0 additions & 3 deletions compiler/lexer/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const (
TOKEN_SEP_COMMA // ,
TOKEN_SEP_DOT // .
TOKEN_SEP_COLON // :
TOKEN_SEP_LABEL // ::
TOKEN_SEP_LPAREN // (
TOKEN_SEP_RPAREN // )
TOKEN_SEP_LBRACK // [
Expand Down Expand Up @@ -45,7 +44,6 @@ const (
TOKEN_KW_FALSE // false
TOKEN_KW_FOR // for
TOKEN_KW_FUNCTION // function
TOKEN_KW_GOTO // goto
TOKEN_KW_IF // if
TOKEN_KW_IN // in
TOKEN_KW_LOCAL // local
Expand All @@ -70,7 +68,6 @@ var keywords = map[string]int{
"false": TOKEN_KW_FALSE,
"for": TOKEN_KW_FOR,
"fn": TOKEN_KW_FUNCTION,
"goto": TOKEN_KW_GOTO,
"if": TOKEN_KW_IF,
"in": TOKEN_KW_IN,
"shy": TOKEN_KW_LOCAL,
Expand Down
19 changes: 0 additions & 19 deletions compiler/parser/parse_stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ func parseStat(lexer *Lexer) Stat {
return parseEmptyStat(lexer)
case TOKEN_KW_BREAK:
return parseBreakStat(lexer)
case TOKEN_SEP_LABEL:
return parseLabelStat(lexer)
case TOKEN_KW_GOTO:
return parseGotoStat(lexer)
case TOKEN_KW_WHILE:
return parseWhileStat(lexer)
case TOKEN_KW_IF:
Expand Down Expand Up @@ -62,21 +58,6 @@ func parseBreakStat(lexer *Lexer) *BreakStat {
return &BreakStat{lexer.Line()}
}

// ‘::’ Name ‘::’
func parseLabelStat(lexer *Lexer) *LabelStat {
lexer.NextTokenOfKind(TOKEN_SEP_LABEL) // ::
_, name := lexer.NextIdentifier() // name
lexer.NextTokenOfKind(TOKEN_SEP_LABEL) // ::
return &LabelStat{name}
}

// goto Name
func parseGotoStat(lexer *Lexer) *GotoStat {
lexer.NextTokenOfKind(TOKEN_KW_GOTO) // goto
_, name := lexer.NextIdentifier() // name
return &GotoStat{name}
}

// while exp do block end
func parseWhileStat(lexer *Lexer) *WhileStat {
lexer.NextTokenOfKind(TOKEN_KW_WHILE) // while
Expand Down
3 changes: 3 additions & 0 deletions test/basic.lk
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ long comment
shy long = '''
abc
'''
goto SKIP
error('never reached')
::SKIP::

if #long >= 0 and '' {
print("hello", #long)
Expand Down

0 comments on commit 08c1034

Please sign in to comment.