com.github.uscexp.grappa.extension.nodes.AstValueTreeNode Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of grappa.extension Show documentation
Show all versions of grappa.extension Show documentation
Extension for parboiled/grappa parser.
The newest version!
/*
* Copyright (C) 2014 - 2016 by haui - all rights reserved
*/
package com.github.uscexp.grappa.extension.nodes;
import com.github.uscexp.grappa.extension.annotations.AstValue;
import com.github.uscexp.grappa.extension.interpreter.AstInterpreter;
import com.github.uscexp.grappa.extension.interpreter.ProcessStore;
/**
* {@link AstTreeNode} for {@link AstValue} annotated parser rules.
* will be instanciated automatically from the {@link AstInterpreter}.
*
* @author haui
*
*/
public class AstValueTreeNode extends AstTreeNode {
private Class> valueType;
private Class> factoryClass;
private String factoryMethod;
public AstValueTreeNode(String rule, String value, Class> valueType, Class> factoryClass, String factoryMethod) {
super(rule, value);
this.valueType = valueType;
this.factoryClass = factoryClass;
this.factoryMethod = factoryMethod;
}
@Override
protected void interpretBeforeChilds(Long id) throws Exception {
}
@Override
protected void interpretAfterChilds(Long id) throws Exception {
ProcessStore.getInstance(id).getStack().push(convert(value, valueType, factoryClass, factoryMethod));
}
}