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

org.unlaxer.tinyexpression.parser.javalang.CodesParser Maven / Gradle / Ivy

There is a newer version: 1.4.4
Show newest version
package org.unlaxer.tinyexpression.parser.javalang;

import java.util.List;
import java.util.Optional;
import java.util.function.Supplier;
import java.util.stream.Collectors;

import org.unlaxer.Token;
import org.unlaxer.parser.Parser;
import org.unlaxer.parser.combinator.LazyZeroOrMore;
import org.unlaxer.tinyexpression.parser.javalang.CodeParser.CodeBlock;
import org.unlaxer.util.annotation.TokenExtractor;

public class CodesParser extends LazyZeroOrMore{

  @Override
  public Supplier getLazyParser() {
    return ()->Parser.get(CodeParser.class);
  }

  @Override
  public Optional getLazyTerminatorParser() {
    return Optional.empty();
  }
  
  @TokenExtractor
  public static List extractCodeBlocksAsModel(Token thisParserParsed){
    return thisParserParsed.filteredChildren.stream()
      .map(CodeParser::extractCodeBlockAsModel)
      .collect(Collectors.toList());
  }
  
  @TokenExtractor
  public static List extractCodeBlocks(Token thisParserParsed){
    return thisParserParsed.filteredChildren.stream()
      .map(CodeParser::extractCodeBlock)
      .collect(Collectors.toList());
  }
  
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy