abnf

package
Version: v0.0.0-...-46acdba Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2015 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PEEKER_EOF = -1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Abnf

type Abnf interface {
	GetDependentRuleNames() Set_RuleName
	GetNFA(rules map[string]*Rule) *automata.NFA
	GetNFAStates(startState, acceptingState *automata.NFAState, rules map[string]*Rule)
}

type Alternation

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

alternation = concatenation

*(*c-wsp "/" *c-wsp concatenation)

func NewAlternation

func NewAlternation() *Alternation

func (*Alternation) AddConcatenation

func (this *Alternation) AddConcatenation(concatenation *Concatenation)

func (*Alternation) GetConcatenations

func (this *Alternation) GetConcatenations() *list.List

func (*Alternation) GetDependentRuleNames

func (this *Alternation) GetDependentRuleNames() Set_RuleName

func (*Alternation) GetNFA

func (this *Alternation) GetNFA(rules map[string]*Rule) *automata.NFA

func (*Alternation) GetNFAStates

func (this *Alternation) GetNFAStates(startState, acceptingState *automata.NFAState, rules map[string]*Rule)

func (*Alternation) String

func (this *Alternation) String() string

type BinVal

type BinVal NumVal

func (*BinVal) Expected

func (this *BinVal) Expected() string

func (*BinVal) Match

func (this *BinVal) Match(value int) bool

type CharVal

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

func NewCharVal

func NewCharVal(value string) *CharVal

func (*CharVal) GetDependentRuleNames

func (this *CharVal) GetDependentRuleNames() Set_RuleName

@Override

func (*CharVal) GetElementType

func (this *CharVal) GetElementType() ElementType

func (*CharVal) GetNFA

func (this *CharVal) GetNFA(rules map[string]*Rule) *automata.NFA

@Override

func (*CharVal) GetNFAStates

func (this *CharVal) GetNFAStates(startState, acceptingState *automata.NFAState, rules map[string]*Rule)

@Override

func (*CharVal) String

func (this *CharVal) String() string

type CollisionException

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

func NewCollisionException

func NewCollisionException(collision string, pos, line int) *CollisionException

func (*CollisionException) String

func (this *CollisionException) String() string

type Concatenation

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

concatenation = repetition *(1*c-wsp repetition)

func NewConcatenation

func NewConcatenation() *Concatenation

func (*Concatenation) AddRepetition

func (this *Concatenation) AddRepetition(repetition *Repetition)

func (*Concatenation) GetDependentRuleNames

func (this *Concatenation) GetDependentRuleNames() Set_RuleName

func (*Concatenation) GetNFA

func (this *Concatenation) GetNFA(rules map[string]*Rule) *automata.NFA

func (*Concatenation) GetNFAStates

func (this *Concatenation) GetNFAStates(startState, acceptingState *automata.NFAState, rules map[string]*Rule)

func (*Concatenation) GetRepetitions

func (this *Concatenation) GetRepetitions() *list.List

func (*Concatenation) String

func (this *Concatenation) String() string

type DecVal

type DecVal NumVal

func (*DecVal) Expected

func (this *DecVal) Expected() string

func (*DecVal) Match

func (this *DecVal) Match(value int) bool

type Element

type Element interface {
	String() string
	GetElementType() ElementType
	GetDependentRuleNames() Set_RuleName
	GetNFA(rules map[string]*Rule) *automata.NFA
	GetNFAStates(startState, acceptingState *automata.NFAState, rules map[string]*Rule)
}

type ElementType

type ElementType int
const (
	ELEMENT_RULENAME ElementType = iota
	ELEMENT_GROUP
	ELEMENT_OPTION
	ELEMENT_CHARVAL
	ELEMENT_NUMVAL
	ELEMENT_PROSEVAL
)

type Elements

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

elements = alternation *c-wsp

func NewElements

func NewElements(alternation *Alternation) *Elements

func (*Elements) GetAlternation

func (this *Elements) GetAlternation() *Alternation

func (*Elements) GetDependentRuleNames

func (this *Elements) GetDependentRuleNames() Set_RuleName

func (*Elements) GetNFA

func (this *Elements) GetNFA(rules map[string]*Rule) *automata.NFA

func (*Elements) GetNFAStates

func (this *Elements) GetNFAStates(startState, acceptingState *automata.NFAState, rules map[string]*Rule)

func (*Elements) String

func (this *Elements) String() string

type Group

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

func NewGroup

func NewGroup(alternation *Alternation) *Group

func (*Group) GetDependentRuleNames

func (this *Group) GetDependentRuleNames() Set_RuleName

func (*Group) GetElementType

func (this *Group) GetElementType() ElementType

func (*Group) GetNFA

func (this *Group) GetNFA(rules map[string]*Rule) *automata.NFA

func (*Group) GetNFAStates

func (this *Group) GetNFAStates(startState, acceptingState *automata.NFAState, rules map[string]*Rule)

func (*Group) String

func (this *Group) String() string

type HexVal

type HexVal NumVal

func (*HexVal) Expected

func (this *HexVal) Expected() string

func (*HexVal) Match

