Skip to content

Commit

Permalink
for in 自动添加 range
Browse files Browse the repository at this point in the history
  • Loading branch information
lollipopkit committed Oct 28, 2022
1 parent dd8f087 commit ed7cffb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
10 changes: 10 additions & 0 deletions compiler/parser/parse_stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,16 @@ func _finishForInStat(lexer *Lexer, name0 string) *ForInStat {
lineOfDo, _ := lexer.NextTokenOfKind(TOKEN_SEP_LCURLY) // {
block := parseBlock(lexer) // block
lexer.NextTokenOfKind(TOKEN_SEP_RCURLY) // }
if len(expList) == 1 {
e := expList[0]
expList[0] = &FuncCallExp{
Line: lineOfDo,
LastLine: lineOfDo,
PrefixExp: &NameExp{lineOfDo, "range"},
NameExp: nil,
Args: []Exp{e},
}
}
return &ForInStat{lineOfDo, nameList, expList, block}
}

Expand Down
22 changes: 10 additions & 12 deletions scripts/test.lk
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
import 'table'

dir := 'test/'
files := os.ls(dir)
skip_files := {
'http_listen.lk'
files, err := os.ls(dir)
if err != nil {
print(err)
os.exit(1)
}

contains := fn(name) {
for _, f in skip_files {
if f == name {
rt true
}
}
rt false
skip_files := {
'http_listen.lk'
}

for _, file in files {
if strs.sub(file, #file - 3) != '.lkc' {
if not contains(file) {
if not strs.contains(file, '.lkc') {
if not table.contains(skip_files, file) {
print(fmt('====== %s ======', file))
do_file(dir + file)
}
Expand Down
2 changes: 1 addition & 1 deletion stdlib/lib_string.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var strLib = map[string]GoFunction{
"split": strSplit,
"join": strJoin,
"contains": strContains,
"replace": strReplace,
"replace": strReplace,
}

func OpenStringLib(ls LkState) int {
Expand Down

0 comments on commit ed7cffb

Please sign in to comment.