parser

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustJSON

func MustJSON(doc *model.IpmGraph) string

MustJSON pretty prints the document JSON (helper for CLI/tests).

func Parse

func Parse(input []byte, opt Options) (*model.IpmGraph, error)

Parse parses ipmt source into an IpmGraph. It returns an error (possibly *ParseError with source positions) on failure.

func ParseIPMTBytes

func ParseIPMTBytes(data []byte, filename string) (*model.IpmGraph, error)

ParseIPMTBytes parses IPMT source bytes using the same options as the CLI.

Types

type LetterKindSpan

type LetterKindSpan struct {
	Span [2]int
	Kind model.NodeType
}

LetterKindSpan is one candidate-kind letter inside a `::?<letters>` marker — the letter's position and the NodeType it represents.

type LogicalLine

type LogicalLine struct {
	Text     string // merged content (continuations joined with space)
	RawStart int    // byte offset in original input where this logical line group begins
	M2R      []int  // merged-index → raw-index mapping (len == len(Text))
	LineNo   int    // 1-based first physical line number
}

LogicalLine is a single logical line after continuation merging.

type NodeSpec

type NodeSpec struct {
	Name  string
	Alias string
	Type  model.NodeType
	// Candidates lists the possible kinds of an Unresolved node (from a ::?et /
	// ::?etc marker), primary first. Non-empty iff Type == Unresolved.
	Candidates []model.NodeType
	Tooltip    string
	// Span is [start, end) within the logical line where the name was found.
	NameStart int
	NameEnd   int

	// Lexeme spans within the logical line ([start,end), {-1,-1} if absent).
	// Filled by parseNodeSpecs from the pt-relative spans parseOneNodeSpec
	// records; consumed by the parser to populate model.Src.Lex.
	KindMarker [2]int // ::e / ::t / ::c
	AliasMark  [2]int // ::a
	TipMark    [2]int // ::tip
	AliasName  [2]int // the alias identifier (as written)
	TipString  [2]int // the quoted tooltip string (incl. quotes)
	NameQuoted bool   // the title (Name span) is a quoted string

	// For ::?<letters> markers, the `::?` prefix span (rendered as a generic
	// type-marker) plus a per-letter list so each candidate letter colors as
	// its own kind (e=event, t=thing, c=concept). Empty when Type !=
	// Unresolved; KindMarker is noSpan in that case.
	UndecidedPrefix  [2]int
	UndecidedLetters []LetterKindSpan
}

NodeSpec is the result of parsing a single node annotation.

type Options

type Options struct {
	Filename string
}

Options holds optional settings for the parser.

type ParseError

type ParseError struct {
	Msg   string
	Start int
	End   int
}

ParseError reports a parsing error with a message and a span in raw source offsets [start, end).

func (*ParseError) Error

func (e *ParseError) Error() string

type Token

type Token struct {
	Kind  TokenKind
	Start int    // offset within LogicalLine.Text (inclusive)
	End   int    // exclusive offset
	Text  string // raw token text for debugging / node segments

	// Arrow-specific:
	Tooltip string // unescaped tooltip text (TokArrowTooltip)
	ExpCode byte   // 'P','X','L','N' (TokArrowExpl)
	Reverse bool   // parsed from <-- form
	Undir   bool   // tooltip/explicit ending with -- (undirected)
}

Token is a single token from scanning a logical line.

type TokenKind

type TokenKind int

TokenKind classifies tokens produced by the scanner.

const (
	TokNode         TokenKind = iota // node segment text
	TokArrowFwd                      // -->
	TokArrowRev                      // <--
	TokArrowUndir                    // ---
	TokArrowExpl                     // --::X--> or --::N-- or <--::X--
	TokArrowTooltip                  // --"..."-->  or --"..."-- or --ident--> or --ident--
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL