Documentation
¶
Overview ¶
Package parser implements an error-tolerant, declaration-grade recursive-descent parser for SystemVerilog, producing an svparse/ast tree from a token stream. Error-tolerant means what it does throughout svparse: a malformed declaration is recorded and skipped (see recover.go), never fatal -- a language server has to make sense of source that's broken mid-edit far more often than a batch tool does.
Declaration-grade means ports, nets/variables, parameters, typedef/ struct/enum, function/task signatures, class members, package imports, containers, and instantiations are parsed for real; procedural block bodies (inside always, function/task bodies, constraint blocks) are recognized and skipped via balanced-token matching, never parsed -- expression and statement grammar is entirely out of scope. See each unparsed field's doc comment in package ast for exactly what's kept as a raw token span instead.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Error ¶
Error is a non-fatal problem noticed while parsing. Parse never stops or panics because of one.
func Parse ¶
Parse parses toks. preprocessor.Token is the canonical input -- not token.Token -- so AST node positions can carry real file attribution (an included declaration's true file) without the parser needing to know anything about how the tokens got there.
toks need not end with a token.KindEOF sentinel: lexer.Lex's own output always does, but preprocessor.Preprocess's does not (its EOF sentinels are internal boundary markers between pushed sources -- files, macro expansions, includes -- stripped from the merged output by design, not a producer bug). peekAt synthesizes an EOF token past the end of whatever toks it's given rather than trusting an invariant that only sometimes holds -- past a genuine end of input should always look the same to the parser regardless of which producer built toks.