Skip to content
Snippets Groups Projects
Commit 80c4135a authored by Tim Kluge's avatar Tim Kluge
Browse files

Refactor files

parent 6fceb27b
No related branches found
No related tags found
No related merge requests found
Pipeline #9726 passed
......@@ -24,18 +24,3 @@ class AndParser(children: List<Parser>, nodeFunc: NodeTransform = ::emptyNodeTra
}
}
class OrParser(children: List<Parser>, nodeFunc: NodeTransform = ::emptyNodeTransform): ParserWithChildren(children, nodeFunc) {
override val typeName: String = "OrParser"
override fun Match(s: Scanner): Node? {
val startPosition = s.position
children.forEach {
val node = s.applyRule(it)
if(node != null){
return Node(node.matched, this, listOf(node))
}
s.position = startPosition
}
return null
}
}
\ No newline at end of file
......@@ -10,20 +10,3 @@ class EmptyParser(transform: NodeTransform = ::emptyNodeTransform) : Parser(tran
}
}
class EndParser(val skipWhitespace: Boolean = true) : Parser() {
override val typeName: String = "EndParser"
override fun Match(s: Scanner): Node? {
val startPosition = s.position
if(skipWhitespace){
s.skipWhitespace()
}
if(s.position == s.input.length){
return Node("", this, listOf())
}
s.position = startPosition
return null
}
}
\ No newline at end of file
package de.timklge.jackrat
import jackrat.de.timklge.jackrat.Scanner
class EndParser(val skipWhitespace: Boolean = true) : Parser() {
override val typeName: String = "EndParser"
override fun Match(s: Scanner): Node? {
val startPosition = s.position
if(skipWhitespace){
s.skipWhitespace()
}
if(s.position == s.input.length){
return Node("", this, listOf())
}
s.position = startPosition
return null
}
}
\ No newline at end of file
package de.timklge.jackrat
import jackrat.de.timklge.jackrat.Scanner
class OrParser(children: List<Parser>, nodeFunc: NodeTransform = ::emptyNodeTransform): ParserWithChildren(children, nodeFunc) {
override val typeName: String = "OrParser"
override fun Match(s: Scanner): Node? {
val startPosition = s.position
children.forEach {
val node = s.applyRule(it)
if(node != null){
return Node(node.matched, this, listOf(node))
}
s.position = startPosition
}
return null
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment