예제 #1
0
  /**
   * Mark the current annotation. This method must be called before recognizing the nonterminals to
   * be annotated. Furthermore, it must be called within the context of a stateful production.
   */
  public void mark() {
    if (DEBUG) System.out.println("mark()");

    if (null == annotation) {
      top.mark = null;
    } else {
      top.mark = annotation.innerMost();
    }
  }
예제 #2
0
  /**
   * Record a pragma.
   *
   * @see Pragma
   * @param directive The actual directive.
   * @param location The pragma's source location.
   */
  public void pragma(String directive, Location location) {
    if (DEBUG) System.out.println("pragma(" + directive + ")");

    Pragma pragma = new Pragma(directive, null);
    pragma.setLocation(location);
    if (null == annotation) {
      annotation = pragma;
    } else {
      annotation.innerMost().setNode(pragma);
    }
  }
예제 #3
0
  /**
   * Record an ident directive.
   *
   * @see SourceIdentity
   * @param ident The actual identity marker.
   * @param location The ident directive's source location.
   */
  public void ident(String ident, Location location) {
    if (DEBUG) System.out.println("ident(" + ident + ")");

    SourceIdentity identity = new SourceIdentity(ident, null);
    identity.setLocation(location);
    if (null == annotation) {
      annotation = identity;
    } else {
      annotation.innerMost().setNode(identity);
    }
  }
예제 #4
0
  /**
   * Record a line marker. Note that string values for the four flags are interpreted as follows:
   * Any non-null string counts for <code>true</code>, while null counts for <code>false</code>.
   *
   * @see LineMarker
   * @param file The file name (without quotes).
   * @param line The line number.
   * @param isStartFile The start file flag.
   * @param isReturnToFile The return to file flag.
   * @param isSystemHeader The system header flag.
   * @param isExternC The extern C flag.
   * @param location The line marker's source location.
   */
  public void lineMarker(
      String file,
      int line,
      String isStartFile,
      String isReturnToFile,
      String isSystemHeader,
      String isExternC,
      Location location) {
    if (DEBUG) System.out.println("lineMarker(" + file + ": " + line + ")");

    int flags = 0;
    if (null != isStartFile) flags |= LineMarker.FLAG_START_FILE;
    if (null != isReturnToFile) flags |= LineMarker.FLAG_RETURN_TO_FILE;
    if (null != isSystemHeader) flags |= LineMarker.FLAG_SYSTEM_HEADER;
    if (null != isExternC) flags |= LineMarker.FLAG_EXTERN_C;

    LineMarker marker = new LineMarker(line, file, flags, null);
    marker.setLocation(location);
    if (null == annotation) {
      annotation = marker;
    } else {
      annotation.innerMost().setNode(marker);
    }
  }