Browse Source

add parsing rules for AND_TEST

master
Brett Langdon 10 years ago
parent
commit
e20e933cd2
2 changed files with 19 additions and 0 deletions
  1. +1
    -0
      ast/tests.go
  2. +18
    -0
      parser/parser.go

+ 1
- 0
ast/tests.go View File

@ -71,4 +71,5 @@ func NewNotTest() *NotTest {
} }
func (node *NotTest) notTestChild() {} func (node *NotTest) notTestChild() {}
func (node *NotTest) andTestChild() {}
func (node *NotTest) SetChild(n NotTestChild) { node.ParentNode.SetChild(n) } func (node *NotTest) SetChild(n NotTestChild) { node.ParentNode.SetChild(n) }

+ 18
- 0
parser/parser.go View File

@ -71,6 +71,24 @@ func (parser *Parser) parseNotTest() *ast.NotTest {
// and_test: not_test ('and' not_test)* // and_test: not_test ('and' not_test)*
func (parser *Parser) parseAndTest() *ast.AndTest { func (parser *Parser) parseAndTest() *ast.AndTest {
andTest := ast.NewAndTest() andTest := ast.NewAndTest()
notTest := parser.parseNotTest()
if notTest == nil {
return nil
}
andTest.Append(notTest)
for {
next := parser.nextToken()
if !next.IsLiteral("and") {
parser.unreadToken(next)
break
}
notTest = parser.parseNotTest()
if notTest == nil {
return nil
}
andTest.Append(notTest)
}
return andTest return andTest
} }


Loading…
Cancel
Save