cparse

package
v0.0.0-...-7b712e5 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindMacros

func FindMacros(env *BuildEnv, r io.Reader) ([]string, error)

FindMacros returns the names of all macros defined by the C source in r.

func Preprocess

func Preprocess(env *BuildEnv, r io.Reader) ([]byte, error)

Preprocess invokes the C preprocessor to pre-process the C source in r.

Types

type BuildEnv

type BuildEnv struct {
	CCArgs []string
}

type Enum

type Enum struct {
	Tag   Tok
	Ident Tok
}

func FindEnums

func FindEnums(tokens []Tok) ([]Enum, error)

FindEnums finds top-level enumeration constants in toks.

type Extractor

type Extractor struct {
	Prologue string
	Names    []string
	Vals     map[string]interface{}
}

func (*Extractor) Extract

func (e *Extractor) Extract(env *BuildEnv) error

type Tok

type Tok struct {
	Kind TokKind
	Text string
}

func Tokenize

func Tokenize(src []byte) ([]Tok, error)

Tokenize parses src into C tokens. src must already be pre-processed.

func (Tok) Int

func (t Tok) Int() int

func (Tok) Match

func (t Tok) Match(kind TokKind, text string) bool

type TokKind

type TokKind uint8
const (
	TokKeyword TokKind = 1 + iota
	TokIdent
	TokNumber
	TokString
	TokChar
	TokOp
	TokEOF
)

type Toks

type Toks struct {
	Toks []Tok
}

Jump to

Keyboard shortcuts

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