Package com.creativewidgetworks.goldparser.simple3.rulehandlers

Source Code of com.creativewidgetworks.goldparser.simple3.rulehandlers.StringLiteral

package com.creativewidgetworks.goldparser.simple3.rulehandlers;

import com.creativewidgetworks.goldparser.engine.Reduction;
import com.creativewidgetworks.goldparser.parser.ProcessRule;
import com.creativewidgetworks.goldparser.parser.Variable;
import com.creativewidgetworks.goldparser.parser.GOLDParser;

@ProcessRule(rule="<Value> ::= StringLiteral")

/**
* Rule handler for the string literal rule.
*
* @author Ralph Iden (http://www.creativewidgetworks.com)
* @version 5.0.0
*/
public class StringLiteral extends Reduction {

    public StringLiteral(GOLDParser parser) {
        // The null test is being performed because this class is used in a test where the parser
        // is not completely initialized.  In production, the current reduction will always be set.
        String str = parser.getCurrentReduction() == null ? "\"\"" : parser.getCurrentReduction().get(0).asString();
       
        StringBuilder sb = new StringBuilder(str);
        sb.deleteCharAt(sb.length() - 1);
        sb.deleteCharAt(0);
        setValue(new Variable(sb.toString()));
    }

}
TOP

Related Classes of com.creativewidgetworks.goldparser.simple3.rulehandlers.StringLiteral

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.