<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/main/lex.go
diff options
context:
space:
mode:
authorCharlie Stanton <charlie@shtanton.xyz>2023-04-26 15:02:03 +0100
committerCharlie Stanton <charlie@shtanton.xyz>2023-04-26 15:02:03 +0100
commit39f767aef901694eef14b1004b13756410f19f66 (patch)
treec26adf90b296c1e0f4029b9867fc7b71a7de20fd /main/lex.go
parent1aa08f927c7043a643e847c434399fc76d053df0 (diff)
downloadstred-go-39f767aef901694eef14b1004b13756410f19f66.tar
Add labels and branches with the : and b commands
Diffstat (limited to 'main/lex.go')
-rw-r--r--main/lex.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/main/lex.go b/main/lex.go
index f28244d..198c346 100644
--- a/main/lex.go
+++ b/main/lex.go
@@ -118,6 +118,7 @@ const (
TokenCommand // A command character
TokenSubstituteDelimiter // usually / but could be something else
TokenSubex // A subex
+ TokenLabel // A label
)
type Token struct {
@@ -182,6 +183,9 @@ func lexCommand(l *lexer) stateFunc {
case 's', 'S', 'f', 'F', 'l', 'L', 'a', 'A':
l.emit(TokenCommand)
return lexSubstitution
+ case ':', 'b':
+ l.emit(TokenCommand)
+ return lexLabel
}
if isAlpha(r) {
l.emit(TokenCommand)
@@ -212,3 +216,9 @@ func lexSubstitution(l *lexer) stateFunc {
}
return lexCommand
}
+
+func lexLabel(l *lexer) stateFunc {
+ l.next()
+ l.emit(TokenLabel)
+ return lexCommand
+}