appyacc

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2025 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ACTSIZE  = 240000
	NSTATES  = 16000
	TEMPSIZE = 16000

	SYMINC   = 50  // increase for non-term or term
	RULEINC  = 50  // increase for max rule length prodptr[i]
	PRODINC  = 100 // increase for productions     prodptr
	WSETINC  = 50  // increase for working sets    wsets
	STATEINC = 200 // increase for states          statemem

	PRIVATE = 0xE000 // unicode private use

	NTBASE     = 010000
	ERRCODE    = 8190
	ACCEPTCODE = 8191
	YYLEXUNK   = 3
	TOKSTART   = 4 //index of first defined token
)

the following are adjustable according to memory size

View Source
const (
	NOASC = iota
	LASC
	RASC
	BASC
)

no, left, right, binary assoc.

View Source
const (
	DONE = iota
	MUSTDO
	MUSTLOOKAHEAD
)

flags for state generation

View Source
const (
	ACTFLAG = 1 << (iota + 2)
	REDFLAG
)

flags for a rule having an action, and being reduced

View Source
const (
	IDENTIFIER = PRIVATE + iota
	MARK
	TERM
	LEFT
	RIGHT
	BINARY
	PREC
	LCURLY
	IDENTCOLON
	NUMBER
	START
	TYPEDEF
	TYPENAME
	UNION
	ERROR
)

parse tokens

View Source
const EMPTY = 1
View Source
const ENDFILE = 0
View Source
const EOF = -1
View Source
const NOMORE = -1000
View Source
const OK = 1
View Source
const WHOKNOWS = 0

Variables

View Source
var CmdYacc = &cli.Command{
	Name:      "yacc",
	Usage:     "generates parsers for LALR(1) grammars",
	ArgsUsage: "<input>",
	Flags: []cli.Flag{
		&cli.BoolFlag{
			Name:  "l",
			Usage: "disable line directives",
		},
		&cli.StringFlag{
			Name:  "o",
			Usage: "set parser output file",
			Value: "y.wa",
		},
		&cli.StringFlag{
			Name:  "p",
			Usage: "name prefix to use in generated code",
			Value: "yy",
		},
		&cli.StringFlag{
			Name:  "v",
			Usage: "create parsing tables",
			Value: "y.output",
		},
		&cli.StringFlag{
			Name:  "c",
			Usage: "set copyright file",
			Value: "",
		},
	},
	Action: func(c *cli.Context) error {
		if c.NArg() != 1 {
			cli.ShowSubcommandHelpAndExit(c, 1)
		}
		InitFlags(Flags{
			Oflag:     c.String("o"),
			Vflag:     c.String("v"),
			Lflag:     c.Bool("l"),
			Prefix:    c.String("p"),
			Copyright: loadCopyright(c.String("c")),
		})
		Main(c.Args().First())
		return nil
	},
}

Functions

func ASSOC

func ASSOC(i int) int

macros for getting associativity and precedence levels

func InitFlags

func InitFlags(x Flags)

设置全局 Flags

func Main

func Main(filename string)

执行程序

func PLEVEL

func PLEVEL(i int) int

func SETASC

func SETASC(i, j int) int

macros for setting associativity and precedence levels

func SETPLEV

func SETPLEV(i, j int) int

func SETTYPE

func SETTYPE(i, j int) int

func TYPE

func TYPE(i int) int

Types

type Error

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

type Flags

type Flags struct {
	Oflag     string // parser output
	Vflag     string // create parsing tables
	Lflag     bool   // disable line directives
	Prefix    string // name prefix to use in generated code
	Copyright string
}

type Item

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

type Lkset

type Lkset []int

structure declarations

type Pitem

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

type Resrv

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

type Row

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

type Symb

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

type Wset

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

Jump to

Keyboard shortcuts

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