From e2774a2ca2d58d4dd507b210d4a62a23a538e833 Mon Sep 17 00:00:00 2001 From: Charlie Stanton Date: Thu, 20 Apr 2023 12:05:39 +0100 Subject: Adds a substitute path command: S --- main/parse.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'main/parse.go') diff --git a/main/parse.go b/main/parse.go index e9dd012..7c87d15 100644 --- a/main/parse.go +++ b/main/parse.go @@ -33,13 +33,6 @@ func (p *parser) peek() Token { return token } -var segmentTokens map[TokenType]bool = map[TokenType]bool { - TokenHash: true, - TokenAt: true, - TokenDot: true, - TokenLBrack: true, -} - func (p *parser) parseSubex() subex.SubexState { delim := p.next() if delim.typ != TokenSubstituteDelimiter { @@ -69,7 +62,7 @@ func (p *parser) parseBasicCommand(commandChar rune) Command { return NextCommand{} case 'N': return AppendNextCommand{} - case 's': + case 's', 'S': subex := p.parseSubex() var next Command token := p.peek() @@ -79,9 +72,16 @@ func (p *parser) parseBasicCommand(commandChar rune) Command { default: next = p.parseCommand() } - return SubstituteCommand { - subex: subex, - next: next, + if (commandChar == 's') { + return SubstituteValueCommand { + subex: subex, + next: next, + } + } else { + return SubstitutePathCommand { + subex: subex, + next: next, + } } case 'o': return NoopCommand{} -- cgit v1.2.3