Documentation ¶
Index ¶
- Constants
- Variables
- func AdaptToValue(fr *Frame, a T, ty R.Type) R.Value
- func Arg0(argv []T)
- func Arg1v(argv []T) (T, []T)
- func Arg2(argv []T) (T, T)
- func Arg2v(argv []T) (T, T, []T)
- func Arg3(argv []T) (T, T, T)
- func Arg3v(argv []T) (T, T, T, []T)
- func Arg4(argv []T) (T, T, T, T)
- func Arg5(argv []T) (T, T, T, T, T)
- func Arg6(argv []T) (T, T, T, T, T, T)
- func Arg7(argv []T) (T, T, T, T, T, T, T)
- func ClearAllCounters()
- func DropSpaces(s string) string
- func HtPeek(ht HTML) string
- func IsGlobal(name string) bool
- func IsLocal(name string) bool
- func Log(fr *Frame, levelStr string, message string)
- func LogAllCounters()
- func Logf(fmt string, args ...interface{})
- func MkGenerator(readerChan <-chan Either) terpGenerator
- func MkHackFloat(f float64) *terpFloatHack
- func MkHash(h Hash) terpHash
- func MkList(a []T) terpList
- func MkMulti(a string) *terpMulti
- func MkOldFloat(a float64) terpFloat
- func MkString(a string) terpString
- func MkStringList(a []string) terpList
- func MkValue(a R.Value) terpValue
- func Must(a, b T)
- func MustA(a, b interface{})
- func MustB(a, b byte)
- func MustNoSp(a, b interface{})
- func MustST(a string, b T)
- func MustTok(a, b Token)
- func NeedsOctalEscape(b byte) bool
- func NonEmpty(v []string) []string
- func OctalEscape(s string) string
- func Regexp(exp string, nocase bool) *regexp.Regexp
- func RegexpFindMatch(exp, str string, nocase bool) (bool, string)
- func RegexpFindSubmatch(exp, str string, nocase bool) (bool, []string)
- func RegexpMatch(exp, str string, nocase bool) bool
- func Repr(a interface{}) string
- func Say(args ...interface{})
- func Sayf(format string, args ...interface{})
- func SetDebugFromEnv()
- func Show(a T) string
- func ShowAllCounters() string
- func ShowEnsembleItems(items []EnsembleItem) string
- func Showv(a []T) string
- func SortListByString(list []T)
- func SortedKeysOfHash(h Hash) []string
- func StringMatch(pattern, str string) bool
- func SubstStringOrOrig(fr *Frame, s string) (z string)
- func ToListElementString(s string) string
- func Where() string
- func White(ch uint8) bool
- func WhiteOrSemi(ch uint8) bool
- type Applier
- type BareWord
- type BitsWord
- type CmdNode
- type CmdScope
- type Command
- type ConstRoot
- type Counter
- type Dollar1
- type Dollar2
- type Either
- type EnsembleItem
- type Evaler
- type Frame
- func (fr *Frame) Apply(argv []T) T
- func (fr *Frame) DefineUpVar(name string, remFr *Frame, remName string)
- func (fr *Frame) Eval(a T) (result T)
- func (fr *Frame) EvalExpr(a T) (result T)
- func (fr *Frame) EvalSeqWithErrorLocation(seq *PSeq) (result T)
- func (fr *Frame) FindCommand(name T, callSuper bool) Command
- func (fr *Frame) GetVar(name string) T
- func (fr *Frame) GetVarScope(name string) Scope
- func (fr *Frame) HasVar(name string) bool
- func (fr *Frame) NewFrame() *Frame
- func (fr *Frame) SetVar(name string, x T)
- func (fr *Frame) SubstString(s string, flags SubstFlags) string
- type FuncRoot
- type Global
- type HTML
- type Hash
- type Jump
- type Lex
- type Loc
- type Obj
- type Opaque
- type PCmd
- type PExpr
- func Parse2ExprConjunction(lex *Lex) *PExpr
- func Parse2ExprDisjunction(lex *Lex) *PExpr
- func Parse2ExprPrimative(lex *Lex) *PExpr
- func Parse2ExprProduct(lex *Lex) *PExpr
- func Parse2ExprRelation(lex *Lex) *PExpr
- func Parse2ExprStr(s string) *PExpr
- func Parse2ExprSum(lex *Lex) *PExpr
- func Parse2ExprTop(lex *Lex) *PExpr
- func Parse2ExprUnary(lex *Lex) *PExpr
- type PPart
- type PSeq
- type PWord
- type PartType
- type SafeSubInterp
- type Scope
- type Seq
- type Shower
- type Slot
- type SortListByStringTSlice
- type Square
- type StatusCode
- type SubstFlags
- type T
- func ApplyToReflectedValue(fr *Frame, v R.Value, args []T, i int) T
- func ApplyToType(fr *Frame, typ R.Type, args []T) T
- func Arg0v(argv []T) []T
- func Arg1(argv []T) T
- func ConcatLists(lists []T) []T
- func EvalOrApplyLists(fr *Frame, lists []T) T
- func HtEntity(entity string) T
- func LookupRootAndApply(fr *Frame, rootName string, args []T) T
- func MkBool(a bool) T
- func MkFloat(a float64) T
- func MkInt(a int64) T
- func MkT(a interface{}) T
- func MkUint(a uint64) T
- func Parse2EvalExprStr(fr *Frame, s string) T
- func Parse2EvalSeqStr(fr *Frame, s string) T
- func ParseList(s string) []T
- func ParseListOrRecover(s string) (recs []T, err interface{})
- type Token
- type TypeRoot
- type UpSlot
- type VarRoot
- type Word
- type WordParts
- type Words
Constants ¶
const ( RETURN = StatusCode(iota + 2) BREAK CONTINUE )
Variables ¶
var AlphanumChars = "[A-Za-z0-9_]"
var BareWordPattern = "(" + InertChars + "+)"
var Debug [256]bool
var DumbDollarPattern = "[$](" + AlphanumChars + "+)"
var Empty = MkString("")
var False = MkInt(0)
var InertChars = "[!%-/0-9:<-@A-Z^_`a-z|~]"
var InvalidValue = *new(R.Value)
var MatchBareWord = regexp.MustCompile("^" + BareWordPattern + "$")
var MatchDumbDollar = regexp.MustCompile("^" + DumbDollarPattern + "$")
var Safes map[string]Command
Safes are builtin commands that safe subinterps can call. Conventionally these contain no hyphen.
var SayPrefix = "Say" // TODO: Global Prefix WILL BREAK WITH goROUTINES.
var True = MkInt(1)
var TypeT = R.TypeOf(MkT(""))
var TypeType = R.TypeOf(TypeT)
var Unsafes map[string]Command
Unsafes are commands that only the trusted, toplevel terp can call. Conventionally these contain a hyphen.
Functions ¶
func ClearAllCounters ¶
func ClearAllCounters()
func DropSpaces ¶
func LogAllCounters ¶
func LogAllCounters()
func MkGenerator ¶
func MkGenerator(readerChan <-chan Either) terpGenerator
func MkHackFloat ¶
func MkHackFloat(f float64) *terpFloatHack
func MkOldFloat ¶
func MkOldFloat(a float64) terpFloat
func MkStringList ¶
func MkStringList(a []string) terpList
func MustNoSp ¶
func MustNoSp(a, b interface{})
MustSp takes Any 2 values, and compares their Repr()s, without spaces.
func NeedsOctalEscape ¶
func OctalEscape ¶
func RegexpMatch ¶
func SetDebugFromEnv ¶
func SetDebugFromEnv()
func ShowAllCounters ¶
func ShowAllCounters() string
func ShowEnsembleItems ¶
func ShowEnsembleItems(items []EnsembleItem) string
func SortedKeysOfHash ¶
func StringMatch ¶
func SubstStringOrOrig ¶
func ToListElementString ¶
func WhiteOrSemi ¶
Types ¶
type BitsWord ¶
type BitsWord uint32 // We cannot fit uint64 into the float -- until we support actual uint64, we must use shorter BitsWords.
type CmdNode ¶
CmdNode makes a singly-linked-list of commands at different mixin levels, highest level first. A non-mixin command has level 0 and only one CmdNode.
type Command ¶
func MkBinaryFlopBoolCmd ¶
func MkBinaryFlopBoolCmd(op binaryFlopBool) Command
func MkBinaryFlopCmd ¶
func MkBinaryFlopCmd(flop binaryFlop) Command
func MkBinaryStringBoolCmd ¶
func MkBinaryStringBoolCmd(op binaryStringBool) Command
func MkChainingBinaryFlopCmd ¶
func MkEnsemble ¶
func MkEnsemble(items []EnsembleItem) Command
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
var Counters *Counter
var EvalSeqWithErrorLocationCounter Counter
var MkBoolCounter Counter
var MkFloatCounter Counter
var MkGeneratorCounter Counter
var MkHackFloatCounter Counter
var MkHashCounter Counter
var MkIntCounter Counter
var MkListCounter Counter
var MkMultiCounter Counter
var MkStringCounter Counter
var MkStringListCounter Counter
var MkTCounter Counter
var MkUintCounter Counter
var MkValueCounter Counter
var MultiEvalExprCompileCounter Counter
var MultiEvalExprCounter Counter
var MultiEvalSeqCompileCounter Counter
var MultiEvalSeqCounter Counter
var NewFrameCounter Counter
var Parse2CmdCounter Counter
var Parse2CmdEvalCounter Counter
var Parse2DollarCounter Counter
var Parse2ExprEvalCounter Counter
var Parse2ExprTopCounter Counter
var Parse2QuoteCounter Counter
var Parse2SeqCounter Counter
var Parse2SeqEvalCounter Counter
var Parse2SquareCounter Counter
var Parse2WordEvalFastCounter0 Counter
var Parse2WordEvalFastCounter1 Counter
var Parse2WordEvalSlowCounter1 Counter
var Parse2WordEvalSlowCounter9 Counter
var ParseListCounter Counter
var SubstStringCounter Counter
type EnsembleItem ¶
type Evaler ¶
A Evaler is some piece of code that can be evaluated. It may be a single command (Words) or a sequence of commands (Seq).
func CompileSequence ¶
CompileSequence uses dumbCompileSequence. If dumbCompileSequence panics, we recover and return nil.
type Frame ¶
type Frame struct { Mu sync.Mutex Vars Scope // local variables Cred Hash // credentials Prev *Frame G *Global WriterChan chan<- Either // for yproc & yield MixinLevel int MixinName string Self *Obj Super *Obj }
Frame is a local variable frame. There is one for the global variables in the Global struct, and a new one is created for each proc or yproc invocation (but not for every Command; non-proc commands do not make Frames).
func NewSafeInterpreter ¶
func NewSafeInterpreter() *Frame
NewSafeInterpreter() makes a new safe interpreter.
func (*Frame) EvalSeqWithErrorLocation ¶
func (*Frame) GetVarScope ¶
func (*Frame) SubstString ¶
func (fr *Frame) SubstString(s string, flags SubstFlags) string
type Global ¶
type Global struct { Cmds CmdScope Fr Frame // global scope MixinSerial int // Increment before defining Mixin. MixinNumberDefining int // Set nonzero while defining Mixin. MixinNameDefining string // Set nonempty while defining Mixin. IsSafe bool // Set true for safe subinterpreter. Logger *log.Logger Verbosity int // Log if message level <= verbosity. LogName string // for logging Mu sync.Mutex }
Global holds the global state of an interpreter, mainly the Commands and global variables. It also knows if a Mixin is being defined. Mixins should be defined by main thread, after all overridable procs are defined, but before other goroutines start.
func (*Global) MintMixinSerial ¶
type HTML ¶
type HTML string
HTML contains properly formatted & escaped HTML
type Jump ¶
type Jump struct { Status StatusCode Result T }
Jump structs are panicked for return, break, and continue.
type Lex ¶
type Lex struct { Str string Len int // len(s) Next int // next position to scan Pos int // position of token Tok Token // type of token }
func (*Lex) AdvanceCurly ¶
AdvanceCurly returns the string decoded from the Curly clause and leaves Next on the close-curly.
func (*Lex) AdvanceIfAlfaNum ¶
func (x *Lex) AdvanceIfAlfaNum()
AdvanceIfAlfaNum will either take a TokAlfaNum (no white space first), or not advance.
func (*Lex) SkipComment ¶
func (x *Lex) SkipComment()
func (*Lex) StretchBackslashEscaped ¶
StretchBackslashEscaped stretches the Next pointer across \C or \ooo for octal.
type Opaque ¶
type Opaque struct {
// contains filtered or unexported fields
}
Opaque is a new idea for things like credentials. Fields must be private.
type PExpr ¶
type PExpr struct { Op Token A, B, C *PExpr Word *PWord // Op '"': for Primatives: "quoted", [square], 3.14 literal, {literal}, $var, $var(index). }
An expr command
func Parse2ExprConjunction ¶
func Parse2ExprDisjunction ¶
func Parse2ExprPrimative ¶
func Parse2ExprProduct ¶
func Parse2ExprRelation ¶
func Parse2ExprStr ¶
func Parse2ExprSum ¶
func Parse2ExprTop ¶
func Parse2ExprUnary ¶
type PPart ¶
type PPart struct { Str string // TODO: make this a T, and use MkMulti. Word *PWord // for DOLLAR2 Seq *PSeq // for SQUARE Type PartType }
func Parse2Dollar ¶
Parse a variable name after a '$', returning *PPart. Leaves Next immediately after the consumed part.
func Parse2Square ¶
Parse Square Bracketed subcommand, returning result and new position
type PWord ¶
type PWord struct { Parts []*PPart Multi *terpMulti // If not null, value is fixed and precompiled. }
One words, composed of parts that may require substitions.
func Parse2DollarKey ¶
Parse the Key for a Dollar with Parens, e.g. $x(key). Dollar, Square, and Backslash substitutions occur. White space and DQuotes are not special. Terminates with ")".
func Parse2Quote ¶
type SafeSubInterp ¶
type SafeSubInterp struct {
// contains filtered or unexported fields
}
func (*SafeSubInterp) Alias ¶
func (ssi *SafeSubInterp) Alias(fr *Frame, newcmdnameStr string, prefix T)
func (*SafeSubInterp) Clone ¶
func (ssi *SafeSubInterp) Clone() *SafeSubInterp
func (*SafeSubInterp) CopyCredFrom ¶
func (ssi *SafeSubInterp) CopyCredFrom(fr *Frame)
func (*SafeSubInterp) Eval ¶
func (ssi *SafeSubInterp) Eval(script T) T
type Seq ¶
type Seq struct {
// contains filtered or unexported fields
}
Seq is a list of Stmts that can be evaluated. The value is usually the value of the last one. If empty, the value is Empty.
type SortListByStringTSlice ¶
type SortListByStringTSlice []T
func (SortListByStringTSlice) Len ¶
func (p SortListByStringTSlice) Len() int
func (SortListByStringTSlice) Less ¶
func (p SortListByStringTSlice) Less(i, j int) bool
func (SortListByStringTSlice) Swap ¶
func (p SortListByStringTSlice) Swap(i, j int)
type StatusCode ¶
type StatusCode int
StatusCode are the same integers as Tcl/C uses for return, break, and continue.
type SubstFlags ¶
type SubstFlags int
const ( NoDollar SubstFlags = 1 << iota NoSquare NoBackslash )
type T ¶
type T interface { ChirpKind() string Raw() interface{} String() string Float() float64 Int() int64 Uint() uint64 ListElementString() string Bool() bool // Like Python, empty values and 0 values are false. IsEmpty() bool // Would String() return ""? List() []T IsPreservedByList() bool IsQuickNumber() bool HeadTail() (hd, tl T) Hash() Hash GetAt(key T) T PutAt(value T, key T) QuickReflectValue() R.Value EvalSeq(fr *Frame) T EvalExpr(fr *Frame) T Apply(fr *Frame, args []T) T }
T is an interface to any Tcl value. Use them only through these methods, or fix these methods.
func ApplyToReflectedValue ¶
ApplyToReflectedValue applies args, starting at i, to terpValue t.
func ConcatLists ¶
func EvalOrApplyLists ¶
func Parse2EvalExprStr ¶
func Parse2EvalSeqStr ¶
func ParseListOrRecover ¶
type Word ¶
A word becomes one argument, or the command word itself. Substitutions take place each time it is to be used.