Examples of SwitchStatement


Examples of anvil.script.statements.SwitchStatement

  }

  final public void SwitchStatement(String label) throws ParseException {
  Token t;
  Case caze;
  SwitchStatement stmt;
    t = jj_consume_token(SWITCH);
    jj_consume_token(OPEN);
    Expression();
    jj_consume_token(CLOSE);
    jj_consume_token(BEGIN);
      stmt = new SwitchStatement(flowPeek(), toLocation(t), (Expression)pop(), label);
      flowPushChild(stmt);
    label_22:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case CASE:
      case _DEFAULT:
        ;
        break;
      default:
        jj_la1[63] = jj_gen;
        break label_22;
      }
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case CASE:
        t = jj_consume_token(CASE);
        ValueExpression();
          caze = stmt.onCase(this, (Expression)pop());
        label_23:
        while (true) {
          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
          case COMMA:
            ;
            break;
          default:
            jj_la1[64] = jj_gen;
            break label_23;
          }
          jj_consume_token(COMMA);
          ValueExpression();
          caze = stmt.onCase(this, (Expression)pop());
        }
        flowPush(caze.getBlock());
        jj_consume_token(COLON);
        label_24:
        while (true) {
          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
          case MODULE:
          case SYMBOL:
          case BEGIN:
          case DOT:
          case STAR:
          case IMPORT:
          case STRING_LITERAL:
          case SEMICOLON:
          case RANGE:
          case FUNCTION:
          case OPEN:
          case SUPER:
          case SYNCHRONIZED:
          case STATIC:
          case CLASS:
          case VAR:
          case IF:
          case WHILE:
          case TRY:
          case CATCH:
          case FINALLY:
          case THROW:
          case PRINT:
          case HOOK:
          case PRINTLN:
          case PRINTBR:
          case SWITCH:
          case FOR:
          case DO:
          case FOREACH:
          case BREAK:
          case CONTINUE:
          case EXIT:
          case RETURN:
          case YIELD:
          case ASSERT:
          case ET:
          case NEGATION:
          case PLUS:
          case MINUS:
          case MINUSMINUS:
          case PLUSPLUS:
          case COPYOF:
          case CLONEOF:
          case TYPEOF:
          case SIZEOF:
          case CLASSOF:
          case BOOLEAN:
          case INT:
          case FLOAT:
          case STRING:
          case DEFINED:
          case UNDEFINED:
          case NULL:
          case OPEN_BRACKET:
          case CARET:
          case DELETE:
          case BEGIN_LIST:
          case NEW:
          case THIS:
          case INTEGER_LITERAL:
          case FLOATING_POINT_LITERAL:
          case INF:
          case FALSE:
          case TRUE:
          case PATTERN:
            ;
            break;
          default:
            jj_la1[65] = jj_gen;
            break label_24;
          }
          Statement();
        }
        flowPop();
        break;
      case _DEFAULT:
        t = jj_consume_token(_DEFAULT);
        jj_consume_token(COLON);
        caze = stmt.onDefault(this, toLocation(t));
        flowPush(caze.getBlock());
        label_25:
        while (true) {
          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
          case MODULE:
View Full Code Here

Examples of com.bacoder.parser.java.api.SwitchStatement

    return returnStatement;
  }

  protected SwitchStatement processSwitchStatement(StatementContext context) {
    SwitchStatement switchStatement = createNode(context, SwitchStatement.class);

    ParExpressionContext parExpressionContext = getChild(context, ParExpressionContext.class);
    switchStatement.setExpression(processParExpression(parExpressionContext));

    List<SwitchBlock> switchBlocks = transform(context, SwitchBlockStatementGroupContext.class,
        new Function<SwitchBlockStatementGroupContext, SwitchBlock>() {
          @Override
          public SwitchBlock apply(SwitchBlockStatementGroupContext context) {
            SwitchBlock switchBlock = createNode(context, SwitchBlock.class);
            switchBlock.setLabels(getSwitchLabels(context));
            switchBlock.setStatements(transform(context, BlockStatementContext.class,
                new Function<BlockStatementContext, BlockStatement>() {
                  @Override
                  public BlockStatement apply(BlockStatementContext context) {
                    return getAdapter(BlockStatementAdapter.class).adapt(context);
                  }
                }));
            return switchBlock;
          }
        });

    List<SwitchLabel> extraSwitchLabels = getSwitchLabels(context);
    if (!extraSwitchLabels.isEmpty()) {
      List<SwitchLabelContext> switchLabelContexts = getChildren(context, SwitchLabelContext.class);
      SwitchBlock extraSwitchBlock =
          createNode(switchLabelContexts.get(0),
              switchLabelContexts.get(switchLabelContexts.size() - 1), SwitchBlock.class);
      extraSwitchBlock.setLabels(extraSwitchLabels);
      switchBlocks.add(extraSwitchBlock);
    }

    switchStatement.setSwitchBlocks(switchBlocks);

    return switchStatement;
  }
