Package org.eclipse.assemblyformatter.ir

Examples of org.eclipse.assemblyformatter.ir.Section


   * @return
   * @throws BadLocationException
   *
   */
  private Section identifyAnyLabel() throws BadLocationException {
    Section section = base;
    Symbol symbolSection = null;
    Section i = null; // section before symbol section

    int state = 1; // initial state must not be RESET

    while (section != null) {
      // final String content = section.getContent(document); // for
      // debugging
      Section nextSection = section.getNextSection();

      switch (state) {
      case RESET:
        // TODO: Two LINE_SEPARATOR sections case
        if (section instanceof LineSeparator) {
          i = section;
          state = 1;
        }/* else { // Stay in current state. } */
        break;
      case 1: // The initial state
        if (section instanceof LineSeparator) {
          break; // Stay in current state.
        }
        if (section instanceof Symbol) {
          symbolSection = (Symbol) section;
          state = 2;
        } else {
          if (section instanceof WhiteSpace) {
            i = section;
            state = 3;
          } else {
            state = RESET;
          }
        }
        break;
      case 2:
        if ((section instanceof WhiteSpace)
            || (section instanceof LineSeparator)) {
          state = MATCH;
        } else {
          if (section instanceof CharacterLiteral) {
            if (document.getChar(section.getOffset()) == ':') {
              state = MATCH;
            } else {
              state = RESET;
            }
          } else {
            state = RESET;
          }
        }
        break;
      case 3:
        if (section instanceof Symbol) {
          symbolSection = (Symbol) section;
          state = 4;
        } else {
          state = RESET;
        }
        break;
      case 4:
        if (section instanceof CharacterLiteral) {
          final char c = document.getChar(section.getOffset());
          if (c == ':') {
            state = MATCH;
          } else {
            state = RESET;
          }
        } else {
          state = RESET;
        }
        break;
      case MATCH:
        // NOP here
        // TODO Review
        break;
      default:
        state = RESET;
      }

      if (state == MATCH) {
        // Replace SYMBOL with LABEL.
        Section label = new Label();
        label.copyPosition(symbolSection);
        label.setNextSection(symbolSection.getNextSection());
        i.setNextSection(label);
        state = RESET;
      }

      section = nextSection;
View Full Code Here


   *
   * @return
   * @throws BadLocationException
   */
  private Section identifyAnyDirective() throws BadLocationException {
    Section section = base;
    Section prevSection = null;

    /**
     * false: Looking for SYMBOL. true: Looking for LINE_SEPARATOR.
     */
    boolean state = false;

    while (section != null) {
      Section nextSection = section.getNextSection();

      if (!state) {
        if (section instanceof Symbol) {
          String s = section.getContent(document);

          for (String i : Directive.IAR_LIST) {
            if (s.compareToIgnoreCase(i) == 0) {
              // Replace SYMBOL with DIRECTIVE.
              Section directiveSection = new Directive();
              directiveSection.copyPosition(section);
              directiveSection.setNextSection(nextSection);

              // Special link handling.
              if (prevSection != null) {
                prevSection.setNextSection(directiveSection);
              } else {
View Full Code Here

   *
   * @param base
   * @return
   */
  private Section identifyAnyInstruction() {
    Section section = base;

    while (section != null) {
      Section nextSection = section.getNextSection();

      if (section instanceof LineSeparator) {
        if (section.nextIs(WhiteSpace.class, Symbol.class)) {
          Symbol symbolSection = (Symbol) Section
              .getNextIs__staticData(1);
          // Replace SYMBOL with INSTRUCTION.
          Section instructionSection = new Instruction();
          instructionSection.copyPosition(symbolSection);
          instructionSection.setNextSection(symbolSection
              .getNextSection());
          nextSection.setNextSection(instructionSection);

          // Jump.
          nextSection = symbolSection.getNextSection();
View Full Code Here

   * TODO Review (parameter identification problem is difficult)
   *
   * @return
   */
  private Section identifyAnyParameter() {
    Section section = base;
    Section i = null, j = null;

    ParameterIdentificationState state = ParameterIdentificationState.INSTRUCTION;

    while (section != null) {
      Section nextSection = section.getNextSection();

      switch (state) {
      case INSTRUCTION:
        if (section instanceof Instruction) {
          state = ParameterIdentificationState.WHITE_SPACE;
View Full Code Here

TOP

Related Classes of org.eclipse.assemblyformatter.ir.Section

Copyright © 2018 www.massapicom. 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.