<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/main/parse.go
diff options
context:
space:
mode:
authorCharlie Stanton <charlie@shtanton.xyz>2023-04-20 12:05:39 +0100
committerCharlie Stanton <charlie@shtanton.xyz>2023-04-20 12:05:39 +0100
commite2774a2ca2d58d4dd507b210d4a62a23a538e833 (patch)
tree4341ba920ebf1d1893a73d37f613bc772c331f73 /main/parse.go
parentc1c33227ab72de1e5f21a08ee74c3df667148343 (diff)
downloadstred-go-e2774a2ca2d58d4dd507b210d4a62a23a538e833.tar
Adds a substitute path command: S
Diffstat (limited to 'main/parse.go')
-rw-r--r--main/parse.go22
1 files changed, 11 insertions, 11 deletions
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{}