summaryrefslogtreecommitdiff
path: root/crenshaw
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2018-08-18 16:50:52 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2018-08-18 16:50:52 +0200
commitf6f9348fff5ca2e4ddcdfa3e6fc4da12ba213700 (patch)
treecdbe13c5cae3a523cfdc758aaf666ed377c1d2fb /crenshaw
parent5820deb5559dac39b7da8b18e4ef2e5838f41b66 (diff)
downloadcompilertests-f6f9348fff5ca2e4ddcdfa3e6fc4da12ba213700.tar.gz
compilertests-f6f9348fff5ca2e4ddcdfa3e6fc4da12ba213700.tar.bz2
crenshaw: whitespaces
Diffstat (limited to 'crenshaw')
-rw-r--r--crenshaw/main.pas21
-rw-r--r--crenshaw/test.prog2
2 files changed, 20 insertions, 3 deletions
diff --git a/crenshaw/main.pas b/crenshaw/main.pas
index fc1224b..294d5a9 100644
--- a/crenshaw/main.pas
+++ b/crenshaw/main.pas
@@ -17,6 +17,17 @@ begin
Read(Look);
end;
+function IsWhite(c: char): boolean;
+begin
+ IsWhite := c in [' ', TAB];
+end;
+
+procedure SkipWhite;
+begin
+ while IsWhite(Look) do
+ GetChar;
+end;
+
procedure Abort(s : string);
begin
Error(s);
@@ -30,8 +41,11 @@ end;
procedure Match(c : char);
begin
- if c = Look then GetChar
- else Expected('''' + c + '''');
+ if c <> Look then Expected('''' + c + '''')
+ else begin
+ GetChar;
+ SkipWhite;
+ end
end;
function IsAlpha(c : char) : boolean;
@@ -63,6 +77,7 @@ begin
while IsAlNum(Look) do begin
Token := Token + UpCase(Look);
GetChar;
+ SkipWhite;
end;
GetName := Token;
end;
@@ -76,6 +91,7 @@ begin
while IsDigit(Look) do begin
Value := Value + Look;
GetChar;
+ SkipWhite;
end;
GetNum := Value;
end;
@@ -234,6 +250,7 @@ procedure Init;
begin
nof_symbols := 0;
GetChar;
+ SkipWhite;
end;
procedure Prologue;
diff --git a/crenshaw/test.prog b/crenshaw/test.prog
index e19b072..21f6d3b 100644
--- a/crenshaw/test.prog
+++ b/crenshaw/test.prog
@@ -1 +1 @@
-x=(4+4+12)*3/2-3+a-b*func1()
+x = ( 4 + 4 + 12 ) * 3 / 2 - 3 + a - b * func1( )