View Full Code Here

Examples of com.dragome.compiler.ast.SwitchStatement

    }
  }

  void rollOut_(Block block)
  {
    SwitchStatement switchStmt= new SwitchStatement();
    switchStmt.setExpression(header.switchExpression);

    for (int i= 0; i < caseGroups.size(); i++)
    {
      Node scNode= caseGroups.get(i);
      SwitchCase switchCase= new SwitchCase(scNode.getInitialPc());
      switchCase.setExpressions(caseGroupExpressions.get(i));
      switchStmt.appendChild(switchCase);

      graph.rollOut(scNode, switchCase);
    }

    block.appendChild(switchStmt);
View Full Code Here

Examples of com.google.dart.engine.ast.SwitchStatement

    NodeList<Statement> statements = node.getStatements();
    if (statements.isEmpty()) {
      // fall-through without statements at all
      AstNode parent = node.getParent();
      if (parent instanceof SwitchStatement) {
        SwitchStatement switchStatement = (SwitchStatement) parent;
        NodeList<SwitchMember> members = switchStatement.getMembers();
        int index = members.indexOf(node);
        if (index != -1 && index < members.size() - 1) {
          return false;
        }
      }
View Full Code Here

Examples of com.google.minijoe.compiler.ast.SwitchStatement

    CaseStatement[] caseClauseArray = new CaseStatement[caseClauseVector.size()];

    caseClauseVector.copyInto(caseClauseArray);

    return new SwitchStatement(switchExpression, caseClauseArray);
  }
View Full Code Here

Examples of com.google.minijoe.compiler.ast.SwitchStatement

    super(name);
  }

  public void testSwitchStatement() throws CompilerException {
    assertParserOutput(
        new SwitchStatement(
            new Identifier("something"),
            new CaseStatement[] {
            }
        ),
        "switch (something) {}"
    );
    assertParserOutput(
        new SwitchStatement(
            new Identifier("something"),
            new CaseStatement[] {
              new CaseStatement(
                  null,
                  new Statement[] {
                      new ExpressionStatement(
                          new Identifier("foo")
                      )
                  }
              )
            }
        ),
        "switch (something) {default: foo;}"
    );
    assertParserOutput(
        new SwitchStatement(
            new Identifier("something"),
            new CaseStatement[] {
              new CaseStatement(
                  new NumberLiteral(0),
                  new Statement[] {
                    new ExpressionStatement(
                        new Identifier("bar")
                    )
                  }
              )
            }
        ),
        "switch (something) {case 0: bar;}"
    );
    assertParserOutput(
        new SwitchStatement(
            new Identifier("something"),
            new CaseStatement[] {
              new CaseStatement(
                  new NumberLiteral(0),
                  new Statement[] {
                    new ExpressionStatement(
                        new Identifier("bar")
                    )
                  }
              ),
              new CaseStatement(
                  new NumberLiteral(1),
                  new Statement[] {
                    new ExpressionStatement(
                        new Identifier("baz")
                    )
                  }
              )
            }
        ),
        "switch (something) {case 0: bar; case 1: baz;}"
    );
    assertParserOutput(
        new SwitchStatement(
            new Identifier("something"),
            new CaseStatement[] {
              new CaseStatement(
                  null,
                  new Statement[] {
                      new ExpressionStatement(
                          new Identifier("foo")
                      )
                  }
              ),
              new CaseStatement(
                  new NumberLiteral(0),
                  new Statement[] {
                    new ExpressionStatement(
                        new Identifier("bar")
                    )
                  }
              ),
              new CaseStatement(
                  new NumberLiteral(1),
                  new Statement[] {
                    new ExpressionStatement(
                        new Identifier("baz")
                    )
                  }
              )
            }
        ),
        "switch (something) {default: foo; case 0: bar; case 1: baz;}"
    );
    assertParserOutput(
        new SwitchStatement(
            new Identifier("something"),
            new CaseStatement[] {
              new CaseStatement(
                  new NumberLiteral(0),
                  new Statement[] {
                    new ExpressionStatement(
                        new Identifier("bar")
                    )
                  }
              ),
              new CaseStatement(
                  null,
                  new Statement[] {
                      new ExpressionStatement(
                          new Identifier("foo")
                      )
                  }
              ),
              new CaseStatement(
                  new NumberLiteral(1),
                  new Statement[] {
                    new ExpressionStatement(
                        new Identifier("baz")
                    )
                  }
              )
            }
        ),
        "switch (something) {case 0: bar; default: foo; case 1: baz;}"
    );
    assertParserOutput(
        new SwitchStatement(
            new Identifier("something"),
            new CaseStatement[] {
              new CaseStatement(
                  new NumberLiteral(0),
                  new Statement[] {
View Full Code Here

Examples of com.google.test.metric.cpp.dom.SwitchStatement

    finished();
  }

  @Override
  public void beginSwitchStatement() {
    Node node = new SwitchStatement();
    parent.addChild(node);
    pushBuilder(new StatementBuilder(node));
  }
View Full Code Here

Examples of com.google.test.metric.cpp.dom.SwitchStatement

  }

  public void testSwitchStatement() throws Exception {
    TranslationUnit unit = parse("void foo() { switch (a) { case 1: break; } }");
    FunctionDefinition functionFoo = unit.getChild(0);
    SwitchStatement switchStatement = functionFoo.getChild(0);
    CaseStatement caseStatement = switchStatement.getChild(0);
    assertNotNull(caseStatement);
  }
View Full Code Here

Examples of com.google.test.metric.cpp.dom.SwitchStatement

  }

  public void testSwitchStatementWithDefault() throws Exception {
    TranslationUnit unit = parse("void foo() { switch (a) { case 1: break; default: break; } }");
    FunctionDefinition functionFoo = unit.getChild(0);
    SwitchStatement switchStatement = functionFoo.getChild(0);
    CaseStatement caseStatement = switchStatement.getChild(0);
    BreakStatement breakStatement = caseStatement.getChild(0);
    assertNotNull(breakStatement);
    DefaultStatement defaultStatement = switchStatement.getChild(1);
    breakStatement = defaultStatement.getChild(0);
    assertNotNull(breakStatement);
  }
View Full Code Here

Examples of org.allspice.structured.statement.SwitchStatement

public class TestSwitch extends MyTestCase {
  public static interface SwitchTest {
    public int meth(int arg0) ;
  }
  public void test1() throws Exception {
    SwitchTest obj = makeObject(SwitchTest.class,new SwitchStatement(ARG0,
        new FIFO<Statement>(
        new CaseStatement(new ConstExpr(Integer.valueOf(1),null),null),
        new ReturnStatement(new ConstExpr(Integer.valueOf(2),null),null),
        new CaseStatement(new ConstExpr(Integer.valueOf(0),null),null),
        new ReturnStatement(new ConstExpr(Integer.valueOf(0),null),null),
View Full Code Here
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.