cdtgo

package
v0.0.0-...-10cd259 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2020 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const (
	NO_RULES   = 112
	GOAL_RULE  = NO_RULES + 1
	NO_SYMBOLS = 101
	NO_STATES  = 193
)
View Source
const (
	NO_KEYWORD = 7
	ID_LENGTH  = 12
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

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

func Parse

func Parse(src string) (*Node, error)

func (*Node) Format

func (s *Node) Format(eachIndent int) string

func (*Node) IsTerminal

func (s *Node) IsTerminal() bool

func (*Node) String

func (s *Node) String() string

type Parser

type Parser struct {
	ShiftHandle  func(Token)
	ReduceHandle func(Rule)
	Input        []Token
	// contains filtered or unexported fields
}

func NewParser

func NewParser(input ...Token) *Parser

func (*Parser) CurrentState

func (s *Parser) CurrentState() int

func (*Parser) IsInit

func (s *Parser) IsInit() bool

func (*Parser) Parsing

func (s *Parser) Parsing() error

func (*Parser) Step

func (s *Parser) Step() error

nil 값이 리턴되면 아직 파싱할 요소가 남음을 의미 io.EOF 값이 리턴되면 더이상 파싱할 값이 없음을 의미 그외의 값은 예상치 못한 에러를 나타냄

type Rule

type Rule int

func (Rule) IsNaming

func (r Rule) IsNaming() bool

func (Rule) String

func (r Rule) String() string

type Token

type Token struct {
	Kind TokenKind
	Data interface{}
}

func Scanning

func Scanning(input string) ([]Token, error)

func ScanningStep

func ScanningStep(input string) (left string, found Token)

func (*Token) String

func (s *Token) String() string

type TokenKind

type TokenKind int
const (
	Tnull      TokenKind = -1
	Tnot       TokenKind = 0
	Tnotequ    TokenKind = 1
	Tremainder TokenKind = 2
	TremAssign TokenKind = 3
	Tident     TokenKind = 4
	Tnumber    TokenKind = 5
	Tand       TokenKind = 6
	Tlparen    TokenKind = 7
	Trparen    TokenKind = 8
	Tmul       TokenKind = 9
	TmulAssign TokenKind = 10
	Tplus      TokenKind = 11
	Tinc       TokenKind = 12
	TaddAssign TokenKind = 13
	Tcomma     TokenKind = 14
	Tminus     TokenKind = 15
	Tdec       TokenKind = 16
	TsubAssign TokenKind = 17
	Tdiv       TokenKind = 18
	TdivAssign TokenKind = 19
	Tcolon     TokenKind = 20
	Tsemicolon TokenKind = 21
	Tless      TokenKind = 22
	Tlesse     TokenKind = 23
	Tassign    TokenKind = 24
	Tequal     TokenKind = 25
	Tgreat     TokenKind = 26
	Tgreate    TokenKind = 27
	Tlbracket  TokenKind = 28
	Trbracket  TokenKind = 29
	Teof       TokenKind = 30

	//   ...........    word symbols ................................. //
	Tbreak    TokenKind = 31
	Tcase     TokenKind = 32
	Tconst    TokenKind = 33
	Tcontinue TokenKind = 34
	Tdefault  TokenKind = 35
	Tdo       TokenKind = 36
	Telse     TokenKind = 37
	Tfor      TokenKind = 38
	Tif       TokenKind = 39
	Tint      TokenKind = 40
	Treturn   TokenKind = 41
	Tswitch   TokenKind = 42
	Tvoid     TokenKind = 43
	Twhile    TokenKind = 44
	Tlbrace   TokenKind = 45
	Tor       TokenKind = 46
	Trbrace   TokenKind = 47
)

func (TokenKind) String

func (t TokenKind) String() string

Jump to

Keyboard shortcuts

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