Example usage for org.eclipse.jdt.internal.compiler.util Messages parser_moveFiles

List of usage examples for org.eclipse.jdt.internal.compiler.util Messages parser_moveFiles

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.util Messages parser_moveFiles.

Prototype

String parser_moveFiles

To view the source code for org.eclipse.jdt.internal.compiler.util Messages parser_moveFiles.

Click Source Link

Usage

From source file:org.eclipse.jdt.internal.compiler.parser.Parser.java

License:Open Source License

public final static void buildFilesFromLPG(String dataFilename, String dataFilename2) {

    //RUN THIS METHOD TO GENERATE PARSER*.RSC FILES

    //build from the lpg javadcl.java files that represents the parser tables
    //lhs check_table asb asr symbol_index

    //[org.eclipse.jdt.internal.compiler.parser.Parser.buildFilesFromLPG("d:/leapfrog/grammar/javadcl.java")]
    char[] contents = CharOperation.NO_CHAR;
    try {/* w w w.  j a  v a2 s  .  co m*/
        contents = Util.getFileCharContent(new File(dataFilename), null);
    } catch (IOException ex) {
        System.out.println(Messages.parser_incorrectPath);
        return;
    }
    java.util.StringTokenizer st = new java.util.StringTokenizer(new String(contents), " \t\n\r[]={,;"); //$NON-NLS-1$
    String[] tokens = new String[st.countTokens()];
    int j = 0;
    while (st.hasMoreTokens()) {
        tokens[j++] = st.nextToken();
    }
    final String prefix = FILEPREFIX;
    int i = 0;

    char[] newLhs = buildFileOfIntFor(prefix + (++i) + ".rsc", "lhs", tokens); //$NON-NLS-1$ //$NON-NLS-2$
    buildFileOfShortFor(prefix + (++i) + ".rsc", "check_table", tokens); //$NON-NLS-2$ //$NON-NLS-1$
    buildFileOfIntFor(prefix + (++i) + ".rsc", "asb", tokens); //$NON-NLS-2$ //$NON-NLS-1$
    buildFileOfIntFor(prefix + (++i) + ".rsc", "asr", tokens); //$NON-NLS-2$ //$NON-NLS-1$
    buildFileOfIntFor(prefix + (++i) + ".rsc", "nasb", tokens); //$NON-NLS-2$ //$NON-NLS-1$
    buildFileOfIntFor(prefix + (++i) + ".rsc", "nasr", tokens); //$NON-NLS-2$ //$NON-NLS-1$
    char[] newTerminalIndex = buildFileOfIntFor(prefix + (++i) + ".rsc", "terminal_index", tokens); //$NON-NLS-2$ //$NON-NLS-1$
    char[] newNonTerminalIndex = buildFileOfIntFor(prefix + (++i) + ".rsc", "non_terminal_index", tokens); //$NON-NLS-1$ //$NON-NLS-2$
    buildFileOfIntFor(prefix + (++i) + ".rsc", "term_action", tokens); //$NON-NLS-2$ //$NON-NLS-1$

    buildFileOfIntFor(prefix + (++i) + ".rsc", "scope_prefix", tokens); //$NON-NLS-2$ //$NON-NLS-1$
    buildFileOfIntFor(prefix + (++i) + ".rsc", "scope_suffix", tokens); //$NON-NLS-2$ //$NON-NLS-1$
    buildFileOfIntFor(prefix + (++i) + ".rsc", "scope_lhs", tokens); //$NON-NLS-2$ //$NON-NLS-1$
    buildFileOfIntFor(prefix + (++i) + ".rsc", "scope_state_set", tokens); //$NON-NLS-2$ //$NON-NLS-1$
    buildFileOfIntFor(prefix + (++i) + ".rsc", "scope_rhs", tokens); //$NON-NLS-2$ //$NON-NLS-1$
    buildFileOfIntFor(prefix + (++i) + ".rsc", "scope_state", tokens); //$NON-NLS-2$ //$NON-NLS-1$
    buildFileOfIntFor(prefix + (++i) + ".rsc", "in_symb", tokens); //$NON-NLS-2$ //$NON-NLS-1$

    byte[] newRhs = buildFileOfByteFor(prefix + (++i) + ".rsc", "rhs", tokens); //$NON-NLS-2$ //$NON-NLS-1$
    buildFileOfByteFor(prefix + (++i) + ".rsc", "term_check", tokens); //$NON-NLS-2$ //$NON-NLS-1$
    buildFileOfByteFor(prefix + (++i) + ".rsc", "scope_la", tokens); //$NON-NLS-2$ //$NON-NLS-1$

    String[] newName = buildFileForName(prefix + (++i) + ".rsc", new String(contents)); //$NON-NLS-1$

    contents = CharOperation.NO_CHAR;
    try {
        contents = Util.getFileCharContent(new File(dataFilename2), null);
    } catch (IOException ex) {
        System.out.println(Messages.parser_incorrectPath);
        return;
    }
    st = new java.util.StringTokenizer(new String(contents), "\t\n\r#"); //$NON-NLS-1$
    tokens = new String[st.countTokens()];
    j = 0;
    while (st.hasMoreTokens()) {
        tokens[j++] = st.nextToken();
    }

    buildFileForCompliance(prefix + (++i) + ".rsc", newRhs.length, tokens);//$NON-NLS-1$
    buildFileForReadableName(READABLE_NAMES_FILE + ".properties", newLhs, newNonTerminalIndex, newName, tokens);//$NON-NLS-1$

    buildFilesForRecoveryTemplates(prefix + (++i) + ".rsc", //$NON-NLS-1$
            prefix + (++i) + ".rsc", //$NON-NLS-1$
            newTerminalIndex, newNonTerminalIndex, newName, newLhs, tokens);

    buildFilesForStatementsRecoveryFilter(prefix + (++i) + ".rsc", //$NON-NLS-1$
            newNonTerminalIndex, newLhs, tokens);

    System.out.println(Messages.parser_moveFiles);
}