@@ -167,7 +167,7 @@ func NewLvalueParser(reader *StringReader) *LvalueParser {
167
167
168
168
type StringReader struct {
169
169
i int
170
- pos [][] interface {} // (lnum, col int)
170
+ pos []pos
171
171
buf []string
172
172
}
173
173
@@ -177,10 +177,52 @@ func NewStringReader(lines []string) *StringReader {
177
177
return obj
178
178
}
179
179
180
+ func (self * StringReader ) __init__ (lines []string ) {
181
+ size := 0
182
+ for _ , l := range lines {
183
+ size += len (l ) + 1 // +1 for EOL
184
+ }
185
+ self .buf = make ([]string , 0 , size )
186
+ self .pos = make ([]pos , 0 , size + 1 ) // +1 for EOF
187
+ var lnum = 0
188
+ for lnum < len (lines ) {
189
+ var col = 0
190
+ for _ , r := range lines [lnum ] {
191
+ c := string (r )
192
+ self .buf = append (self .buf , c )
193
+ self .pos = append (self .pos , pos {lnum : lnum + 1 , col : col + 1 })
194
+ col += len (c )
195
+ }
196
+ for lnum + 1 < len (lines ) && viml_eqregh (lines [lnum + 1 ], "^\\ s*\\ \\ " ) {
197
+ var skip = true
198
+ col = 0
199
+ for _ , r := range lines [lnum + 1 ] {
200
+ c := string (r )
201
+ if skip {
202
+ if c == "\\ " {
203
+ skip = false
204
+ }
205
+ } else {
206
+ self .buf = append (self .buf , c )
207
+ self .pos = append (self .pos , pos {lnum : lnum + 2 , col : col + 1 })
208
+ }
209
+ col += len (c )
210
+ }
211
+ lnum += 1
212
+ }
213
+ self .buf = append (self .buf , "<EOL>" )
214
+ self .pos = append (self .pos , pos {lnum : lnum + 1 , col : col + 1 })
215
+ lnum += 1
216
+ }
217
+ // for <EOF>
218
+ self .pos = append (self .pos , pos {lnum : lnum + 1 , col : 0 })
219
+ self .i = 0
220
+ }
221
+
180
222
func (self * StringReader ) getpos () * pos {
181
- var p = self .pos [self .i ]
182
- var lnum , col = p [ 0 ].( int ), p [ 1 ].( int )
183
- return & pos { i : self . i , lnum : lnum , col : col }
223
+ p : = self .pos [self .i ]
224
+ p . i = self . i
225
+ return & p
184
226
}
185
227
186
228
type Compiler struct {
@@ -200,7 +242,7 @@ func (self *Compiler) __init__() {
200
242
}
201
243
202
244
func (self * Compiler ) out (f string , args ... interface {}) {
203
- if viml_len (args ) == 0 {
245
+ if len (args ) == 0 {
204
246
if string (f [0 ]) == ")" {
205
247
self .lines [len (self .lines )- 1 ] += f
206
248
} else {
0 commit comments