<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/main/lex.go
diff options
context:
space:
mode:
authorCharlie Stanton <charlie@shtanton.xyz>2024-04-07 15:27:36 +0100
committerCharlie Stanton <charlie@shtanton.xyz>2024-04-07 15:27:36 +0100
commit658900fcae610caace83a112ac0ee865108ebc92 (patch)
tree4d7b6bebe0d192abf62970ca4324ef1ff274e3c8 /main/lex.go
parent81925b6ad5212512d27365b8224b76095191431f (diff)
downloadstred-go-658900fcae610caace83a112ac0ee865108ebc92.tar
Change output subex internals to allow structures
Also add substitute register syntactic sugar
Diffstat (limited to 'main/lex.go')
-rw-r--r--main/lex.go35
1 files changed, 21 insertions, 14 deletions
diff --git a/main/lex.go b/main/lex.go
index 496abd0..a28975f 100644
--- a/main/lex.go
+++ b/main/lex.go
@@ -171,21 +171,28 @@ func lexCommand(l *lexer) stateFunc {
l.ignore()
r := l.next()
switch r {
- case eof:
- l.emit(TokenEOF)
- return nil
- case '{':
- l.emit(TokenLBrace)
- return lexCommand
- case '}':
- l.emit(TokenRBrace)
- return lexCommand
- case 's', 'S':
- l.emit(TokenCommand)
+ case eof:
+ l.emit(TokenEOF)
+ return nil
+ case '{':
+ l.emit(TokenLBrace)
+ return lexCommand
+ case '}':
+ l.emit(TokenRBrace)
+ return lexCommand
+ case 's', 'S':
+ l.emit(TokenCommand)
+ return lexSubstitution
+ case 'x', 'X', 'y', 'Y', 'z', 'Z':
+ l.emit(TokenCommand)
+ if l.peek() == '/' {
return lexSubstitution
- case ':', 'b':
- l.emit(TokenCommand)
- return lexLabel
+ } else {
+ return lexCommand
+ }
+ case ':', 'b':
+ l.emit(TokenCommand)
+ return lexLabel
}
if isAlpha(r) {
l.emit(TokenCommand)