package parser

import "github.com/influxdata/flux/parser"

Package parser implements a parser for Flux source files. Input is provided by a string and output is an abstract-syntax tree (AST) representing the Flux source.

The parser accepts a larger language than is syntactically permitted and will embed any errors from parsing the source into the AST itself.

Index

Functions

func FormatDuration

func FormatDuration(n *ast.DurationLiteral) string

FormatDuration will convert DurationLiteral into formatted string representation

func HandleToJSON

func HandleToJSON(hdl flux.ASTHandle) ([]byte, error)

func MustParseTime

func MustParseTime(lit string) *ast.DateTimeLiteral

MustParseTime parses a time literal and panics in the case of an error.

func ParseDir

func ParseDir(fset *token.FileSet, path string) (map[string]*ast.Package, error)

ParseDir parses all files ending in '.flux' within the specified directory. All discovered packages are returned. The parsed packages may contain errors, use ast.Check to check for errors.

func ParseDuration

func ParseDuration(lit string) (*ast.DurationLiteral, error)

ParseDuration will convert a string into an DurationLiteral.

func ParseFile

func ParseFile(fset *token.FileSet, path string) (*ast.File, error)

ParseFile parses the specified path as a Flux source file. The parsed file may contain errors, use ast.Check to check for errors.

func ParseSignedDuration

func ParseSignedDuration(lit string) (*ast.DurationLiteral, error)

ParseSignedDuration will convert a string into a possibly negative DurationLiteral.

func ParseSource

func ParseSource(source string) *ast.Package

ParseSource parses the string as Flux source code. The parsed package may contain errors, use ast.Check to check for errors.

func ParseSourceWithFileName

func ParseSourceWithFileName(source, fileName string) *ast.Package

ParseSourceWithFileName parses the string as Flux source code and will have fileName in the ast's The parsed package may contain errors, use ast.Check to check for errors.

func ParseString

func ParseString(lit string) (*ast.StringLiteral, error)

ParseString removes quotes and unescapes the string literal.

func ParseTime

func ParseTime(lit string) (*ast.DateTimeLiteral, error)

ParseTime will convert a string into an *ast.DateTimeLiteral.

func ParseToHandle

func ParseToHandle(ctx context.Context, src []byte) (*libflux.ASTPkg, error)

Source Files

doc.go libflux_parser.go parser.go strconv.go

Version
v0.196.1 (latest)
Published
Feb 19, 2025
Platform
linux/amd64
Imports
9 packages
Last checked
1 day ago

Tools for package owners.