You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.0 KiB
Go

package shell
type Block struct {
BaseToken
}
type DollarBlock struct {
BaseToken
}
type BlockParameters struct{}
type DollarBlockParameters struct {
BlockParameters
}
func (p *BlockParameters) Enter(i *CharIterator) error {
return i.Next()
}
func (p *DollarBlockParameters) SubParsers() []Parser {
return []Parser{
&BaseParser{
parameters: &WordParameters{},
},
}
}
func (p *DollarBlockParameters) MakeToken() Token {
return &DollarBlock{}
}
func (p *BlockParameters) SubParsers() []Parser {
return []Parser{
&BaseParser{
parameters: &StatementParameters{},
},
}
}
func (p *BlockParameters) Supports(charsBefore []rune, r rune) bool {
if r == '{' {
return len(charsBefore) == 0 ||
countBackslashSuffixes(charsBefore)%2 == 0
}
return false
}
func (p *BlockParameters) ShouldLeave(charsBefore []rune, r rune) bool {
if r == '}' {
return len(charsBefore) == 0 ||
countBackslashSuffixes(charsBefore)%2 == 0
}
return false
}
func (p *BlockParameters) MakeToken() Token {
return &Block{}
}