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

com.kero.security.lang.parsers.HasBlock Maven / Gradle / Ivy

Go to download

Kero-Security is a library for statically controlling access to properties of objects / classes.

There is a newer version: 0.1.39
Show newest version
package com.kero.security.lang.parsers;

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

import com.kero.security.lang.collections.TokenSequence;
import com.kero.security.lang.tokens.KeyWordToken;

public interface HasBlock {

	public default List parseBlock(TokenSequence tokens) {
		
		if(tokens.peek() != KeyWordToken.OPEN_BLOCK) return Collections.emptyList();
		
		tokens.poll(); // OPEN_BLOCK
		
		List units = new LinkedList<>();
		
		while(tokens.peek() != KeyWordToken.CLOSE_BLOCK) {
			
			units.add(parseBlockUnit(tokens));
		}
		
		tokens.poll(); // CLOSE_BLOCK
		
		return units;
	}
	
	public U parseBlockUnit(TokenSequence tokens);
}