コード例 #1
0
ファイル: LineParser0.java プロジェクト: hetykai/gyuhji56
  private NaleNode statement0() throws JmoException {

    Token t = buf.findValid();
    if (t == null) {
      return null;
    }
    if (t.getType() == TokenType.IF) {
      buf.takeToken();
      Token tx = buf.findValid();
      this.expectNotNull(tx);
      NaleNode nq;
      if (tx.getType() == TokenType.TRUE) {
        nq = new BooleanNode(true, tx.getPosition());
        buf.takeToken();
      } else if (tx.getType() == TokenType.FALSE) {
        nq = new BooleanNode(false, tx.getPosition());
        buf.takeToken();
      } else {
        nq = parseVariable();
      }
      this.expectLineEnd();
      return new IFNode(nq, t.getPosition());
    } else if (t.getType() == TokenType.FI) {
      NaleNode node = new IFEndNode(t.getPosition());
      buf.takeToken();
      expectEnd();
      return node;
    } else if (t.getType() == TokenType.DEBUG) {
      buf.takeToken();
      expectEnd();
      return new DebuggerNode(t.getPosition());

    } else if (t.getType() == TokenType.EXPORT) {
      buf.takeToken();
      NaleNode nn = statement();
      if (nn instanceof VarNode) {

        VarNode vn = (VarNode) nn;
        if (vn.getParNode() != null) {
          throw new ParseException("can not export varNode with member:" + vn, t.getPosition());
        }
        return new ExpNode(t.getPosition(), (VarNode) nn);
      } else if (nn instanceof AssignableNode) {
        return new ExpNode(t.getPosition(), (AssignableNode) nn);
      } else {
        throw new ParseException("can not export non-varNode! " + nn, t.getPosition());
      }
    } else if (t.getType() == TokenType.echo) {
      buf.takeToken();
      Token n = buf.findValid();
      this.expectNotNull(n);
      NaleNode node = regexNode(t.getPosition());
      return new EchoNode(node, t.getPosition());
    } else {
      return statement();
    }
  }
コード例 #2
0
ファイル: LineParser0.java プロジェクト: hetykai/gyuhji56
  protected NaleNode parseVariable() throws JmoException {
    VarNode varNode = varNode();
    while (true) {
      Token t = buf.findValid();
      if (t == null) {
        return varNode;
      }
      if (t.getType() == TokenType.LPAREN) { // function
        expectValid(TokenType.LPAREN);
        List<ReferNode> paras = funcParasNode();
        expectValid(TokenType.RPAREN);
        FunctionCallNode fncN =
            new FunctionCallNode(
                t.getPosition(), varNode.getParNode(), varNode.getVarName(), paras);
        expectLineEnd();
        return fncN;
      } else if (t.getType() == TokenType.DOT) {
        buf.takeToken();
        VarNode varsub = varNode();
        varNode = new VarNode(varNode.getPosition(), varNode, varsub.getVarName());
      } else {

        return varNode;
      }
    }
  }