func (this *HexVal) Match(value int) bool

type MatchException

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

func NewMatchException

func NewMatchException(expected string, actual, pos, line int) *MatchException

func (*MatchException) String

func (this *MatchException) String() string

type Matcher

type Matcher interface {
	Match(value int) bool
	Expected() string
}

type NumVal

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

num-val = "%" (bin-val / dec-val / hex-val)

bin-val = "b" 1*BIT

[ 1*("." 1*BIT) / ("-" 1*BIT) ]
     ; series of concatenated bit values
     ; or single ONEOF range

dec-val = "d" 1*DIGIT

[ 1*("." 1*DIGIT) / ("-" 1*DIGIT) ]

hex-val = "x" 1*HEXDIG

[ 1*("." 1*HEXDIG) / ("-" 1*HEXDIG) ]

func NewNumVal

func NewNumVal(base string, ranged bool) *NumVal

func (*NumVal) AddValue

func (this *NumVal) AddValue(value string)

func (*NumVal) GetDependentRuleNames

func (this *NumVal) GetDependentRuleNames() Set_RuleName

func (*NumVal) GetElementType

func (this *NumVal) GetElementType() ElementType

func (*NumVal) GetNFA

func (this *NumVal) GetNFA(rules map[string]*Rule) *automata.NFA

func (*NumVal) GetNFAStates

func (this *NumVal) GetNFAStates(startState, acceptingState *automata.NFAState, rules map[string]*Rule)

@Override

func (*NumVal) GetValues

func (this *NumVal) GetValues() *list.List

func (*NumVal) String

func (this *NumVal) String() string

type Option

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

func NewOption

func NewOption(alternation *Alternation) *Option

func (*Option) GetAlternation

func (this *Option) GetAlternation() *Alternation

func (*Option) GetDependentRuleNames

func (this *Option) GetDependentRuleNames() Set_RuleName

func (*Option) GetElementType

func (this *Option) GetElementType() ElementType

func (*Option) GetNFA

func (this *Option) GetNFA(rules map[string]*Rule) *automata.NFA

func (*Option) GetNFAStates

func (this *Option) GetNFAStates(startState, acceptingState *automata.NFAState, rules map[string]*Rule)

func (*Option) String

func (this *Option) String() string

type Parser

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

ABNF文法解析器

func NewParser

func NewParser(reader io.Reader) *Parser

构造函数,设置规则名的前缀和输入源,并将普通的输入源转化为支持peek操作的输入源。

func (*Parser) ALPHA

func (this *Parser) ALPHA() string

ALPHA = 0x41-5A / 0x61-7A

func (*Parser) AssertMatchExpected

func (this *Parser) AssertMatchExpected(value, expected int)

如果不匹配则抛出MatchException异常 MatchException中包含了产生匹配异常的符号输入流中的行列位置,以及期待的字符。

func (*Parser) AssertMatchExpectedIgnoreCase

func (this *Parser) AssertMatchExpectedIgnoreCase(value int, expected byte)

如果不匹配(忽略大小写)则抛出MatchException异常 MatchException中包含了产生匹配异常的符号输入流中的行列位置,以及期待的字符。

func (*Parser) AssertMatchRange

func (this *Parser) AssertMatchRange(value, lower, upper int)

如果字符不在某个范围之内则抛出MatchException异常 MatchException中包含了产生匹配异常的符号输入流中的行列位置,以及期待的字符。

func (*Parser) BIT

func (this *Parser) BIT() string

BIT = "0" / "1"

func (*Parser) CHAR

func (this *Parser) CHAR() string

CHAR = %x01-7E

func (*Parser) CR

func (this *Parser) CR() string

CR = %x0D

func (*Parser) CRLF

func (this *Parser) CRLF() string

CRLF = CR LF

func (*Parser) CTL

func (this *Parser) CTL() string

CTL = 0x00-1F / 0x7F

func (*Parser) DIGIT

func (this *Parser) DIGIT() string

DIGIT = %x30-39

func (*Parser) DQUOTE

func (this *Parser) DQUOTE() string

DQUOTE = %x22

func (*Parser) HEXDIG

func (this *Parser) HEXDIG() string

HEXDIG = DIGIT/"A"/"B"/"C"/"D"/"E"/"F"

func (*Parser) HTAB

func (this *Parser) HTAB() string

HTAB = %x09

func (*Parser) LF

func (this *Parser) LF() string

LF = %x0A

func (*Parser) LWSP

func (this *Parser) LWSP() string

LWSP = *(WSP / CRLF WSP) ?

func (*Parser) MatchExpected

func (this *Parser) MatchExpected(value, expected int) bool

match函数用来判断两个字符是否相同 (例如判断输入的字符是否与期望的字符相同)

func (*Parser) MatchExpectedChars

func (this *Parser) MatchExpectedChars(value int, expected []int) bool

match函数用来判断字符是否与某些字符相同 (例如判断输入的字符是否为'-','+',或'%')

func (*Parser) MatchExpectedIgnoreCase

func (this *Parser) MatchExpectedIgnoreCase(value int, expected byte) bool

