diff options
Diffstat (limited to 'subex/parse.go')
-rw-r--r-- | subex/parse.go | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/subex/parse.go b/subex/parse.go index 59b784d..1d64c20 100644 --- a/subex/parse.go +++ b/subex/parse.go @@ -4,7 +4,7 @@ import ( "main/walk" ) -func expectBracket(l *RuneReader, ifLeft walk.Datum, ifRight walk.Datum) walk.Datum { +func expectBracket(l *RuneReader, ifLeft walk.Atom, ifRight walk.Atom) walk.Atom { switch l.next() { case '(': return ifLeft @@ -15,8 +15,8 @@ func expectBracket(l *RuneReader, ifLeft walk.Datum, ifRight walk.Datum) walk.Da } } -// Having just read termType, read in a bracket and return the corresponding walk.Datum -func parseTerminatorDatumLiteral(termType rune, l *RuneReader) walk.Datum { +// Having just read termType, read in a bracket and return the corresponding Atom +func parseTerminatorAtomLiteral(termType rune, l *RuneReader) walk.Atom { switch termType { case '@': return expectBracket(l, walk.ArrayBegin, walk.ArrayEnd) @@ -43,21 +43,21 @@ func parseReplacement(l *RuneReader) (output []TransducerOutput) { if slot == eof { panic("Missing slot character") } - output = append(output, TransducerReplacementLoad{datum: slot}) + output = append(output, TransducerReplacementLoad{atom: slot}) case '@', '~', '#': - output = append(output, TransducerReplacementRune{datum: parseTerminatorDatumLiteral(r, l)}) + output = append(output, TransducerReplacementAtom{atom: parseTerminatorAtomLiteral(r, l)}) default: - output = append(output, TransducerReplacementRune{datum: r}) + output = append(output, TransducerReplacementAtom{atom: r}) } } return output } // Parse the contents of a range subex [] into a map -func parseRangeSubex(l *RuneReader) map[walk.Datum]walk.Datum { +func parseRangeSubex(l *RuneReader) map[walk.Atom]walk.Atom { // TODO escaping - parts := make(map[walk.Datum]walk.Datum) - var froms []walk.Datum + parts := make(map[walk.Atom]walk.Atom) + var froms []walk.Atom var hasTo bool for { fromsStart := l.next() @@ -68,9 +68,9 @@ func parseRangeSubex(l *RuneReader) map[walk.Datum]walk.Datum { hasTo = true break } else { - datum := parseTerminatorDatumLiteral(fromsStart, l) - if datum != nil { - froms = append(froms, datum) + atom := parseTerminatorAtomLiteral(fromsStart, l) + if atom != nil { + froms = append(froms, atom) continue } } @@ -91,16 +91,16 @@ func parseRangeSubex(l *RuneReader) map[walk.Datum]walk.Datum { panic("Missing from part of range expression") } - var tos []walk.Datum + var tos []walk.Atom if hasTo { for { tosStart := l.next() if tosStart == ']' { break } else { - datum := parseTerminatorDatumLiteral(tosStart, l) - if datum != nil { - tos = append(tos, datum) + atom := parseTerminatorAtomLiteral(tosStart, l) + if atom != nil { + tos = append(tos, atom) continue } } @@ -166,9 +166,9 @@ func parseSubex(l *RuneReader, minPower int) SubexAST { case '.': lhs = SubexASTCopyAny{} case '@', '#', '~': - lhs = SubexASTCopyRune{datum: parseTerminatorDatumLiteral(r, l)} + lhs = SubexASTCopyAtom{atom: parseTerminatorAtomLiteral(r, l)} default: - lhs = SubexASTCopyRune{datum: r} + lhs = SubexASTCopyAtom{atom: r} } loop: for { if minPower <= 0 { |