| 1 | //Copyright 2013 Vastech SA (PTY) LTD |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package ast |
| 16 | |
| 17 | type LexNTNode interface { |
| 18 | LexNode |
| 19 | Element(int) LexNode |
| 20 | Len() int |
| 21 | Walk(LexNodeVisitor) LexNodeVisitor |
| 22 | } |
| 23 | |
| 24 | // Element |
| 25 | |
| 26 | func (this *LexAlt) Element(i int) LexNode { |
| 27 | return this.Terms[i] |
| 28 | } |
| 29 | |
| 30 | func (this *LexGroupPattern) Element(i int) LexNode { |
| 31 | return this.LexPattern.Alternatives[i] |
| 32 | } |
| 33 | |
| 34 | func (this *LexOptPattern) Element(i int) LexNode { |
| 35 | return this.LexPattern.Alternatives[i] |
| 36 | } |
| 37 | |
| 38 | func (this *LexPattern) Element(i int) LexNode { |
| 39 | return this.Alternatives[i] |
| 40 | } |
| 41 | |
| 42 | func (this *LexRepPattern) Element(i int) LexNode { |
| 43 | return this.LexPattern.Alternatives[i] |
| 44 | } |
| 45 | |
| 46 | // Len |
| 47 | |
| 48 | func (this *LexAlt) Len() int { |
| 49 | return len(this.Terms) |
| 50 | } |
| 51 | |
| 52 | func (this *LexGroupPattern) Len() int { |
| 53 | return len(this.LexPattern.Alternatives) |
| 54 | } |
| 55 | |
| 56 | func (this *LexOptPattern) Len() int { |
| 57 | return len(this.LexPattern.Alternatives) |
| 58 | } |
| 59 | |
| 60 | func (this *LexPattern) Len() int { |
| 61 | return len(this.Alternatives) |
| 62 | } |
| 63 | |
| 64 | func (this *LexRepPattern) Len() int { |
| 65 | return len(this.LexPattern.Alternatives) |
| 66 | } |