exper

package
v0.0.0-...-e19c9e5 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TokenSequence []Token
	CurPtr        = 0
)
View Source
var SpeciesCode = map[string]string{
	"":           "",
	"integer":    "INTCON",
	"string":     "STRCON",
	"const":      "CONSTTK",
	"charc":      "CHARCON",
	"main":       "MAINTK",
	"identifier": "IDENFR",
	"return":     "RETURNTK",
	"do":         "DOTK",
	"void":       "VOIDTK",
	"for":        "FORTK",
	"scanf":      "SCANFTK",
	"int":        "INTTK",
	"else":       "ELSETK",
	"char":       "CHARTK",
	"while":      "WHILETK",
	"printf":     "PRINTFTK",
	"if":         "IFTK",
	"-":          "MINU",
	"+":          "PLUS",
	"*":          "MULT",
	"/":          "DIV",
	"<":          "LSS",
	"<=":         "LEQ",
	">":          "GRE",
	">=":         "GEQ",
	"==":         "EQL",
	"!=":         "NEQ",
	"=":          "ASSIGN",
	";":          "SEMICN",
	",":          "COMMA",
	"(":          "LPARENT",
	")":          "RPARENT",
	"[":          "LBRACK",
	"]":          "RBRACK",
	"{":          "LBRACE",
	"}":          "RBRACE",
}

Functions

func AnalysisToken

func AnalysisToken(input, output string) error

func CompareTwoFile

func CompareTwoFile(res, ans string)

func GrammarAnalysis

func GrammarAnalysis(input, output string) error

func GrammarDeduction

func GrammarDeduction()

func InitTokenSequence

func InitTokenSequence()

func IsConstDef

func IsConstDef(tkSpecCode string) bool
tkSpecCode == "IDENFR" ||
tkSpecCode == "INTCON" ||
tkSpecCode == "CHARCON" ||
tkSpecCode == "INTTK" ||
tkSpecCode =="CHARTK" ||
tkSpecCode == "ASSIGN" ||
tkSpecCode == "COMMA"  ||
tkSpecCode == "MINUS" ||
tkSpecCode == "PLUS"

检查标识符重复错误 只输出,不检查语法,不分析语法错误

func RemoveLeftToken

func RemoveLeftToken(in, out string)

func WalkPrintToken

func WalkPrintToken(n int)

func WriteFileLine

func WriteFileLine(str string)

Types

type Token

type Token struct {
	SpeciesCode string
	Value       string
}

func GetNextNThToken

func GetNextNThToken(n int) *Token

func GetNextToken

func GetNextToken() *Token

func NextToken

func NextToken() *Token

func (*Token) String

func (token *Token) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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