Skip to main content

Crate makefile_lossless

Crate makefile_lossless 

Source
Expand description

A lossless parser for Makefiles

Example:

use std::io::Read;
let contents = r#"PYTHON = python3

.PHONY: all

all: build

build:
	$(PYTHON) setup.py build
"#;
let makefile: makefile_lossless::Makefile = contents.parse().unwrap();

assert_eq!(makefile.rules().count(), 3);

Structs§

ArchiveMember
An AST node for $ast
ArchiveMembers
An AST node for $ast
Conditional
An AST node for $ast
ErrorInfo
Information about a specific parsing error
Identifier
An AST node for $ast
Include
An AST node for $ast
Makefile
An AST node for $ast
Parse
The result of parsing: a syntax tree and a collection of errors.
ParseError
An error that occurred while parsing a makefile
PositionedParseError
A positioned parse error containing location information.
Rule
An AST node for $ast
TextEdit
A text edit applied to the source, as typically received from an LSP.
TextRange
A range in text, represented as a pair of TextSize.
VariableDefinition
An AST node for $ast
VariableReference
A reference to a variable in the makefile, e.g. $(FOO) or ${BAR}.

Enums§

Error
An error that can occur when parsing a makefile
Lang
these two SyntaxKind types, allowing for a nicer SyntaxNode API where “kinds” are values from our enum SyntaxKind, instead of plain u16 values.
MakefileItem
Represents different types of items that can appear in a Makefile
MakefileVariant
The variant of makefile being parsed
RuleItem
Represents different types of items that can appear in a Rule’s body
SyntaxKind

Functions§

apply_edit_to_text
Apply a text edit to the old source, producing the new source text.
is_in_prerequisites
Determine if the given byte offset is in the prerequisites area of a rule line (i.e. after the first : on a non-recipe line).
variable_at_offset
Extract a variable name from $(VAR) or ${VAR} surrounding the given byte offset.
word_at_offset
Extract the word (identifier) at the given byte offset.