more edits
[cdsspec-compiler.git] / grammer / pre_scanner.jj
1 /* pre_scan.jj Process the backslash at the end of line */
2
3 options {
4         STATIC = false;
5         JAVA_UNICODE_ESCAPE = true;
6 }
7
8 PARSER_BEGIN(PreScanner)
9 package edu.uci.eecs.specCompiler.grammerParser.preScanner;
10
11 import java.io.FileInputStream;
12 import java.io.FileNotFoundException;
13 import java.io.InputStream;
14 import java.io.ByteArrayInputStream;
15 import java.util.ArrayList;
16
17         public class PreScanner {
18                 public static void main(String[] argvs)
19                 throws ParseException, TokenMgrError {
20                         try {
21                                 FileInputStream fis = new FileInputStream("./grammer/spec.txt");
22                                 PreScanner preScanner = new PreScanner(fis);
23                                 String code = preScanner.ProcessEndBackslash();
24                                 System.out.println(code);
25                                 System.out.println("Finished!");
26                         } catch (FileNotFoundException e) {
27                                 e.printStackTrace();
28                         }
29                 }
30         }
31 PARSER_END(PreScanner)
32
33 SKIP : {
34         <"\\\n">
35 }
36
37 TOKEN : {
38         <ANY: ~[]>
39 }
40
41 String ProcessEndBackslash() :
42 {
43         StringBuilder sb;
44         String str;
45 }
46 {
47         { sb = new StringBuilder(); }
48         (str = <ANY>.image { sb.append(str); } )* <EOF>
49         {
50                 return sb.toString();
51         }
52 }