Search in sources :

Example 6 with ISyntaxComponent

use of priv.bajdcc.LL1.syntax.ISyntaxComponent in project jMiniLang by bajdcc.

the class FirstSetSolver method visitBegin.

@Override
public void visitBegin(SequenceExp node, VisitBag bag) {
    bag.bVisitChildren = false;
    bag.bVisitEnd = false;
    boolean zero = false;
    for (ISyntaxComponent exp : node.arrExpressions) {
        exp.visit(this);
        zero = bZero;
        if (!zero) {
            break;
        }
    }
    bZero = zero;
}
Also used : ISyntaxComponent(priv.bajdcc.LL1.syntax.ISyntaxComponent)

Example 7 with ISyntaxComponent

use of priv.bajdcc.LL1.syntax.ISyntaxComponent in project jMiniLang by bajdcc.

the class Syntax method doTail.

/**
 * 处理右端表达式
 *
 * @throws SyntaxException 词法错误
 */
private void doTail() throws SyntaxException {
    /* 获得分析后的表达式根结点 */
    ISyntaxComponent exp = doAnalysis(TokenType.EOF, null);
    /* 将根结点添加进对应规则 */
    RuleItem item = new RuleItem(exp, rule.rule);
    onAddRuleItem(item);
    rule.rule.arrRules.add(item);
}
Also used : RuleItem(priv.bajdcc.LL1.syntax.rule.RuleItem)

Example 8 with ISyntaxComponent

use of priv.bajdcc.LL1.syntax.ISyntaxComponent in project jMiniLang by bajdcc.

the class Syntax method getSingleString.

/**
 * 获得单一产生式描述
 *
 * @param name
 *            非终结符名称
 * @param exp
 *            表达式树
 * @return 原产生式描述
 */
public static String getSingleString(String name, ISyntaxComponent exp) {
    StringBuilder sb = new StringBuilder();
    sb.append(name);
    sb.append(" -> ");
    SyntaxToString alg = new SyntaxToString();
    exp.visit(alg);
    sb.append(alg.toString());
    return sb.toString();
}
Also used : SyntaxToString(priv.bajdcc.LL1.syntax.stringify.SyntaxToString)

Example 9 with ISyntaxComponent

use of priv.bajdcc.LL1.syntax.ISyntaxComponent in project jMiniLang by bajdcc.

the class SequenceExp method visit.

@Override
public void visit(ISyntaxComponentVisitor visitor) {
    VisitBag bag = new VisitBag();
    visitor.visitBegin(this, bag);
    if (bag.bVisitChildren) {
        for (ISyntaxComponent exp : arrExpressions) {
            exp.visit(visitor);
        }
    }
    if (bag.bVisitEnd) {
        visitor.visitEnd(this);
    }
}
Also used : ISyntaxComponent(priv.bajdcc.LL1.syntax.ISyntaxComponent) VisitBag(priv.bajdcc.util.VisitBag)

Example 10 with ISyntaxComponent

use of priv.bajdcc.LL1.syntax.ISyntaxComponent in project jMiniLang by bajdcc.

the class FirstsetSolver method visitBegin.

@Override
public void visitBegin(SequenceExp node, VisitBag bag) {
    bag.bVisitChildren = false;
    bag.bVisitEnd = false;
    boolean zero = false;
    for (ISyntaxComponent exp : node.arrExpressions) {
        exp.visit(this);
        zero = bZero;
        if (!zero) {
            break;
        }
    }
    bZero = zero;
}
Also used : ISyntaxComponent(priv.bajdcc.LALR1.syntax.ISyntaxComponent)

Aggregations

ISyntaxComponent (priv.bajdcc.LALR1.syntax.ISyntaxComponent)4 ISyntaxComponent (priv.bajdcc.LL1.syntax.ISyntaxComponent)4 VisitBag (priv.bajdcc.util.VisitBag)4 SyntaxToString (priv.bajdcc.LL1.syntax.stringify.SyntaxToString)2 BranchExp (priv.bajdcc.LL1.syntax.exp.BranchExp)1 IExpCollction (priv.bajdcc.LL1.syntax.exp.IExpCollction)1 SequenceExp (priv.bajdcc.LL1.syntax.exp.SequenceExp)1 RuleItem (priv.bajdcc.LL1.syntax.rule.RuleItem)1 OperatorType (priv.bajdcc.LL1.syntax.token.OperatorType)1