com.github.uscexp.grappa.extension.parser.peg.AstSQUAREOPENTreeNode 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.
/*
* Copyright (C) 2014 by haui - all rights reserved
*/
package com.github.uscexp.grappa.extension.parser.peg;
import org.parboiled.Node;
/**
* Command implementation for the PegParser
rule: SQUAREOPEN.
*/
public class AstSQUAREOPENTreeNode extends AstPegBaseTreeNode {
public AstSQUAREOPENTreeNode(Node> node, String value) {
super(node, value);
}
@Override
protected void interpret(Long id)
throws ReflectiveOperationException {
super.interpret(id);
if (!closeProcessStore.getStack().isEmpty()) {
String rule = "";
String stackValue = (String) closeProcessStore.getStack().pop();
int i = 0;
while (!closeProcessStore.getStack().isEmpty() && !stackValue.equals(AstSQUARECLOSETreeNode.CLOSE)) {
if(i > 0) {
rule += ", ";
}
rule += stackValue;
++i;
stackValue = (String) closeProcessStore.getStack().pop();
}
if(i > 1) {
rule = "firstOf(" + rule + ")";
}
closeProcessStore.getStack().push(rule);
}
}
}