From 39f767aef901694eef14b1004b13756410f19f66 Mon Sep 17 00:00:00 2001 From: Charlie Stanton Date: Wed, 26 Apr 2023 15:02:03 +0100 Subject: Add labels and branches with the : and b commands --- main/lex.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'main/lex.go') 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 +} -- cgit v1.2.3