parsemake

package module
v0.0.0-...-7816f33 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2024 License: MIT Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

parsemake

parses a makefile The goal was a proof of concept for me to parse makefiles for use in tab completion for fish-shell. The project might never be completely finished or compliant with the makefile spec. but it will do for my needs.

Heavily inspired from https://github.com/mrtazz/checkmake

WARNING this is an unfinished project it does not currently work use at your own risk.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrParse = errors.New("parse error")
)

Functions

This section is empty.

Types

type ArrStringNoAlloc

type ArrStringNoAlloc []StringNoAlloc

func ArrStringToNoAlloc

func ArrStringToNoAlloc(sArr []string) ArrStringNoAlloc

func (ArrStringNoAlloc) GoString

func (s ArrStringNoAlloc) GoString() string

func (ArrStringNoAlloc) String

func (s ArrStringNoAlloc) String() string

type Makefile

type Makefile struct {
	Rules     RuleList
	Variables VariableList
}

Makefile and it's corresponded parts matches signature of checkmake/parser

func Parse

func Parse(filepath string) (ret *Makefile, err error)

func ParseLog

func ParseLog(filepath string, logLvl slog.Level) (ret *Makefile, err error)

ParseLog is the main function to parse a Makefile from a file path string to a Makefile struct. This function should be kept fairly small and ideally most of the heavy lifting will live in the specific parsing functions below that know how to deal with individual lines.

type MakefileScanner

type MakefileScanner struct {
	Scanner    *bufio.Scanner
	LineNumber int
	FileHandle *os.File
	Finished   bool
}

MakefileScanner is a wrapping struct around bufio.Scanner which provides extra functionality like the current line number

func NewMakefileScanner

func NewMakefileScanner(filepath string) (ret *MakefileScanner, err error)

NewMakefileScanner returns a MakefileScanner struct for parsing a Makefile

func (*MakefileScanner) Bytes

func (s *MakefileScanner) Bytes() []byte

Bytes is a thin wrapper around bufio.Scanner Bytes()

func (*MakefileScanner) Close

func (s *MakefileScanner) Close() error

Close closes all open handles the scanner has

func (*MakefileScanner) Scan

func (s *MakefileScanner) Scan() bool

Scan is a thin wrapper around the bufio.Scanner Scan() function

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

func NewParseWithBuffSize

func NewParseWithBuffSize(buff int64) (p *Parser)

func NewParser

func NewParser() *Parser

func (*Parser) Parse

func (p *Parser) Parse(fileName string) (m []byte, err error)

func (p *Parser) Parse(fileName string) (m *Makefile, err error) {

type Rule

type Rule struct {
	LineNumber    int
	Target        StringNoAlloc
	Dependencies  []StringNoAlloc
	Body          []StringNoAlloc
	UsedVariables []Variable
}

type RuleList

type RuleList []Rule

type StringNoAlloc

type StringNoAlloc gojay.EmbeddedJSON

func StringToNoAlloc

func StringToNoAlloc(s string) StringNoAlloc

func (StringNoAlloc) GoString

func (s StringNoAlloc) GoString() string

func (StringNoAlloc) String

func (s StringNoAlloc) String() string

type Variable

type Variable struct {
	LineNumber      int
	SimplyExpanded  bool
	SpecialVariable bool
	Name            StringNoAlloc
	Assignment      StringNoAlloc
}

type VariableList

type VariableList []Variable

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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