Documentation
¶
Index ¶
- Constants
- func GenKeywordTokens() []lexer.SimpleRule
- func IntoRule(rules []lexer.SimpleRule) []lexer.Rule
- func NewIdLexer() *lexer.StatefulDefinition
- func NewIdParser[T any]() *participle.Parser[T]
- func NewLexer() *lexer.StatefulDefinition
- func NewParser[T any]() *participle.Parser[T]
- func SimpleRules(additions []lexer.Rule) []lexer.Rule
- func SimpleStringlessRules(additions []lexer.Rule) []lexer.Rule
- type DeclarationCommandT
- type DumpallT
- type DumpoffT
- type DumponT
- type DumpvarsT
- type File
- type IdT
- type IdxT
- type ScalarValueChangeT
- type ScopeKindCode
- type ScopeKindT
- type ScopeT
- type SimulationCommandT
- type SimulationKeywordT
- type SimulationTimeT
- type TimeUnit
- type TimescaleT
- type ValueChangeT
- type ValueT
- type VarKindCode
- type VarT
- type VarTypeT
- type VectorValueChange1T
- type VectorValueChange2T
- type VectorValueChange3T
- type VectorValueChangeT
Constants ¶
const ( BinstringPattern = `[bB]([10xXzZuU])+` FloatPattern = `[+-]?([0-9]*\.?[0-9]+|[0-9]+\.?[0-9]*)([eE][+-]?[0-9]+)?` // Generated by Gemini. RealStringPattern = `[r|R]` + FloatPattern IntPattern = `[+-]?[0-9]+` StringPattern = `\w+` TimestampPattern = `#\d+` WhitespacePattern = `\s+` IdentifierPattern = `[a-zA-Z_][a-zA-Z0-9_]*` StatePattern = `s` + IdentifierPattern )
See: https://github.com/google/re2/wiki/Syntax
const ( // Any string that consists of non-whitespace. AnyWordPattern = `[^\r\n\t\f\v ]+` PunctPattern = "([\\(\\)!-/:-@[-`{-~])+\\S*" )
const MaxIterations = int(int64(^uint64(0) >> 1))
MaxIterations is the max number of items to be captured by the parser. While the default is 1 million, VCD files can be GIGANTIC, so we just let it rip.
Variables ¶
This section is empty.
Functions ¶
func GenKeywordTokens ¶
func GenKeywordTokens() []lexer.SimpleRule
func IntoRule ¶
func IntoRule(rules []lexer.SimpleRule) []lexer.Rule
IntoRule converts a SimpleRule into a (complex) Rule.
func NewIdLexer ¶
func NewIdLexer() *lexer.StatefulDefinition
func NewIdParser ¶
func NewIdParser[T any]() *participle.Parser[T]
func NewLexer ¶
func NewLexer() *lexer.StatefulDefinition
NewLexer returns a built lexer that produces a valid stream of VCD tokens.
The lexer is lightly stateful to allow date and comment keywords and such.
func NewParser ¶
func NewParser[T any]() *participle.Parser[T]
func SimpleRules ¶
SimpleRules returns keywords plus basic token types.
Types ¶
type DeclarationCommandT ¶
type DeclarationCommandT struct { CommentText *string `parser:"@KwComment @AnyNonspace* @KwEndSpecial" json:",omitempty"` Var *VarT `parser:"| @KwVar (@Ws? @AnyNonspace)* @Ws? @KwEndSpecial" json:",omitempty"` Date *string `parser:"| @KwDate @AnyNonspace* @KwEndSpecial" json:",omitempty"` Version *string `parser:"| @KwVersion @AnyNonspace* @KwEndSpecial" json:",omitempty"` Attrbegin *bool `parser:"| @KwAttrbegin @AnyNonspace* @KwEndSpecial" json:",omitempty"` Attrend *bool `parser:"| @KwAttrend @AnyNonspace* @KwEndSpecial" json:",omitempty"` EndDefinitions *bool `parser:"| @KwEnddefinitions (@KwEnd|@KwEndSpecial)" json:",omitempty"` Scope *ScopeT `parser:"| @@" json:",omitempty"` Timescale *TimescaleT `parser:"| @@" json:",omitempty"` Upscope *bool `parser:"| @KwUpscope @KwEnd" json:",omitempty"` }
type DumpallT ¶
type DumpallT struct { Kw bool `parser:"@KwDumpall" json:",omitempty"` ValueChange []*ValueChangeT `parser:"@@*" json:",omitempty"` KwEnd bool `parser:"@KwEnd" json:",omitempty"` }
type DumpoffT ¶
type DumpoffT struct { Kw bool `parser:"@KwDumpoff" json:",omitempty"` ValueChange []*ValueChangeT `parser:"@@*" json:",omitempty"` KwEnd bool `parser:"@KwEnd" json:",omitempty"` }
type DumponT ¶
type DumponT struct { Kw bool `parser:"@KwDumpon" json:",omitempty"` ValueChange []*ValueChangeT `parser:"@@*" json:",omitempty"` KwEnd bool `parser:"@KwEnd" json:",omitempty"` }
type DumpvarsT ¶
type DumpvarsT struct { Kw bool `parser:"@KwDumpvars" json:",omitempty"` ValueChange []*ValueChangeT `parser:"@@*" json:",omitempty"` KwEnd bool `parser:"@KwEnd" json:",omitempty"` }
type File ¶
type File struct { DeclarationCommand []*DeclarationCommandT `parser:"@@*" json:",omitempty"` SimulationCommand []*SimulationCommandT `parser:"@@*" json:",omitempty"` }
File represents a parsed Value Change Dump. The inline definition here, is based on the IEEE Std 1364-2001 Version C, page 331. Plus some extensions that don't seem described there, but happen in realistic VCD files.
type IdT ¶
type IdxT ¶
type ScalarValueChangeT ¶
type ScalarValueChangeT struct { Pos lexer.Position Value ValueT `parser:"@@" json:",omitempty"` IdCode string `parser:"@IdCode" json:",omitempty"` // Garble is used to work around the tokenizer being unable to // make a distinction between [`x*@`] and [`x`, `*@`]. The // correct way to handle this is to write a custom lexer, but // since this seems to be the only place where it matters, this is // somewhat easier and kind of achieves the same goal. Garble string `parser:"| @IdCode" json:",omitempty"` }
func (ScalarValueChangeT) GetIdCode ¶
func (self ScalarValueChangeT) GetIdCode() string
func (ScalarValueChangeT) GetValue ¶
func (self ScalarValueChangeT) GetValue() string
type ScopeKindCode ¶
type ScopeKindCode int
const ( ScopeKindBegin ScopeKindCode = iota ScopeKindFork ScopeKindModule ScopeKindFunction ScopeKindTask ScopeKindVHDLArchitecture ScopeKindVHDLRecord ScopeKindUnknown )
type ScopeKindT ¶
type ScopeKindT struct { Begin bool `parser:"@\"begin\"" json:",omitempty"` Fork bool `parser:"| \"fork\"" json:",omitempty"` Function bool `parser:"| \"function\"" json:",omitempty"` Module bool `parser:"| @\"module\"" json:",omitempty"` Task bool `parser:"| \"task\"" json:",omitempty"` // Extensions? VHDLArchitecture bool `parser:"| \"vhdl_architecture\"" json:",omitempty"` VHDLRecord bool `parser:"| \"vhdl_record\"" json:",omitempty"` }
func (ScopeKindT) Kind ¶
func (self ScopeKindT) Kind() ScopeKindCode
type ScopeT ¶
type ScopeT struct { Scope bool `parser:"@KwScope" json:",omitempty"` ScopeKind ScopeKindT `parser:"@@" json:",omitempty"` Id string `parser:"@Ident" json:",omitempty"` KwEnd bool `parser:"@KwEnd" json:"-"` }
type SimulationCommandT ¶
type SimulationCommandT struct { Dumpall *DumpallT `parser:"@@" json:",omitempty"` Dumpoff *DumpoffT `parser:"| @@" json:",omitempty"` Dumpon *DumponT `parser:"| @@" json:",omitempty"` Dumpvars *DumpvarsT `parser:"| @@" json:",omitempty"` SimulationTime *SimulationTimeT `parser:"| @@" json:",omitempty"` ValueChange *ValueChangeT `parser:"| @@" json:",omitempty"` Attrbegin *bool `parser:"| @KwAttrbegin @AnyNonspace* @KwEndSpecial" json:",omitempty"` Attrend *bool `parser:"| @KwAttrend @AnyNonspace* @KwEndSpecial" json:",omitempty"` }
type SimulationKeywordT ¶
type SimulationTimeT ¶
type SimulationTimeT struct {
DecimalNumber string `parser:"@Timestamp" json:",omitempty"`
}
func (SimulationTimeT) Value ¶
func (self SimulationTimeT) Value() uint64
type TimeUnit ¶
type TimeUnit struct { Second bool `parser:" @\"s\"" json:",omitempty"` MilliSecond bool `parser:"| @\"ms\"" json:",omitempty"` MicroSecond bool `parser:"| @\"us\"" json:",omitempty"` NanoSecond bool `parser:"| @\"ns\"" json:",omitempty"` PicoSecond bool `parser:"| @\"ps\"" json:",omitempty"` FemtoSecond bool `parser:"| @\"fs\"" json:",omitempty"` }
func (TimeUnit) Multiplier ¶
type TimescaleT ¶
type TimescaleT struct { Kw bool `parser:"@KwTimescale" json:"-"` Number int64 `parser:"@Int" json:",omitempty"` Unit *TimeUnit `parser:"@@" json:",omitempty"` Kw2 bool `parser:"@KwEnd" json:"-"` }
func (TimescaleT) AsNanoseconds ¶
func (self TimescaleT) AsNanoseconds() float64
AsNanoseconds returns the number of nanoseconds.
func (TimescaleT) AsSeconds ¶
func (self TimescaleT) AsSeconds() float64
AsSeconds returns the number of seconds (possibly fractional, possibly very small)
type ValueChangeT ¶
type ValueChangeT struct { ScalarValueChange *ScalarValueChangeT `parser:"@@" json:",omitempty"` VectorValueChange *VectorValueChangeT `parser:"| @@" json:",omitempty"` }
func (ValueChangeT) GetIdCode ¶
func (self ValueChangeT) GetIdCode() string
func (ValueChangeT) GetValue ¶
func (self ValueChangeT) GetValue() string
type ValueT ¶
type ValueT struct {
Value string `parser:"@(\"0\" | \"1\" | \"x\" | \"X\"| \"z\" | \"Z\")" json:",omitempty"`
}
type VarKindCode ¶
type VarKindCode int
VarKindCode is the type code for a variable.
const ( VarKindEvent VarKindCode = iota VarKindInteger VarKindParameter VarKindReal VarKindReg VarKindSupply0 VarKindSupply1 VarKindTime VarKindTri VarKindTriand VarKindTrior VarKindTrireg VarKindTri0 VarKindTri1 VarKindWand VarKindWire VarKindWor // Extensions? VarKindLogic VarKindString VarKindUnknown )
func (VarKindCode) Int ¶
func (self VarKindCode) Int() int
type VarT ¶
type VarT struct { Kw bool `json:",omitempty"` VarType string `json:",omitempty"` Size int `json:",omitempty"` Code string `json:",omitempty"` Id IdT `json:",omitempty"` KwEnd bool `json:",omitempty"` // contains filtered or unexported fields }
func (VarT) GetVarKind ¶
func (self VarT) GetVarKind() VarKindCode
type VarTypeT ¶
type VarTypeT struct { Event bool `parser:" @\"event\"" json:",omitempty"` Integer bool `parser:"| @\"integer\"" json:",omitempty"` Parameter bool `parser:"| @\"parameter\"" json:",omitempty"` Real bool `parser:"| @\"real\"" json:",omitempty"` Reg bool `parser:"| @\"reg\"" json:",omitempty"` Supply0 bool `parser:"| @\"supply0\"" json:",omitempty"` Supply1 bool `parser:"| @\"supply1\"" json:",omitempty"` Time bool `parser:"| @\"time\"" json:",omitempty"` Tri bool `parser:"| @\"tri\"" json:",omitempty"` Triand bool `parser:"| @\"triand\"" json:",omitempty"` Trior bool `parser:"| @\"trior\"" json:",omitempty"` Trireg bool `parser:"| @\"trireg\"" json:",omitempty"` Tri0 bool `parser:"| @\"tri0\"" json:",omitempty"` Tri1 bool `parser:"| @\"tri1\"" json:",omitempty"` Wand bool `parser:"| @\"wand\"" json:",omitempty"` Wire bool `parser:"| @\"wire\"" json:",omitempty"` Wor bool `parser:"| @\"wor\"" json:",omitempty"` // Extensions? Logic bool `parser:"| @\"logic\"" json:",omitempty"` String bool `parser:"| @\"string\"" json:",omitempty"` }
type VectorValueChange1T ¶
type VectorValueChange1T struct { Value string `parser:"@Binstring" json:",omitempty"` IdCode string `parser:"@IdCode" json:",omitempty"` }
func (VectorValueChange1T) GetCode ¶
func (self VectorValueChange1T) GetCode() string
func (VectorValueChange1T) GetValue ¶
func (self VectorValueChange1T) GetValue() string
type VectorValueChange2T ¶
type VectorValueChange2T struct { Value string `parser:" @StateString " json:",omitempty"` IdCode string `parser:" @IdCode " json:",omitempty"` }
func (VectorValueChange2T) GetCode ¶
func (self VectorValueChange2T) GetCode() string
func (VectorValueChange2T) GetValue ¶
func (self VectorValueChange2T) GetValue() string
type VectorValueChange3T ¶
type VectorValueChange3T struct { Value string `parser:"@RealString" json:",omitempty"` IdCode string `parser:"@IdCode" json:",omitempty"` }
func (VectorValueChange3T) GetCode ¶
func (self VectorValueChange3T) GetCode() string
func (VectorValueChange3T) GetValue ¶
func (self VectorValueChange3T) GetValue() string
type VectorValueChangeT ¶
type VectorValueChangeT struct { VectorValueChange1 *VectorValueChange1T `parser:"@@" json:",omitempty"` VectorValueChange2 *VectorValueChange2T `parser:"| @@" json:",omitempty"` VectorValueChange3 *VectorValueChange3T `parser:"| @@" json:",omitempty"` }
func (VectorValueChangeT) GetCode ¶
func (self VectorValueChangeT) GetCode() string
func (VectorValueChangeT) GetValue ¶
func (self VectorValueChangeT) GetValue() string