DepthError reports an error if any of the parsing depths are not zero, to be called at the end of transpiling a complete block of code.
()
| 236 | // DepthError reports an error if any of the parsing depths are not zero, |
| 237 | // to be called at the end of transpiling a complete block of code. |
| 238 | func (sh *Shell) DepthError() error { |
| 239 | if sh.TotalDepth() == 0 { |
| 240 | return nil |
| 241 | } |
| 242 | str := "" |
| 243 | if sh.ParenDepth != 0 { |
| 244 | str += fmt.Sprintf("Incomplete parentheses (), remaining depth: %d\n", sh.ParenDepth) |
| 245 | } |
| 246 | if sh.BraceDepth != 0 { |
| 247 | str += fmt.Sprintf("Incomplete braces [], remaining depth: %d\n", sh.BraceDepth) |
| 248 | } |
| 249 | if sh.BrackDepth != 0 { |
| 250 | str += fmt.Sprintf("Incomplete brackets {}, remaining depth: %d\n", sh.BrackDepth) |
| 251 | } |
| 252 | if str != "" { |
| 253 | slog.Error(str) |
| 254 | return errors.New(str) |
| 255 | } |
| 256 | return nil |
| 257 | } |
| 258 | |
| 259 | // AddLine adds line on the stack |
| 260 | func (sh *Shell) AddLine(ln string) { |
no test coverage detected