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

com.kero.security.lang.parsers.metaline.HasMetalines Maven / Gradle / Ivy

package com.kero.security.lang.parsers.metaline;

import java.util.LinkedList;
import java.util.List;

import com.kero.security.lang.collections.TokenSequence;
import com.kero.security.lang.nodes.metaline.MetalineNode;
import com.kero.security.lang.parsers.exceptions.ParserNotFoundException;
import com.kero.security.lang.tokens.KeyWordToken;

public interface HasMetalines {

	public default List parseMetalines(TokenSequence tokens) {
		
		List metalines = new LinkedList<>();
		
		while(tokens.peek() == KeyWordToken.METALINE) {
			
			metalines.add(parseLine(tokens));
		}
		
		return metalines;
	}
	
	public default N parseLine(TokenSequence tokens) {

		List> parsers = getMetalineParsers();

		for(MetalineParser parser : parsers) {
			
			if(parser.isMatch(tokens)) {
				
				return parser.parse(tokens);
			}
		}
		
		throw new ParserNotFoundException("Can't find parser for metaline!");
	}
	
	public List> getMetalineParsers();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy