<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/main/parse.go
diff options
context:
space:
mode:
Diffstat (limited to 'main/parse.go')
-rw-r--r--main/parse.go54
1 files changed, 3 insertions, 51 deletions
diff --git a/main/parse.go b/main/parse.go
index cbbfb9a..141ae7e 100644
--- a/main/parse.go
+++ b/main/parse.go
@@ -71,61 +71,13 @@ func (p *parser) parseBasicCommand(commands []Command, commandChar rune) []Comma
return append(commands, NextCommand{})
case 'N':
return append(commands, AppendNextCommand{})
- case 's', 'S', 'f', 'F', 'l', 'L', 'a', 'A':
+ case 's', 'S':
ast := p.parseSubex()
- switch commandChar {
- case 'f':
- ast = subex.SubexASTConcat {
- First: ast,
- Second: subex.SubexASTRepeat {
- Content: subex.SubexASTCopyAny{},
- Acceptable: []subex.ConvexRange{{Start: -1, End: 0}},
- },
- }
- case 'F':
- ast = subex.SubexASTConcat {
- First: subex.SubexASTStore {
- Slot: '_',
- Match: ast,
- },
- Second: subex.SubexASTRepeat {
- Content: subex.SubexASTCopyAny{},
- Acceptable: []subex.ConvexRange{{Start: -1, End: 0}},
- },
- }
- case 'l':
- ast = subex.SubexASTConcat {
- First: subex.SubexASTRepeat {
- Content: subex.SubexASTCopyAny{},
- Acceptable: []subex.ConvexRange{{Start: 0, End: -1}},
- },
- Second: ast,
- }
- case 'L':
- ast = subex.SubexASTConcat {
- First: subex.SubexASTRepeat {
- Content: subex.SubexASTCopyAny{},
- Acceptable: []subex.ConvexRange{{Start: 0, End: -1}},
- },
- Second: subex.SubexASTStore {
- Slot: '_',
- Match: ast,
- },
- }
- case 'a', 'A':
- ast = subex.SubexASTRepeat {
- Acceptable: []subex.ConvexRange{{Start: -1, End: 0}},
- Content: subex.SubexASTOr {
- First: ast,
- Second: subex.SubexASTCopyAny{},
- },
- }
- }
subex := subex.CompileTransducer(ast)
switch commandChar {
- case 's', 'a':
+ case 's':
return append(commands, SubstituteValueCommand {subex}, JumpCommand {len(commands) + 3})
- case 'S', 'f', 'F', 'l', 'L', 'A':
+ case 'S':
return append(commands, SubstitutePathCommand {subex}, JumpCommand {len(commands) + 3})
default:
panic("Unreachable!?!?")