github.com/jingcheng-WU/gonum@v0.9.1-0.20210323123734-f1a2a11a8f7b/graph/formats/dot/internal/parser/action.go (about) 1 // Code generated by gocc; DO NOT EDIT. 2 3 // This file is dual licensed under CC0 and The Gonum License. 4 // 5 // Copyright ©2017 The Gonum Authors. All rights reserved. 6 // Use of this source code is governed by a BSD-style 7 // license that can be found in the LICENSE file. 8 // 9 // Copyright ©2017 Robin Eklind. 10 // This file is made available under a Creative Commons CC0 1.0 11 // Universal Public Domain Dedication. 12 13 package parser 14 15 import ( 16 "fmt" 17 ) 18 19 type action interface { 20 act() 21 String() string 22 } 23 24 type ( 25 accept bool 26 shift int // value is next state index 27 reduce int // value is production index 28 ) 29 30 func (this accept) act() {} 31 func (this shift) act() {} 32 func (this reduce) act() {} 33 34 func (this accept) Equal(that action) bool { 35 if _, ok := that.(accept); ok { 36 return true 37 } 38 return false 39 } 40 41 func (this reduce) Equal(that action) bool { 42 that1, ok := that.(reduce) 43 if !ok { 44 return false 45 } 46 return this == that1 47 } 48 49 func (this shift) Equal(that action) bool { 50 that1, ok := that.(shift) 51 if !ok { 52 return false 53 } 54 return this == that1 55 } 56 57 func (this accept) String() string { return "accept(0)" } 58 func (this shift) String() string { return fmt.Sprintf("shift:%d", this) } 59 func (this reduce) String() string { 60 return fmt.Sprintf("reduce:%d(%s)", this, productionsTable[this].String) 61 }