2017-09-23 16:07:59 -07:00
|
|
|
package org.nwapw.abacus.parsing
|
2017-07-29 21:02:41 -07:00
|
|
|
|
2017-09-23 16:07:59 -07:00
|
|
|
import org.nwapw.abacus.tree.TreeNode
|
2017-07-29 21:02:41 -07:00
|
|
|
|
2017-07-29 21:36:39 -07:00
|
|
|
/**
|
2017-09-23 16:07:59 -07:00
|
|
|
* Converter from tokens into a parse tree.
|
|
|
|
*
|
|
|
|
* An interface that provides the ability to convert a list of tokens
|
2017-07-29 21:36:39 -07:00
|
|
|
* into a parse tree.
|
2017-07-30 21:11:32 -07:00
|
|
|
*
|
2017-07-29 21:36:39 -07:00
|
|
|
* @param <T> the type of tokens accepted by this parser.
|
|
|
|
*/
|
2017-09-23 16:07:59 -07:00
|
|
|
|
|
|
|
interface Parser<in T> {
|
2017-07-29 21:02:41 -07:00
|
|
|
|
2017-07-29 21:36:39 -07:00
|
|
|
/**
|
|
|
|
* Constructs a tree out of the given tokens.
|
2017-07-30 21:11:32 -07:00
|
|
|
*
|
2017-07-29 21:36:39 -07:00
|
|
|
* @param tokens the tokens to construct a tree from.
|
|
|
|
* @return the constructed tree, or null on error.
|
|
|
|
*/
|
2017-09-23 16:07:59 -07:00
|
|
|
fun constructTree(tokens: List<T>): TreeNode
|
|
|
|
|
|
|
|
}
|