mirror of
https://github.com/2003scape/deep-c-rsc.git
synced 2024-03-22 05:49:51 -04:00
216 lines
6.9 KiB
Diff
216 lines
6.9 KiB
Diff
diff -ruN jcgo-generated-by-jcoco115/ErrorStream.java jcgo-modified/ErrorStream.java
|
|
--- jcgo-generated-by-jcoco115/ErrorStream.java 2009-12-29 12:01:36.000000000 +0300
|
|
+++ jcgo-modified/ErrorStream.java 2009-12-29 12:02:46.000000000 +0300
|
|
@@ -1,4 +1,4 @@
|
|
-package comivmaisoftjcgo;
|
|
+package com.ivmaisoft.jcgo;
|
|
|
|
public class ErrorStream {
|
|
|
|
diff -ruN jcgo-generated-by-jcoco115/Parser.java jcgo-modified/Parser.java
|
|
--- jcgo-generated-by-jcoco115/Parser.java 2009-12-29 12:01:38.000000000 +0300
|
|
+++ jcgo-modified/Parser.java 2012-03-12 19:21:11.000000000 +0400
|
|
@@ -1,10 +1,7 @@
|
|
-package comivmaisoftjcgo;
|
|
-
|
|
-import java.util.*;
|
|
+package com.ivmaisoft.jcgo;
|
|
|
|
public class Parser {
|
|
private static final int maxT = 104;
|
|
- private static final int maxP = 104;
|
|
|
|
private static final boolean T = true;
|
|
private static final boolean x = false;
|
|
@@ -69,28 +66,6 @@
|
|
return set[s][t.kind];
|
|
}
|
|
|
|
- private static void ExpectWeak(int n, int follow) {
|
|
- if (t.kind == n) Get();
|
|
- else {
|
|
- Error(n);
|
|
- while (!StartOf(follow)) Get();
|
|
- }
|
|
- }
|
|
-
|
|
- private static boolean WeakSeparator(int n, int syFol, int repFol) {
|
|
- boolean[] s = new boolean[maxT+1];
|
|
- if (t.kind == n) {Get(); return true;}
|
|
- else if (StartOf(repFol)) return false;
|
|
- else {
|
|
- for (int i = 0; i <= maxT; i++) {
|
|
- s[i] = set[syFol][i] || set[repFol][i] || set[0][i];
|
|
- }
|
|
- Error(n);
|
|
- while (!s[t.kind]) Get();
|
|
- return StartOf(syFol);
|
|
- }
|
|
- }
|
|
-
|
|
private static Term UnaryWithIdentTailOrDimExprs(Term a) {
|
|
Term z;
|
|
z = Empty.term;
|
|
@@ -1847,7 +1822,7 @@
|
|
z = WhileStatement();
|
|
break;
|
|
}
|
|
- case 1: case 2: case 3: case 4: case 5: case 7: case 11: case 34: case 35: case 36: case 37: case 38: case 39: case 40: case 41: case 42: case 66: case 67: case 94: case 95: case 96: case 97: case 98: case 99: case 100: case 101: case 102: case 103: {
|
|
+ case 1: case 2: case 3: case 4: case 5: /* case 7: */ case 11: case 34: case 35: case 36: case 37: case 38: case 39: case 40: case 41: case 42: case 66: case 67: case 94: case 95: case 96: case 97: case 98: case 99: case 100: case 101: case 102: case 103: {
|
|
z = ExprOrLabeledStmntOrVarDecl();
|
|
break;
|
|
}
|
|
@@ -2638,12 +2613,11 @@
|
|
}
|
|
|
|
private static void Annotation() {
|
|
- Term b;
|
|
Expect(10);
|
|
- b = QualifiedIdentifier();
|
|
+ QualifiedIdentifier();
|
|
if (t.kind == 11) {
|
|
Get();
|
|
- b = QualifiedIdentifierOrString();
|
|
+ QualifiedIdentifierOrString();
|
|
Expect(12);
|
|
}
|
|
}
|
|
diff -ruN jcgo-generated-by-jcoco115/Scanner.java jcgo-modified/Scanner.java
|
|
--- jcgo-generated-by-jcoco115/Scanner.java 2009-12-29 12:01:40.000000000 +0300
|
|
+++ jcgo-modified/Scanner.java 2012-03-12 19:15:41.000000000 +0400
|
|
@@ -1,16 +1,16 @@
|
|
-package comivmaisoftjcgo;
|
|
+package com.ivmaisoft.jcgo;
|
|
|
|
import java.io.*;
|
|
import java.util.*;
|
|
|
|
-class Token {
|
|
+/* class Token {
|
|
int kind; // token kind
|
|
int pos; // token position in the source text (starting at 0)
|
|
int col; // token column (starting at 0)
|
|
int line; // token line (starting at 1)
|
|
String str; // exact string value
|
|
String val; // token string value (uppercase if ignoreCase)
|
|
-}
|
|
+} */
|
|
|
|
class Buffer {
|
|
|
|
@@ -36,22 +36,43 @@
|
|
// BufferedReader s = new BufferedReader(new FileReader(f), bufLen);
|
|
// buf = new char[bufLen]; // Java 1.1
|
|
|
|
- BufferedReader s = new BufferedReader(new FileReader(f), bufLen);
|
|
+ FileReader s = new FileReader(f);
|
|
buf = new char[bufLen]; // Java 1.1
|
|
|
|
int n = s.read(buf); pos = 0;
|
|
+ if (n > 0) { while (n < buf.length) {
|
|
+ int res = s.read(buf, n, buf.length - n);
|
|
+ if (res <= 0) break; else n += res; } }
|
|
+ s.close();
|
|
} catch (IOException e) {
|
|
System.out.println("--- cannot open file " + name);
|
|
+ if (bufLen >= 0) System.exit(1);
|
|
System.exit(0);
|
|
}
|
|
}
|
|
|
|
static void Set(int position) {
|
|
+ if (position > 0) { pos = prevPrevPos; return; }
|
|
if (position < 0) position = 0; else if (position >= bufLen) position = bufLen;
|
|
pos = position;
|
|
}
|
|
|
|
+ private static int prevPrevPos, prevPos;
|
|
+ private static boolean ignoreBackslash;
|
|
static int read() {
|
|
+ prevPrevPos = prevPos; prevPos = pos;
|
|
+ int c; if (pos == 0) ignoreBackslash = false;
|
|
+ if (!ignoreBackslash) { if (bufLen - 5 > pos && buf[pos] == '\\') {
|
|
+ if (buf[pos + 1] == 'u') { int k = 2;
|
|
+ while (buf[pos + k] == 'u' && bufLen - pos > k + 4) k++;
|
|
+ if (buf[pos + k] == '0' && buf[pos + k + 1] == '0' &&
|
|
+ buf[pos + k + 2] >= '0' && buf[pos + k + 2] <= '7' &&
|
|
+ (((c = buf[pos + k + 3]) >= '0' && c <= '9') ||
|
|
+ ((c -= 'A' - '0' - 10) >= '0' + 10 && c <= '0' + 0xf) ||
|
|
+ ((c -= 'a' - 'A') >= '0' + 10 && c <= '0' + 0xf)) &&
|
|
+ (c = ((buf[pos + k + 2] - '0') << 4) | (c - '0')) != 0 && (c != '\\' ||
|
|
+ bufLen - pos == k + 4 || buf[pos + k + 4] != 'u')) { pos += k + 4;
|
|
+ return c; } } ignoreBackslash = true; } } else ignoreBackslash = false;
|
|
if (pos < bufLen) return (int) buf[pos++]; else return eof;
|
|
}
|
|
}
|
|
@@ -104,6 +125,8 @@
|
|
strCh = (char) Buffer.read(); pos++;
|
|
ch = strCh;
|
|
if (ch == '\uffff') ch = EOF;
|
|
+ if (ch == '\t') lineStart += (pos - lineStart) % 8 - 7;
|
|
+ if (ch >= 0x7f && ch != 0xffff) { ch = 0x7f; return; }
|
|
else if (ch == CR) {line++; lineStart = pos + 1;}
|
|
else if (ch == LF) {
|
|
if (lastCh != CR) line++;
|
|
@@ -115,7 +138,7 @@
|
|
}
|
|
|
|
private static boolean Comment0() {
|
|
- int level = 1, line0 = line, lineStart0 = lineStart; char startCh;
|
|
+ int level = 1;
|
|
NextCh();
|
|
if (ch == '*') {
|
|
NextCh();
|
|
@@ -131,17 +154,18 @@
|
|
else NextCh();
|
|
}
|
|
} else {
|
|
- if (ch == CR || ch == LF) {line--; lineStart = lineStart0;}
|
|
+ if (ch == CR || ch == LF) {line--;}
|
|
pos = pos - 2; Buffer.Set(pos+1); NextCh();
|
|
}
|
|
return false;
|
|
}
|
|
private static boolean Comment1() {
|
|
- int level = 1, line0 = line, lineStart0 = lineStart; char startCh;
|
|
+ int level = 1;
|
|
NextCh();
|
|
if (ch == '/') {
|
|
NextCh();
|
|
for(;;) {
|
|
+ if (ch == 13) { NextCh(); return true; }
|
|
if (ch == 10) {
|
|
level--;
|
|
if (level == 0) {NextCh(); return true;}
|
|
@@ -150,7 +174,7 @@
|
|
else NextCh();
|
|
}
|
|
} else {
|
|
- if (ch == CR || ch == LF) {line--; lineStart = lineStart0;}
|
|
+ if (ch == CR || ch == LF) {line--;}
|
|
pos = pos - 2; Buffer.Set(pos+1); NextCh();
|
|
}
|
|
return false;
|
|
@@ -250,7 +274,6 @@
|
|
t.pos = pos; t.col = pos - lineStart + 1; t.line = line;
|
|
StringBuffer buf = new StringBuffer();
|
|
int state = start[ch];
|
|
- int apx = 0;
|
|
loop: for (;;) {
|
|
buf.append(strCh);
|
|
NextCh();
|
|
diff -ruN jcgo-generated-by-jcoco115/Token.java jcgo-modified/Token.java
|
|
--- jcgo-generated-by-jcoco115/Token.java 1970-01-01 03:00:00.000000000 +0300
|
|
+++ jcgo-modified/Token.java 2009-12-29 12:13:14.000000000 +0300
|
|
@@ -0,0 +1,10 @@
|
|
+package com.ivmaisoft.jcgo;
|
|
+
|
|
+class Token {
|
|
+ int kind; // token kind
|
|
+ int pos; // token position in the source text (starting at 0)
|
|
+ int col; // token column (starting at 0)
|
|
+ int line; // token line (starting at 1)
|
|
+ String str; // exact string value
|
|
+ String val; // token string value (uppercase if ignoreCase)
|
|
+}
|