func (*Parser) MatchRange

func (this *Parser) MatchRange(value, lower, upper int) bool

match函数用来判断字符是否在某个范围之内 (例如判断输入的字符是否是字母、或数字字符等)

func (*Parser) OCTET

func (this *Parser) OCTET() string

OCTET = %x00-FF

func (*Parser) Parse

func (this *Parser) Parse() (*list.List, error)

调用parse函数开始对输入源进行解析,返回输入源中定义的ABNF规则列表

func (*Parser) SP

func (this *Parser) SP() string

SP = %x20

func (*Parser) VCHAR

func (this *Parser) VCHAR() string

VCHAR = %x21-7E

func (*Parser) WSP

func (this *Parser) WSP() string

WSP = SP / HTAB

type Peeker

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

func NewPeeker

func NewPeeker(reader io.Reader) *Peeker

*

* The constructor accepts an InputStream to setup the
* object.
*
* @param is
*          The InputStream to parse.

func (*Peeker) GetLine

func (this *Peeker) GetLine() int

func (*Peeker) GetPos

func (this *Peeker) GetPos() int

func (*Peeker) Peek

func (this *Peeker) Peek(depth int) int

*

* Peek at a specified depth.
*
* @param depth
*          The depth to check.
* @return The character peeked at.
* @throws IOException
*           If an I/O exception occurs.

func (*Peeker) Read

func (this *Peeker) Read() int

func (*Peeker) UpdatePosition

func (this *Peeker) UpdatePosition(value byte)

when read LF, set pos = 1 when read CR, line++

type ProseVal

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

func NewProseVal

func NewProseVal(value string) *ProseVal

func (*ProseVal) GetDependentRuleNames

func (this *ProseVal) GetDependentRuleNames() Set_RuleName

func (*ProseVal) GetElementType

func (this *ProseVal) GetElementType() ElementType

func (*ProseVal) GetNFA

func (this *ProseVal) GetNFA(rules map[string]*Rule) *automata.NFA

func (*ProseVal) GetNFAStates

func (this *ProseVal) GetNFAStates(startState, acceptingState *automata.NFAState, rules map[string]*Rule)

func (*ProseVal) String

func (this *ProseVal) String() string

type RegularAnalyzer

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

func NewRegularAnalyzer

func NewRegularAnalyzer(rules *list.List) *RegularAnalyzer

func (*RegularAnalyzer) ContainsAll

func (this *RegularAnalyzer) ContainsAll(definedRuleNames Set_RuleName, dependent Set_RuleName) bool

func (*RegularAnalyzer) GetNonRegularRules

func (this *RegularAnalyzer) GetNonRegularRules() *list.List

func (*RegularAnalyzer) GetRegularRules

func (this *RegularAnalyzer) GetRegularRules() *list.List

func (*RegularAnalyzer) GetUndefinedRules

func (this *RegularAnalyzer) GetUndefinedRules() *list.List

type Repeat

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

repeat = 1*DIGIT / (*DIGIT "*" *DIGIT)

func NewRepeat

func NewRepeat(min, max int, starred bool) *Repeat

func (*Repeat) GetMax

func (this *Repeat) GetMax() int

func (*Repeat) GetMin

func (this *Repeat) GetMin() int

func (*Repeat) String

func (this *Repeat) String() string

type Repetition

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

repetition = [repeat] element

func NewRepetition

func NewRepetition(repeat *Repeat, element Element) *Repetition

func (*Repetition) GetDependentRuleNames

func (this *Repetition) GetDependentRuleNames() Set_RuleName

func (*Repetition) GetNFA

func (this *Repetition) GetNFA(rules map[string]*Rule) *automata.NFA

func (*Repetition) GetNFAStates

func (this *Repetition) GetNFAStates(startState, acceptingState *automata.NFAState, rules map[string]*Rule)

func (*Repetition) String

func (this *Repetition) String() string

type Rule

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

func NewRule

func NewRule(ruleName *RuleName, definedAs string, elements *Elements) *Rule

func (*Rule) GetDefinedAs

func (this *Rule) GetDefinedAs() string

func (*Rule) GetElements

func (this *Rule) GetElements() *Elements

func (*Rule) GetRuleName

func (this *Rule) GetRuleName() *RuleName

func (*Rule) SetDefinedAs

func (this *Rule) SetDefinedAs(definedAs string)

func (*Rule) String

func (this *Rule) String() string

type RuleName

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

func NewRuleName

func NewRuleName(rulename string) *RuleName

func (*RuleName) GetDependentRuleNames

func (this *RuleName) GetDependentRuleNames() Set_RuleName

func (*RuleName) GetElementType

func (this *RuleName) GetElementType() ElementType

func (*RuleName) GetNFA

func (this *RuleName) GetNFA(rules map[string]*Rule) *automata.NFA

func (*RuleName) GetNFAStates

func (this *RuleName) GetNFAStates(startState, acceptingState *automata.NFAState, rules map[string]*Rule)

func (*RuleName) String

func (this *RuleName) String() string

type Set_RuleName

type Set_RuleName map[string]*RuleName

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL