| 1 | //Copyright 2012 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 astscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/ |
| 16 | |
| 17 | import ( |
| 18 | "strconvscip-go gomod github.com/golang/go/src go1.24 strconv/" |
| 19 | "stringsscip-go gomod github.com/golang/go/src go1.24 strings/" |
| 20 | |
| 21 | "github.com/goccmack/gocc/example/bools/tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/" |
| 22 | "github.com/goccmack/gocc/example/bools/utilscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/util`/" |
| 23 | ) |
| 24 | |
| 25 | type Attribscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/Attrib# interface{} |
| 26 | |
| 27 | type Valscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/Val# interface { |
| 28 | Attribscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/Attrib# |
| 29 | Evalscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/Val#Eval.() bool |
| 30 | Stringscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/Val#String.() string |
| 31 | } |
| 32 | |
| 33 | type Opscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/Op# int |
| 34 | |
| 35 | func (o Opscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/Op#) Stringscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/Op#String().() string { |
| 36 | switch o { |
| 37 | case ORscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/OR.: |
| 38 | return "|" |
| 39 | case ANDscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/AND.: |
| 40 | return "&" |
| 41 | } |
| 42 | return "" |
| 43 | } |
| 44 | |
| 45 | const ( |
| 46 | NOOPscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/NOOP. = Opscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/Op#(0) |
| 47 | ORscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/OR. = Opscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/Op#(1) |
| 48 | ANDscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/AND. = Opscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/Op#(2) |
| 49 | ) |
| 50 | |
| 51 | type BoolExprscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/BoolExpr# struct { |
| 52 | Ascip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/BoolExpr#A. Valscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/Val# |
| 53 | Bscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/BoolExpr#B. Valscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/Val# |
| 54 | Opscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/BoolExpr#Op. Opscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/Op# |
| 55 | } |
| 56 | |
| 57 | func NewBoolAndExprscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/NewBoolAndExpr().(a, b Attribscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/Attrib#) (*BoolExprscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/BoolExpr#, error) { |
| 58 | return &BoolExprscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/BoolExpr#{a.(Valscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/Val#), b.(Valscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/Val#), ANDscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/AND.}, nil |
| 59 | } |
| 60 | |
| 61 | func NewBoolOrExprscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/NewBoolOrExpr().(a, b Attribscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/Attrib#) (*BoolExprscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/BoolExpr#, error) { |
| 62 | return &BoolExprscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/BoolExpr#{a.(Valscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/Val#), b.(Valscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/Val#), ORscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/OR.}, nil |
| 63 | } |
| 64 | |
| 65 | func NewBoolGroupExprscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/NewBoolGroupExpr().(a Attribscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/Attrib#) (*BoolExprscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/BoolExpr#, error) { |
| 66 | return &BoolExprscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/BoolExpr#{a.(Valscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/Val#), nil, NOOPscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/NOOP.}, nil |
| 67 | } |
| 68 | |
| 69 | func (this *BoolExprscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/BoolExpr#) Evalscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/BoolExpr#Eval().() bool { |
| 70 | switch this.Opscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/BoolExpr#Op. { |
| 71 | case ORscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/OR.: |
| 72 | return this.Ascip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/BoolExpr#A..Evalscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/Val#Eval.() || this.Bscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/BoolExpr#B..Evalscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/Val#Eval.() |
| 73 | case ANDscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/AND.: |
| 74 | return this.Ascip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/BoolExpr#A..Evalscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/Val#Eval.() && this.Bscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/BoolExpr#B..Evalscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/Val#Eval.() |
| 75 | } |
| 76 | return this.Ascip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/BoolExpr#A..Evalscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/Val#Eval.() |
| 77 | } |
| 78 | |
| 79 | func (this *BoolExprscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/BoolExpr#) Stringscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/BoolExpr#String().() string { |
| 80 | return this.Ascip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/BoolExpr#A..Stringscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/Val#String.() + " " + this.Opscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/BoolExpr#Op..Stringscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/Op#String().() + " " + this.Bscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/BoolExpr#B..Stringscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/Val#String.() |
| 81 | } |
| 82 | |
| 83 | type valscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/val# bool |
| 84 | |
| 85 | func (v valscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/val#) Evalscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/val#Eval().() bool { |
| 86 | return bool(v) |
| 87 | } |
| 88 | |
| 89 | func (v valscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/val#) Stringscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/val#String().() string { |
| 90 | if v { |
| 91 | return "true" |
| 92 | } |
| 93 | return "false" |
| 94 | } |
| 95 | |
| 96 | var ( |
| 97 | TRUEscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/TRUE. = valscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/val#(true) |
| 98 | FALSEscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/FALSE. = valscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/val#(false) |
| 99 | ) |
| 100 | |
| 101 | type LessThanExprscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/LessThanExpr# struct { |
| 102 | Ascip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/LessThanExpr#A. int64 |
| 103 | Bscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/LessThanExpr#B. int64 |
| 104 | } |
| 105 | |
| 106 | func NewLessThanExprscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/NewLessThanExpr().(a, b Attribscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/Attrib#) (*LessThanExprscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/LessThanExpr#, error) { |
| 107 | aint, err := utilscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/util`/.IntValuescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/util`/IntValue().(a.(*tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/.Tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/Token#).Litscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/Token#Lit.) |
| 108 | if err != nil { |
| 109 | return nil, err |
| 110 | } |
| 111 | bint, err := utilscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/util`/.IntValuescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/util`/IntValue().(b.(*tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/.Tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/Token#).Litscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/Token#Lit.) |
| 112 | if err != nil { |
| 113 | return nil, err |
| 114 | } |
| 115 | return &LessThanExprscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/LessThanExpr#{aint, bint}, nil |
| 116 | } |
| 117 | |
| 118 | func (this *LessThanExprscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/LessThanExpr#) Evalscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/LessThanExpr#Eval().() bool { |
| 119 | return this.Ascip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/LessThanExpr#A. < this.Bscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/LessThanExpr#B. |
| 120 | } |
| 121 | |
| 122 | func (this *LessThanExprscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/LessThanExpr#) Stringscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/LessThanExpr#String().() string { |
| 123 | return strconvscip-go gomod github.com/golang/go/src go1.24 strconv/.FormatIntscip-go gomod github.com/golang/go/src go1.24 strconv/FormatInt().(this.Ascip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/LessThanExpr#A., 10) + " < " + strconvscip-go gomod github.com/golang/go/src go1.24 strconv/.FormatIntscip-go gomod github.com/golang/go/src go1.24 strconv/FormatInt().(this.Bscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/LessThanExpr#B., 10) |
| 124 | } |
| 125 | |
| 126 | type SubStringExprscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/SubStringExpr# struct { |
| 127 | Ascip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/SubStringExpr#A. string |
| 128 | Bscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/SubStringExpr#B. string |
| 129 | } |
| 130 | |
| 131 | func NewSubStringExprscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/NewSubStringExpr().(a, b Attribscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/Attrib#) (*SubStringExprscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/SubStringExpr#, error) { |
| 132 | astr, err := strconvscip-go gomod github.com/golang/go/src go1.24 strconv/.Unquotescip-go gomod github.com/golang/go/src go1.24 strconv/Unquote().(string(a.(*tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/.Tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/Token#).Litscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/Token#Lit.)) |
| 133 | if err != nil { |
| 134 | return nil, err |
| 135 | } |
| 136 | bstr, err := strconvscip-go gomod github.com/golang/go/src go1.24 strconv/.Unquotescip-go gomod github.com/golang/go/src go1.24 strconv/Unquote().(string(b.(*tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/.Tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/Token#).Litscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/token`/Token#Lit.)) |
| 137 | if err != nil { |
| 138 | return nil, err |
| 139 | } |
| 140 | return &SubStringExprscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/SubStringExpr#{astr, bstr}, nil |
| 141 | } |
| 142 | |
| 143 | func (this *SubStringExprscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/SubStringExpr#) Evalscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/SubStringExpr#Eval().() bool { |
| 144 | return stringsscip-go gomod github.com/golang/go/src go1.24 strings/.Containsscip-go gomod github.com/golang/go/src go1.24 strings/Contains().(this.Bscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/SubStringExpr#B., this.Ascip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/SubStringExpr#A.) |
| 145 | } |
| 146 | |
| 147 | func (this *SubStringExprscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/SubStringExpr#) Stringscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/SubStringExpr#String().() string { |
| 148 | return this.Ascip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/SubStringExpr#A. + " in " + this.Bscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/example/bools/ast`/SubStringExpr#B. |
| 149 | } |