goyacc

command
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2021 License: BSD-1-Clause, BSD-2-Clause Imports: 19 Imported by: 0

README

README.MD


This is a temporary staging folder to resolve golang bug, related to GOMODULE and go.sum checksum error.

Users in China seem to be unable to reliably build repo because of URL redirection and blocking of HTTPS endpoints.

Copying the external dependencies into folder in repo should enable offline builds and avoid the go sum checksum error bug.


YACC is staged for deprecation. And is on schedule for deprecation and deletion.

Documentation

Overview

Goyacc is a version of yacc generating Go parsers.

Usage

Note: If no non flag arguments are given, goyacc reads standard input.

goyacc [options] [input]

options and (defaults)
	-c                  Report state closures. (false)
	-cr                 Check all states are reducible. (false)
	-dlval              Debug value when runtime yyDebug >= 3. ("lval")
	-dlvalf             Debug format of -dlval. ("%+v")
	-ex                 Explain how were conflicts resolved. (false)
	-fs                 Emit follow sets. (false)
	-l                  Disable line directives, for compatibility only - ignored. (false)
	-la                 Report all lookahead sets. (false)
	-o outputFile       Parser output. ("y.go")
	-p prefix           Name prefix to use in generated code. ("yy")
	-pool               Use sync.Pool for the parser stack
	-v reportFile       Create grammar report. ("y.output")
	-xe examplesFile    Generate error messages by examples. ("")
	-xegen examplesFile Generate a file suitable for -xe automatically from the grammar.
	                    The file must not exist. ("")

Changelog

2018-03-23: The new option -pool enables using sync.Pool to recycle parser stacks.

2017-08-01: New option -fs emits a table of the follow sets. Index is the state number.

2016-03-17: Error messages now use the last token literal string, if any, to produce nicer text like "unexpected integer constant". If using xerrors the message could be, for example, something like "unexpected integer constant, expected '{'"-

2015-03-24: The search for a custom error message is now extended to include also the last state that was shifted into, if any. This change resolves a problem in which a lookahead symbol is valid for a reduce action in state A, but the same symbol is later never accepted by any shift action in some state B which is popped from the state stack after the reduction is performed. The computed from example state is A but when the error is actually detected, the state is now B and the custom error was thus not used.

2015-02-23: Added -xegen flag. It can be used to automagically generate a skeleton errors by example file which can be, for example, edited and/or submited later as an argument of the -xe option.

2014-12-18: Support %precedence for better bison compatibility[3]. The actual changes are in packages goyacc is dependent on. Goyacc users should rebuild the binary:

$ go get -u github.com/cznic/goyacc

2014-12-02: Added support for the optional yyLexerEx interface. The Reduced method can be useful for debugging and/or automatically producing examples by parsing code fragments. If it returns true the parser exits immediately with return value -1.

Overview

The generated parser is reentrant and mostly backwards compatible with parsers generated by go tool yacc[0]. yyParse expects to be given an argument that conforms to the following interface:

type yyLexer interface {
	Lex(lval *yySymType) int
	Error(e string)
}

Optionally the argument to yyParse may implement the following interface:

type yyLexerEx interface {
	yyLexer
	// Hook for recording a reduction.
	Reduced(rule, state int, lval *yySymType) (stop bool) // Client should copy *lval.
}

Lex should return the token identifier, and place other token information in lval (which replaces the usual yylval). Error is equivalent to yyerror in the original yacc.

Code inside the parser may refer to the variable yylex, which holds the yyLexer passed to Parse.

Multiple grammars compiled into a single program should be placed in distinct packages. If that is impossible, the "-p prefix" flag to yacc sets the prefix, by default yy, that begins the names of symbols, including types, the parser, and the lexer, generated and referenced by yacc's generated code. Setting it to distinct values allows multiple grammars to be placed in a single package.

Differences wrt go tool yacc

- goyacc implements ideas from "Generating LR Syntax Error Messages from Examples"[1]. Use the -xe flag to pass a name of the example file. For more details about the example format please see [2].

- The grammar report includes example token sequences leading to the particular state. Can help understanding conflicts.

- Minor changes in parser debug output.

Directories

Path Synopsis
Package bigfft implements multiplication of big.Int using FFT.
Package bigfft implements multiplication of big.Int using FFT.
Package fileutil collects some file utility functions.
Package fileutil collects some file utility functions.
falloc
WIP: Package falloc provides allocation/deallocation of space within a file/store (WIP, unstable API).
WIP: Package falloc provides allocation/deallocation of space within a file/store (WIP, unstable API).
hdb
WIP: Package hdb provides a "handle"/value DB like store, but actually it's closer to the model of a process's virtual memory and its alloc, free and move methods.
WIP: Package hdb provides a "handle"/value DB like store, but actually it's closer to the model of a process's virtual memory and its alloc, free and move methods.
storage
WIP: Package storage defines and implements storage providers and store accessors.
WIP: Package storage defines and implements storage providers and store accessors.
Golex is a lex/flex like (not fully POSIX lex compatible) utility.
Golex is a lex/flex like (not fully POSIX lex compatible) utility.
lex
Package lex is a Unicode-friendly run time library for golex[0] generated lexical analyzers[1].
Package lex is a Unicode-friendly run time library for golex[0] generated lexical analyzers[1].
Package lex provides support for a *nix (f)lex like tool on .l sources.
Package lex provides support for a *nix (f)lex like tool on .l sources.
Package lexer provides generating actionless scanners (lexeme recognizers) at run time.
Package lexer provides generating actionless scanners (lexeme recognizers) at run time.
Package mathutil provides utilities supplementing the standard 'math' and 'math/rand' packages.
Package mathutil provides utilities supplementing the standard 'math' and 'math/rand' packages.
mersenne
Package mersenne collects utilities related to Mersenne numbers[1] and/or some of their properties.
Package mersenne collects utilities related to Mersenne numbers[1] and/or some of their properties.
parser
nquads
Package parser implements a parser for N-Quads[0] source text.
Package parser implements a parser for N-Quads[0] source text.
yacc
Package parser implements a parser for yacc source files.
Package parser implements a parser for yacc source files.
scanner
nquads
Package scanner implements a scanner for N-Quads[0] source text.
Package scanner implements a scanner for N-Quads[0] source text.
yacc
Package scanner implements a scanner for yacc[0] source text with actions written in Go.
Package scanner implements a scanner for yacc[0] source text with actions written in Go.
Package sortutil provides utilities supplementing the standard 'sort' package.
Package sortutil provides utilities supplementing the standard 'sort' package.
y
Package y converts .y (yacc[2]) source files to data suitable for a parser generator.
Package y converts .y (yacc[2]) source files to data suitable for a parser generator.

Jump to

Keyboard shortcuts

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