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

com.github.uscexp.grappa.extension.parser.peg.AstCharRangeTreeNode Maven / Gradle / Ivy

There is a newer version: 0.4.0-Beta
Show newest version
/*
 * 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: charRange.
 */
public class AstCharRangeTreeNode extends AstPegBaseTreeNode {

	public AstCharRangeTreeNode(Node node, String value) {
		super(node, value);
	}

	@Override
	protected void interpret(Long id)
		throws ReflectiveOperationException {
		super.interpret(id);
		String rangeStart = (String) closeProcessStore.getStack().pop();
		String rangeEnd = (String) closeProcessStore.getStack().peek();
		if(rangeEnd.startsWith("ch('") && value.length() > 1) {
			rangeStart = rangeStart.substring(3, rangeStart.length()-1);
			rangeEnd = rangeEnd.substring(3, rangeEnd.length()-1);
			closeProcessStore.getStack().pop();
			closeProcessStore.getStack().push("charRange(" + rangeStart + ", " + rangeEnd + ")");
		} else {
			closeProcessStore.getStack().push(rangeStart);
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy