github.com/goplus/gogen@v1.16.0/token/token.go (about)

     1  /*
     2   Copyright 2024 The GoPlus Authors (goplus.org)
     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       http://www.apache.org/licenses/LICENSE-2.0
     7   Unless required by applicable law or agreed to in writing, software
     8   distributed under the License is distributed on an "AS IS" BASIS,
     9   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    10   See the License for the specific language governing permissions and
    11   limitations under the License.
    12  */
    13  
    14  package token
    15  
    16  import (
    17  	"go/token"
    18  )
    19  
    20  // Token is the set of lexical tokens of the Go/Go+ programming language.
    21  type Token = token.Token
    22  
    23  const (
    24  	additional_beg = token.TILDE - 1
    25  	additional_end = token.TILDE + 1
    26  
    27  	SRARROW   = additional_beg // -> (single right arrow)
    28  	BIDIARROW = additional_end // <> (bidirectional arrow)
    29  )
    30  
    31  func String(tok Token) string {
    32  	if tok >= additional_beg {
    33  		switch tok {
    34  		case SRARROW:
    35  			return "->"
    36  		case BIDIARROW:
    37  			return "<>"
    38  		}
    39  	}
    40  	return tok.String()
    41  }