Documentation ¶
Index ¶
- Constants
- Variables
- func AdaptToValue(fr *Frame, a T, ty R.Type) R.Value
- func AdaptToValueInner(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 Arg3Usage(argv []T, usage string) (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 ArgDash2v(argv []T) ([]string, T, T, []T)
- func ArgDash2vUsage(argv []T, usage string) ([]string, T, T, []T)
- func CHECK(b bool, rest ...interface{})
- func ClearAllCounters()
- func DropSpaces(s string) string
- func FollowedByGap(lex *Lex) bool
- func HtPeek(ht HTML) string
- func IfNilArgvThenUsage(argv []T, usage 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 MkFloat(a float64) terpFloat
- func MkGenerator(readerChan <-chan Either) terpGenerator
- func MkHash(h Hash) *terpHash
- func MkInt(a int64) terpInt
- func MkList(a []T) terpList
- func MkMulti(s string) *terpMulti
- func MkMultiFr(fr *Frame, a *terpMulti) *terpMulti
- func MkString(a string) terpString
- func MkStringList(a []string) terpList
- func MkUint(a uint64) terpInt
- 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 Show(a T) string
- func ShowAllCounters() string
- func ShowEnsembleItems(items []EnsembleItem) string
- func ShowExprUnlessNull(expr *PExpr) string
- func ShowSeqUnlessNull(seq *PSeq) 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 BitsWord
- type CmdNode
- type CmdScope
- type Command
- type ConstRoot
- type Counter
- type Either
- type EnsembleItem
- 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) EvalString(a string) (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 MacroNode
- type MacroScope
- 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 Shower
- type Slot
- type SortListByStringTSlice
- 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 Arg1Usage(argv []T, usage string) 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 MkNum(s string) T
- func MkT(a interface{}) 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{})
- func RemoveHeadDashArgs(argv []T) (dashes []string, newArgv []T)
- type Token
- type TypeRoot
- type UpSlot
- type VarRoot
Constants ¶
const ( RETURN = StatusCode(iota + 2) BREAK CONTINUE USAGE // New in chirp; not in Tcl. )
Variables ¶
var AlphanumChars = "[A-Za-z0-9_]"
var BareWordPattern = "(" + InertChars + "+)"
var Debug [256]bool
var DumbDollarPattern = "[$](" + AlphanumChars + "+)"
var Empty = MkString("")
var False = Zero
var InertChars = "[!%-/0-9:<-@A-Z^_`a-z|~]"
var InvalidValue = *new(R.Value)
var MatchBareWord = regexp.MustCompile("^" + BareWordPattern + "$")
var MatchDumbDollar = regexp.MustCompile("^" + DumbDollarPattern + "$")
var MustFails int64
var MustMutex sync.Mutex
var MustSucceeds int64
var One = MkInt(1)
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 = One
var TypeT = R.TypeOf(new(T)).Elem()
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.
var Zero = MkInt(0)
Functions ¶
func ArgDash2v ¶
ArgDash2v expects args to be (1) dash arguments (2) two required args (3) possibly some optional args.
func ClearAllCounters ¶
func ClearAllCounters()
func DropSpaces ¶
func FollowedByGap ¶
func IfNilArgvThenUsage ¶
func LogAllCounters ¶
func LogAllCounters()
func MkGenerator ¶
func MkGenerator(readerChan <-chan Either) terpGenerator
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 ShowAllCounters ¶
func ShowAllCounters() string
func ShowEnsembleItems ¶
func ShowEnsembleItems(items []EnsembleItem) string
func ShowExprUnlessNull ¶
func ShowSeqUnlessNull ¶
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 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 MkNumCounter 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 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 DebugName string }
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) EvalString ¶
func (*Frame) GetVarScope ¶
func (*Frame) SubstString ¶
func (fr *Frame) SubstString(s string, flags SubstFlags) string
type Global ¶
type Global struct { Cmds CmdScope Macros MacroScope 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 MacroScope ¶
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 { VarName string Multi *terpMulti 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 PSeq ¶
Any piece of tcl code, a sequence of commands.
func CompileSequence ¶
func MaybeCompileSequence ¶
func Parse2SeqStr ¶
type PWord ¶
type PWord struct { Parts []*PPart Multi *terpMulti // If not null, value is fixed and precompiled. ExpandAsMultiWord bool }
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(masterFr *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 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 { ChirpFlavor() string Raw() interface{} String() string Float() float64 Int() int64 Uint() uint64 ListElementString() string IsQuickString() bool IsQuickList() bool IsQuickHash() bool Bool() bool // Like Python, empty values and 0 values are false. IsEmpty() bool // Would String() return ""? List() []T IsPreservedByList() bool IsQuickInt() bool IsQuickNumber() bool HeadTail() (hd, tl T) Hash() (Hash, *sync.Mutex) 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 ¶
func RemoveHeadDashArgs ¶
RemoveHeadDashArgs removes dash args from argv (only if they are QuickString), returning the dash args and modified argv. Argv[0] is preserved.
type Token ¶
type Token uint8
const ( TokEnd Token = iota // end of string TokNewline TokAlfaNum TokNumber TokOther // Non-Ascii or not special. TokBoolOr // || TokBoolAnd // && TokNumEq // == TokNumNe TokNumLe TokNumGe TokStrEq // eq TokStrNe TokStrLt TokStrLe TokStrGt TokStrGe TokShiftLeft // << TokShiftRight // >> TokExpandSquare // {*}[ TokExpandDollar // {*}$ )