<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharlie Stanton <charlie@shtanton.xyz>2023-04-20 09:36:50 +0100
committerCharlie Stanton <charlie@shtanton.xyz>2023-04-20 09:36:50 +0100
commitb95e5ddaa1b182dfe58a386bfc107fa7d95c4393 (patch)
tree41c6e8141e5a7afcbb963e2ce1344bf238c98018
parent6a77b63c3cd4edb992b94e42c5a222a1480a3f33 (diff)
downloadstred-go-b95e5ddaa1b182dfe58a386bfc107fa7d95c4393.tar
Remove the need for a semicolon after each command
-rw-r--r--main/lex.go6
-rw-r--r--main/parse.go8
2 files changed, 3 insertions, 11 deletions
diff --git a/main/lex.go b/main/lex.go
index e82c309..02dd0ee 100644
--- a/main/lex.go
+++ b/main/lex.go
@@ -460,13 +460,9 @@ func lexCommandEnd(l *lexer) stateFunc {
l.emit(TokenEOF)
return nil
}
- if l.accept(";") {
- l.emit(TokenSemicolon)
- return lexCommand
- }
if l.accept("}") {
l.emit(TokenRBrace)
return lexCommandEnd
}
- return l.errorf("Expected ; found something else")
+ return lexCommand
}
diff --git a/main/parse.go b/main/parse.go
index 8211444..e0272e8 100644
--- a/main/parse.go
+++ b/main/parse.go
@@ -307,14 +307,10 @@ func (p *parser) parseCommands() []Command {
return commands
}
commands = append(commands, p.parseCommand())
- semicolon := p.next()
- if semicolon.typ == TokenEOF || semicolon.typ == TokenRBrace {
- p.rewind(semicolon)
+ endToken := p.peek()
+ if endToken.typ == TokenEOF || endToken.typ == TokenRBrace {
return commands
}
- if semicolon.typ != TokenSemicolon {
- panic("Expected ; after command")
- }
}
}