All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.kero.security.lang.KsdlParser Maven / Gradle / Ivy

package com.kero.security.lang;

import java.util.ArrayList;
import java.util.List;

import com.kero.security.lang.collections.RootNodeList;
import com.kero.security.lang.collections.TokenSequence;
import com.kero.security.lang.nodes.KsdlRootNode;
import com.kero.security.lang.parsers.KsdlRootNodeParser;
import com.kero.security.lang.parsers.SchemeParser;

public class KsdlParser {

	private static final KsdlParser INSTANCE = new KsdlParser();
	
	protected List> parsers;
	
	private KsdlParser() {
		
		this.parsers = new ArrayList<>();
			parsers.add(new SchemeParser());
	}
	
	public RootNodeList parse(TokenSequence tokensArg) {
		
		TokenSequence tokens = new TokenSequence(tokensArg);
		
		RootNodeList roots = new RootNodeList();
		
		c2: while(!tokens.isEmpty()) {
			
			for(KsdlRootNodeParser parser : this.parsers) {
				
				if(parser.isMatch(tokens)) {
					
					KsdlRootNode node = parser.parse(tokens);
					
					roots.add(node);
					
					continue c2;
				}
			}
		}
		
		return roots;
	}
	
	public static KsdlParser getInstance() {
		
		return INSTANCE;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy