Changeset 3005


Ignore:
Timestamp:
Apr 8, 2013, 10:43:54 AM (6 years ago)
Author:
bhull
Message:

Regular Expression Changes

Location:
proto/RE
Files:
80 added
3 edited

Legend:

Unmodified
Added
Removed
  • proto/RE/input/test/test1.re

    r2346 r3005  
    1 [a] | [b] | [c] | [d]
     1( (a b) * c) +
  • proto/RE/src/applications/PrintCode.java

    r2360 r3005  
    55import java.io.FileInputStream;
    66
     7import java.io.File;
    78import java.io.IOException;
    89import java.io.InputStream;
     
    2728    public static void main(String[] args) throws IOException {
    2829        //checkArguments(args, "PrintCode");
     30        //printCode(args[0], args[1], System.out);
     31       PrintStream pablo = new PrintStream(new File("output/re_pablo.py"));
     32       printCode(args[0], args[1]+"/re_pablo", pablo, false);
     33       pablo.close();
     34       PrintStream debug = new PrintStream(new File("output/re_debug.py"));
     35       printCode(args[0], args[1]+"/re_debug", debug, true);
     36       debug.close();
     37       PrintStream cc_input = new PrintStream(new File("output/ccinput"));
     38       printCode(args[0], args[1]+"/ccinput", cc_input, false);
     39       cc_input.close();
    2940       
    30         printCode(args[0], args[1], System.out);
    3141    }
    3242   
     
    3545     * @throws IOException
    3646     */
    37     public static void printCode(String filename, String templateFilename, PrintStream out) throws IOException {
     47    public static void printCode(String filename, String templateFilename, PrintStream out, Boolean debug) throws IOException {
    3848        //This is quick and dirty debug code.  Should probably not be used long term.
    3949       
     
    5262        for(int i = 0; i<visitor.characterClassVariableGenerator.position; i++) {
    5363                String varName = visitor.characterClassVariableGenerator.prefix+i;
    54                 debugCode = debugCode + ",\r\n\t('      "+varName+"', bitutil.bitstream2string("+varName+", lgth+1))";
    55         lexStreams = lexStreams +"\r\n  "+varName+" = (0)";
     64                debugCode = debugCode + ",\n\t('        "+varName+"', bitutil.bitstream2string("+varName+", lgth+1))";
     65        lexStreams = lexStreams +"\n    "+varName+" = (0)";
    5666        }
    5767        String clearCursors = "";
    5868        for(int i = 0; i<visitor.cursorGenerator.position; i++) {
    5969                String varName = visitor.cursorGenerator.prefix+i;
    60                 debugCode = debugCode + ",\r\n\t('      "+varName+"', bitutil.bitstream2string("+varName+", lgth+1))";                 
    61                 clearCursors = clearCursors + "\t"+varName+"=0\r\n";
     70                debugCode = debugCode + ",\n\t('        "+varName+"', bitutil.bitstream2string("+varName+", lgth+1))";                 
     71                clearCursors = clearCursors + "\t"+varName+"=0\n";
    6272        }
    6373        debugCode = debugCode + "])";
    6474        lexStreams=lexStreams.replace("lex.","");
    6575        CodeGenerator codeGenerator = new CodeGenerator(visitor.getNodeStates(),visitor.getCharacterClassVariables(), new PythonGenerator());
    66         template = template.replace("@pbs_code", clearCursors+"\tm0=~0\r\n@pbs_code");
     76        template = template.replace("@pbs_code", clearCursors+"\tm0=~0\n@pbs_code");
    6777        template = template.replace("@cc_input", CharacterClassOutputGenerator.generateCharacterClassOutput(visitor.getCharacterClassVariables()));
    6878        template = template.replace("@pbs_code",codeGenerator.generateCode(syntaxTree).toString());
    6979        template = template.replace("@pbs_debug", debugCode);
    7080        template = template.replace("@lex_strms",lexStreams);
    71         template = template.replace("pablo", "bitutil");
    72         System.out.println(template);
     81        if (debug) {
     82                template = template.replace("pablo", "bitutil");
     83        }
     84        //System.out.println(template);
     85        out.println(template);
    7386         
    7487    }
  • proto/RE/src/codeGenerator/PythonGenerator.java

    r2360 r3005  
    22
    33public class PythonGenerator implements OutputGenerator {
    4         private String lineBreak = "\r\n";
     4        private String lineBreak = "\n";
    55        @Override
    66        public Output makeAssignment(Output lhs, Output rhs) {
Note: See TracChangeset for help on using the changeset viewer.