Documentation ¶
Overview ¶
Graphics operators
Arithmetic and Math Operators ¶
Miscellaneous Operators ¶
Operand Stack Manipulation Operators ¶
Copyright 2009 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. postscript scanner derived form the scanner package of go sources
Index ¶
- Constants
- func TokenString(tok int) string
- type Dictionary
- type DictionaryStack
- type Interpreter
- func (interpreter *Interpreter) ClearDictionaries()
- func (interpreter *Interpreter) ClearOperands()
- func (interpreter *Interpreter) Define(name string, value Value)
- func (interpreter *Interpreter) DictionaryStackSize() int
- func (interpreter *Interpreter) Execute(reader io.Reader)
- func (interpreter *Interpreter) ExecuteFile(filePath string) error
- func (interpreter *Interpreter) FindValue(name string) Value
- func (interpreter *Interpreter) FindValueInDictionaries(name string) (Value, Dictionary)
- func (interpreter *Interpreter) Get(index int) Value
- func (interpreter *Interpreter) GetGraphicContext() draw2d.GraphicContext
- func (interpreter *Interpreter) GetValues(n int) []Value
- func (interpreter *Interpreter) OperandSize() int
- func (interpreter *Interpreter) Peek() Value
- func (interpreter *Interpreter) PeekDictionary() Dictionary
- func (interpreter *Interpreter) Pop() Value
- func (interpreter *Interpreter) PopArray() []Value
- func (interpreter *Interpreter) PopBoolean() bool
- func (interpreter *Interpreter) PopDictionary() Dictionary
- func (interpreter *Interpreter) PopFloat() float64
- func (interpreter *Interpreter) PopInt() int
- func (interpreter *Interpreter) PopName() string
- func (interpreter *Interpreter) PopOperator() Operator
- func (interpreter *Interpreter) PopProcedureDefinition() *ProcedureDefinition
- func (interpreter *Interpreter) PopString() string
- func (interpreter *Interpreter) PopValues(n int) []Value
- func (interpreter *Interpreter) Push(operand Value)
- func (interpreter *Interpreter) PushDictionary(dictionary Dictionary)
- func (interpreter *Interpreter) SetGraphicContext(gc draw2d.GraphicContext)
- func (interpreter *Interpreter) SystemDefine(name string, value Value)
- func (interpreter *Interpreter) SystemDictionary() Dictionary
- func (interpreter *Interpreter) UserDictionary() Dictionary
- type Mark
- type Operator
- type OperatorFunc
- type Position
- type PrimitiveOperator
- type Procedure
- type ProcedureDefinition
- type Scanner
- type Value
- type ValueStack
Constants ¶
const ( ScanIdents = 1 << -Ident ScanInts = 1 << -Int ScanFloats = 1 << -Float // includes Ints ScanChars = 1 << -Char ScanStrings = 1 << -String ScanRawStrings = 1 << -RawString ScanComments = 1 << -Comment SkipComments = 1 << -skipComment // if set with ScanComments, comments become white space GoTokens = ScanIdents | ScanFloats | ScanChars | ScanStrings | ScanRawStrings | ScanComments | SkipComments )
Predefined mode bits to control recognition of tokens. For instance, to configure a Scanner such that it only recognizes (Go) identifiers, integers, and skips comments, set the Scanner's Mode field to:
ScanIdents | ScanInts | SkipComments
const ( EOF = -(iota + 1) Ident Int Float Char String RawString Comment )
The result of Scan is one of the following tokens or a Unicode character.
const GoWhitespace = 1<<'\t' | 1<<'\n' | 1<<'\r' | 1<<' '
GoWhitespace is the default value for the Scanner's Whitespace field. Its value selects Go's white space characters.
Variables ¶
This section is empty.
Functions ¶
func TokenString ¶
TokenString returns a (visible) string for a token or Unicode character.
Types ¶
type Dictionary ¶
func NewDictionary ¶
func NewDictionary(prealloc int) Dictionary
type DictionaryStack ¶
type DictionaryStack []Dictionary
type Interpreter ¶
type Interpreter struct {
// contains filtered or unexported fields
}
func NewInterpreter ¶
func NewInterpreter(gc draw2d.GraphicContext) *Interpreter
func (*Interpreter) ClearDictionaries ¶
func (interpreter *Interpreter) ClearDictionaries()
func (*Interpreter) ClearOperands ¶
func (interpreter *Interpreter) ClearOperands()
func (*Interpreter) Define ¶
func (interpreter *Interpreter) Define(name string, value Value)
func (*Interpreter) DictionaryStackSize ¶
func (interpreter *Interpreter) DictionaryStackSize() int
func (*Interpreter) Execute ¶
func (interpreter *Interpreter) Execute(reader io.Reader)
func (*Interpreter) ExecuteFile ¶
func (interpreter *Interpreter) ExecuteFile(filePath string) error
func (*Interpreter) FindValue ¶
func (interpreter *Interpreter) FindValue(name string) Value
func (*Interpreter) FindValueInDictionaries ¶
func (interpreter *Interpreter) FindValueInDictionaries(name string) (Value, Dictionary)
func (*Interpreter) Get ¶
func (interpreter *Interpreter) Get(index int) Value
func (*Interpreter) GetGraphicContext ¶
func (interpreter *Interpreter) GetGraphicContext() draw2d.GraphicContext
func (*Interpreter) GetValues ¶
func (interpreter *Interpreter) GetValues(n int) []Value
func (*Interpreter) OperandSize ¶
func (interpreter *Interpreter) OperandSize() int
func (*Interpreter) Peek ¶
func (interpreter *Interpreter) Peek() Value
func (*Interpreter) PeekDictionary ¶
func (interpreter *Interpreter) PeekDictionary() Dictionary
func (*Interpreter) Pop ¶
func (interpreter *Interpreter) Pop() Value
func (*Interpreter) PopArray ¶
func (interpreter *Interpreter) PopArray() []Value
func (*Interpreter) PopBoolean ¶
func (interpreter *Interpreter) PopBoolean() bool
func (*Interpreter) PopDictionary ¶
func (interpreter *Interpreter) PopDictionary() Dictionary
func (*Interpreter) PopFloat ¶
func (interpreter *Interpreter) PopFloat() float64
func (*Interpreter) PopInt ¶
func (interpreter *Interpreter) PopInt() int
func (*Interpreter) PopName ¶
func (interpreter *Interpreter) PopName() string
func (*Interpreter) PopOperator ¶
func (interpreter *Interpreter) PopOperator() Operator
func (*Interpreter) PopProcedureDefinition ¶
func (interpreter *Interpreter) PopProcedureDefinition() *ProcedureDefinition
func (*Interpreter) PopString ¶
func (interpreter *Interpreter) PopString() string
func (*Interpreter) PopValues ¶
func (interpreter *Interpreter) PopValues(n int) []Value
func (*Interpreter) Push ¶
func (interpreter *Interpreter) Push(operand Value)
func (*Interpreter) PushDictionary ¶
func (interpreter *Interpreter) PushDictionary(dictionary Dictionary)
func (*Interpreter) SetGraphicContext ¶
func (interpreter *Interpreter) SetGraphicContext(gc draw2d.GraphicContext)
func (*Interpreter) SystemDefine ¶
func (interpreter *Interpreter) SystemDefine(name string, value Value)
func (*Interpreter) SystemDictionary ¶
func (interpreter *Interpreter) SystemDictionary() Dictionary
func (*Interpreter) UserDictionary ¶
func (interpreter *Interpreter) UserDictionary() Dictionary
type Operator ¶
type Operator interface {
Execute(interpreter *Interpreter)
}
type OperatorFunc ¶
type OperatorFunc func(interpreter *Interpreter)
type Position ¶
type Position struct { Filename string // filename, if any Offset int // byte offset, starting at 0 Line int // line number, starting at 1 Column int // column number, starting at 0 (character count per line) }
A source position is represented by a Position value. A position is valid if Line > 0.
type PrimitiveOperator ¶
type PrimitiveOperator struct {
// contains filtered or unexported fields
}
func NewOperator ¶
func NewOperator(f OperatorFunc) *PrimitiveOperator
func (*PrimitiveOperator) Execute ¶
func (o *PrimitiveOperator) Execute(interpreter *Interpreter)
type Procedure ¶
type Procedure struct {
// contains filtered or unexported fields
}
func NewProcedure ¶
func NewProcedure(def *ProcedureDefinition) *Procedure
func (*Procedure) Execute ¶
func (p *Procedure) Execute(interpreter *Interpreter)
type ProcedureDefinition ¶
type ProcedureDefinition struct {
Values []Value
}
func NewProcedureDefinition ¶
func NewProcedureDefinition() *ProcedureDefinition
func (*ProcedureDefinition) Add ¶
func (p *ProcedureDefinition) Add(value Value)
type Scanner ¶
type Scanner struct { // Error is called for each error encountered. If no Error // function is set, the error is reported to os.Stderr. Error func(s *Scanner, msg string) // ErrorCount is incremented by one for each error encountered. ErrorCount int // The Mode field controls which tokens are recognized. For instance, // to recognize Ints, set the ScanInts bit in Mode. The field may be // changed at any time. Mode uint // The Whitespace field controls which characters are recognized // as white space. To recognize a character ch <= ' ' as white space, // set the ch'th bit in Whitespace (the Scanner's behavior is undefined // for values ch > ' '). The field may be changed at any time. Whitespace uint64 // Current token position. The Offset, Line, and Column fields // are set by Scan(); the Filename field is left untouched by the // Scanner. Position // contains filtered or unexported fields }
A Scanner implements reading of Unicode characters and tokens from an io.Reader.
func (*Scanner) Init ¶
Init initializes a Scanner with a new source and returns itself. Error is set to nil, ErrorCount is set to 0, Mode is set to GoTokens, and Whitespace is set to GoWhitespace.
func (*Scanner) Next ¶
Next reads and returns the next Unicode character. It returns EOF at the end of the source. It reports a read error by calling s.Error, if set, or else prints an error message to os.Stderr. Next does not update the Scanner's Position field; use Pos() to get the current position.
func (*Scanner) Peek ¶
Peek returns the next Unicode character in the source without advancing the scanner. It returns EOF if the scanner's position is at the last character of the source.
func (*Scanner) Pos ¶
Position returns the current source position. If called before Next() or Scan(), it returns the position of the next Unicode character or token returned by these functions. If called afterwards, it returns the position immediately after the last character of the most recent token or character scanned.
func (*Scanner) Scan ¶
Scan reads the next token or Unicode character from source and returns it. It only recognizes tokens t for which the respective Mode bit (1<<-t) is set. It returns EOF at the end of the source. It reports scanner errors (read and token errors) by calling s.Error, if set; otherwise it prints an error message to os.Stderr.
type ValueStack ¶
type ValueStack []Value