import { RuleType , TokenType } from './Parser' ; import IToken from './IToken' ; export default class AstNode { private readonly subItems = new Map < any , any [ ] > ( ) ; constructor ( public readonly ruleType ) { } public add ( type , obj ) { let items = this . subItems . get ( type ) ; if ( items === undefined ) { items = [ ] ; this . subItems . set ( type , items ) ; } items . push ( obj ) ; } public getSingle ( ruleType ) { return ( this . subItems . get ( ruleType ) || [ ] ) [ 0 ] ; } public getItems ( ruleType ) { return this . subItems . get ( ruleType ) || [ ] ; } public getToken ( tokenType ) { return ( this . subItems . get ( tokenType ) || [ ] ) [ 0 ] ; } public getTokens ( tokenType ) { return this . subItems . get ( tokenType ) || [ ] ; } }