Browse Source

added support for lower case modules

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@6535 8c9fc860-2736-0410-a75d-ab315db34111
eth.guenter 9 years ago
parent
commit
142706e703
2 changed files with 199 additions and 21 deletions
  1. 12 7
      source/PrettyPrint.Mod
  2. 187 14
      source/PrettyPrintHighlighter.XML

+ 12 - 7
source/PrettyPrint.Mod

@@ -18,7 +18,7 @@ CONST
 	PPDir = "PPr";
 	PPDir = "PPr";
 
 
 VAR
 VAR
-	highlighter: SyntaxHighlighter.Highlighter;
+	highlighterU, highlighterL: SyntaxHighlighter.Highlighter;
 	out, err: Streams.Writer;
 	out, err: Streams.Writer;
 	
 	
 	PROCEDURE CheckSubDirectory( CONST dname: ARRAY OF CHAR ): BOOLEAN;
 	PROCEDURE CheckSubDirectory( CONST dname: ARRAY OF CHAR ): BOOLEAN;
@@ -40,17 +40,20 @@ VAR
 	
 	
 	PROCEDURE Convert*( context: Commands.Context );	(*  {filename} ~ *)
 	PROCEDURE Convert*( context: Commands.Context );	(*  {filename} ~ *)
 	VAR 
 	VAR 
-		filename, dest: ARRAY 64 OF CHAR;  format, res: LONGINT;
+		filename, dest: ARRAY 64 OF CHAR;  format, l, res: LONGINT;
 		f: Files.File;  text: Texts.Text;
 		f: Files.File;  text: Texts.Text;
+		highlighter: SyntaxHighlighter.Highlighter;
 	BEGIN
 	BEGIN
 		out := context.out;  err := context.error;
 		out := context.out;  err := context.error;
 		
 		
 		out.String( "PrettyPrint.Convert" ); out.Ln;
 		out.String( "PrettyPrint.Convert" ); out.Ln;
 		IF ~CheckSubDirectory( PPDir ) THEN  Files.CreateDirectory( PPDir, res )  END;
 		IF ~CheckSubDirectory( PPDir ) THEN  Files.CreateDirectory( PPDir, res )  END;
-		IF highlighter = NIL THEN  LoadHighlighter  END;
-		IF highlighter # NIL THEN
+		IF highlighterU = NIL THEN  LoadHighlighter  END;
+		IF highlighterU # NIL THEN
 			WHILE context.arg.GetString( filename ) DO
 			WHILE context.arg.GetString( filename ) DO
 				out.String( "    " );  out.String( filename );  
 				out.String( "    " );  out.String( filename );  
+				l := Strings.Length( filename );
+				IF filename[l-3] = 'm' THEN  highlighter := highlighterL  ELSE  highlighter := highlighterU END;
 				f := Files.Old( filename );
 				f := Files.Old( filename );
 				IF f = NIL THEN
 				IF f = NIL THEN
 					err.String( " : file not found" ); err.Ln;  
 					err.String( " : file not found" ); err.Ln;  
@@ -74,18 +77,20 @@ VAR
 	VAR res: LONGINT; msg: ARRAY 128 OF CHAR;
 	VAR res: LONGINT; msg: ARRAY 128 OF CHAR;
 	BEGIN 
 	BEGIN 
 		Commands.Call( "SyntaxHighlighter.Open PrettyPrintHighlighter.XML", {}, res, msg );
 		Commands.Call( "SyntaxHighlighter.Open PrettyPrintHighlighter.XML", {}, res, msg );
-		highlighter := SyntaxHighlighter.GetHighlighter( "PrintOberon" );
+		highlighterU := SyntaxHighlighter.GetHighlighter( "PrintOberon" );
+		highlighterL := SyntaxHighlighter.GetHighlighter( "printoberon" );
 		Commands.Call( "SyntaxHighlighter.Open SyntaxHighlighter.XML", {}, res, msg );
 		Commands.Call( "SyntaxHighlighter.Open SyntaxHighlighter.XML", {}, res, msg );
 	END LoadHighlighter;
 	END LoadHighlighter;
 
 
 BEGIN
 BEGIN
-	highlighter := NIL
+	highlighterU := NIL;
+	highlighterL := NIL
 END PrettyPrint.
 END PrettyPrint.
 
 
 
 
 	SystemTools.Free PrettyPrint ~
 	SystemTools.Free PrettyPrint ~
 	
 	
-	PrettyPrint.Convert  PrettyPrint.Mod  Xyz.Mod ~
+	PrettyPrint.Convert  PrettyPrint.Mod  Huffman.mod Xyz.Mod ~
 
 
 
 
 
 

+ 187 - 14
source/PrettyPrintHighlighter.XML

@@ -38,31 +38,40 @@
 	<Styles>
 	<Styles>
 		<Style name="Default"/>
 		<Style name="Default"/>
 		<Style name="Bold" fontsize="8" fontstyle="{0}" color="7090FFFF"/>
 		<Style name="Bold" fontsize="8" fontstyle="{0}" color="7090FFFF"/>
+		<Style name="KeyWords" fontsize="8" fontstyle="{0}" color="7090FFFF"/>
+		<Style name="KeyWordsL" fontstyle="{0}" color="7090FFFF"/>
 		<Style name="Italic" fontstyle="{1}"/>
 		<Style name="Italic" fontstyle="{1}"/>
 		<Style name="Red" fontsize="8" fontstyle="{0}" color="FF0000FF"/>
 		<Style name="Red" fontsize="8" fontstyle="{0}" color="FF0000FF"/>
 		<Style name="Blue" fontsize="8" fontstyle="{0}" color="0000FFFF"/>
 		<Style name="Blue" fontsize="8" fontstyle="{0}" color="0000FFFF"/>
 		<Style name="Green" fontsize="8" fontstyle="{0}" color="009000FF"/>
 		<Style name="Green" fontsize="8" fontstyle="{0}" color="009000FF"/>
 		<Style name="Comment" color="808080FF"/>
 		<Style name="Comment" color="808080FF"/>
+		<Style name="Punctuation"  color="707070FF"/>
 		<Style name="ToDo" fontsize="8" fontstyle="{0}" color = "FF0000FF"/>
 		<Style name="ToDo" fontsize="8" fontstyle="{0}" color = "FF0000FF"/>
 		<Style name="CommentItalic" fontstyle="{1}" color="808080FF"/>
 		<Style name="CommentItalic" fontstyle="{1}" color="808080FF"/>
 		<Style name="Control" fontstyle="{0}" color="FFFF"/>
 		<Style name="Control" fontstyle="{0}" color="FFFF"/>
 		<Style name="Modifiers" color="A000FF"/>
 		<Style name="Modifiers" color="A000FF"/>
 		<Style name="Locking" color="FF00FFFF"/>
 		<Style name="Locking" color="FF00FFFF"/>
 		<Style name="Checks" fontsize="8" fontstyle="{0}" color="0000FFFF"/>
 		<Style name="Checks" fontsize="8" fontstyle="{0}" color="0000FFFF"/>
+		<Style name="ChecksL" fontstyle="{0}" color="0000FFFF"/>
 		<Style name="Threads" color="FF00FFFF"/>
 		<Style name="Threads" color="FF00FFFF"/>
+		<Style name="ThreadsL" fontstyle="{0}" color="FF00FFFF"/>
 		<Style name="Structure" fontsize="8" fontstyle="{0}" color="7090FFFF"/>
 		<Style name="Structure" fontsize="8" fontstyle="{0}" color="7090FFFF"/>
 		<Style name="Operators" color="D02020FF"/>
 		<Style name="Operators" color="D02020FF"/>
 		<Style name="OperatorKW" fontsize="8" fontstyle="{0}" color="CF5F5FFF"/>
 		<Style name="OperatorKW" fontsize="8" fontstyle="{0}" color="CF5F5FFF"/>
+		<Style name="OperatorKWL" fontstyle="{0}" color="E07070FF"/>
 		<Style name="Values" color="158080FF"/>
 		<Style name="Values" color="158080FF"/>
 		<Style name="ValueNames" fontsize="8" fontstyle="{0}" color="159898FF"/>
 		<Style name="ValueNames" fontsize="8" fontstyle="{0}" color="159898FF"/>
+		<Style name="ValueNamesL" fontstyle="{0}" color="1088A8FF"/>
 		<Style name="BasicTypes" fontsize="8" fontstyle="{0}" color="7F8FAFFF"/>
 		<Style name="BasicTypes" fontsize="8" fontstyle="{0}" color="7F8FAFFF"/>
+		<Style name="BasicTypesL" fontstyle="{0}" color="7080A0FF"/>
 		<Style name="ComplexTypes" fontstyle="{0}" color="FFFF"/>
 		<Style name="ComplexTypes" fontstyle="{0}" color="FFFF"/>
 		<Style name="Dangerous" fontsize="8" fontstyle="{0}" color="FF0000FF"/>
 		<Style name="Dangerous" fontsize="8" fontstyle="{0}" color="FF0000FF"/>
+		<Style name="DangerousL" fontstyle="{0}" color="FF0000FF"/>
 		<Style name="Debug" color="FFFF"/>
 		<Style name="Debug" color="FFFF"/>
 		<Style name="String" color="7F002FFF"/>
 		<Style name="String" color="7F002FFF"/>
 		<Style name="Error" bgcolor="FF0000FF"/>
 		<Style name="Error" bgcolor="FF0000FF"/>
 		<Style name="StdProc" fontsize="8" fontstyle="{0}" color="00A0C0FF"/>
 		<Style name="StdProc" fontsize="8" fontstyle="{0}" color="00A0C0FF"/>
-		<Style name="LinkerSpecial" color="C06000FF"/>
+		<Style name="StdProcL" fontstyle="{0}" color="00A0B0FF"/>
 	</Styles>
 	</Styles>
 
 
 	<Highlighters>
 	<Highlighters>
@@ -81,27 +90,27 @@
 			</Tokens>
 			</Tokens>
 
 
 			<Words allowCharacters="._" numberStyle="Values">
 			<Words allowCharacters="._" numberStyle="Values">
-				<Group style="Bold">
+				<Group style="KeyWords">
 					FOR TO WHILE DO REPEAT UNTIL IF THEN ELSE ELSIF
 					FOR TO WHILE DO REPEAT UNTIL IF THEN ELSE ELSIF
 					LOOP CASE BY
 					LOOP CASE BY
 					BEGIN END CODE FINALLY
 					BEGIN END CODE FINALLY
 					OF WITH
 					OF WITH
 				</Group>
 				</Group>
-				<Group style="Green">
+				<Group style="KeyWords">
 					RETURN EXIT
 					RETURN EXIT
 				</Group>
 				</Group>
-				<Group style="Bold">
+				<Group style="KeyWords">
 					VAR CONST
 					VAR CONST
 					ARRAY POINTER
 					ARRAY POINTER
 				</Group>
 				</Group>
-				<Group style="Bold">
-					NEW SELF DISPOSE
+				<Group style="KeyWords">
+					DISPOSE
 				</Group>
 				</Group>
 				<Group style="OperatorKW">
 				<Group style="OperatorKW">
 					DIV MOD IN IS OR
 					DIV MOD IN IS OR
 				</Group>
 				</Group>
 				<Group style="StdProc">
 				<Group style="StdProc">
-					ABS ASH CAP CHR ORD
+					ABS ASH CAP CHR ORD NEW CAS
 					COPY GETPROCEDURE LEN
 					COPY GETPROCEDURE LEN
 					MAX MIN ODD ADDRESSOF SIZEOF SHORT LONG ENTIER ENTIERH
 					MAX MIN ODD ADDRESSOF SIZEOF SHORT LONG ENTIER ENTIERH
 					RE IM
 					RE IM
@@ -112,7 +121,7 @@
 					OUT
 					OUT
 				</Group>
 				</Group>
 				<Group style="Modifiers">
 				<Group style="Modifiers">
-					DELEGATE
+					DELEGATE REALTIME UNCHECKED UNCOOPERATIVE DISPOSABLE ALIGNED
 				</Group>
 				</Group>
 				<Group style="Locking">
 				<Group style="Locking">
 					KernelLog.Enter
 					KernelLog.Enter
@@ -125,21 +134,18 @@
 					*.AcquireWrite *.ReleaseWrite
 					*.AcquireWrite *.ReleaseWrite
 					mtxLock mtxUnlock conWait conSignal
 					mtxLock mtxUnlock conWait conSignal
 				</Group>
 				</Group>
-				<Group style="LinkerSpecial">
-					Heaps.Relocate
-				</Group>
 				<Group style="Checks">
 				<Group style="Checks">
 					ASSERT
 					ASSERT
 				</Group>
 				</Group>
 				<Group style="Threads">
 				<Group style="Threads">
 					ACTIVE SHARED PRIORITY AWAIT EXCLUSIVE
 					ACTIVE SHARED PRIORITY AWAIT EXCLUSIVE
 				</Group>
 				</Group>
-				<Group style="Bold">
+				<Group style="KeyWords">
 					MODULE IMPORT TYPE DEFINITION REFINES IMPLEMENTS PROCEDURE OPERATOR
 					MODULE IMPORT TYPE DEFINITION REFINES IMPLEMENTS PROCEDURE OPERATOR
 					OBJECT RECORD
 					OBJECT RECORD
 				</Group>
 				</Group>
 				<Group style="ValueNames">
 				<Group style="ValueNames">
-					NIL TRUE FALSE IMAG
+					NIL TRUE FALSE IMAG SELF
 				</Group>
 				</Group>
 				<Group style="BasicTypes">
 				<Group style="BasicTypes">
 					BOOLEAN
 					BOOLEAN
@@ -236,6 +242,173 @@
 
 
 		</Highlighter>
 		</Highlighter>
 
 
+		<Highlighter name="printoberon" defaultstyle="Default">
+			<Tokens>
+				<Group style="Error">
+					*)
+				</Group>
+				<Group style="Operators">
+					= := * + - /
+					&lt; &lt;= &gt;= &gt; &amp; ~ #
+				</Group>
+				<Group style="Comment">
+					; : ,
+				</Group>
+			</Tokens>
+
+			<Words allowCharacters="._" numberStyle="Values">
+				<Group style="KeyWordsL">
+					for to while do repeat until if then else elsif
+					loop case by
+					begin end code finally
+					of with
+				</Group>
+				<Group style="KeyWordsL">
+					return exit
+				</Group>
+				<Group style="KeyWordsL">
+					var const
+					array pointer
+				</Group>
+				<Group style="KeyWordsL">
+					new self dispose
+				</Group>
+				<Group style="OperatorKWL">
+					div mod in is or
+				</Group>
+				<Group style="StdProcL">
+					abs ash cap chr ord cas
+					copy getprocedure len
+					max min odd addressof sizeof short long entier entierh
+					re im
+					lsh rot incr
+					first last step
+					incl excl inc dec
+					send receive
+					out
+				</Group>
+				<Group style="Modifiers">
+					DELEGATE REALTIME DISPOSABLE ALIGNED
+				</Group>
+				<Group style="Locking">
+					KernelLog.Enter
+					KernelLog.Exit
+					Acquire Release
+					*.Acquire *.Release
+					AcquireRead ReleaseRead
+					AcquireWrite ReleaseWrite
+					*.AcquireRead 	*.ReleaseRead
+					*.AcquireWrite *.ReleaseWrite
+					mtxLock mtxUnlock conWait conSignal
+				</Group>
+				<Group style="ChecksL">
+					assert
+				</Group>
+				<Group style="Threads">
+					ACTIVE SHARED PRIORITY EXCLUSIVE
+				</Group>
+				<Group style="ThreadsL">
+					await 
+				</Group>
+				<Group style="KeyWordsL">
+					module import type definition refines implements procedure operator
+					object record
+				</Group>
+				<Group style="ValueNamesL">
+					nil true false imag
+				</Group>
+				<Group style="BasicTypesL">
+					boolean
+					shortint integer longint hugeint
+					real longreal					
+					complex longcomplex
+					set
+					char
+					any
+					range
+					address size
+				</Group>
+				<Group style="Dangerous">
+					UNTRACED UNSAVE UNCHECKED UNCOOPERATIVE
+				</Group>
+				<Group style="DangerousL">
+					system.get system.get8 system.get16 system.get32 system.get64
+					system.sizeof system.typeof
+					system.put system.put8 system.put16 system.put32 system.put64
+					system.val
+					system.adr
+					system.move
+					system.portin system.portput
+					system.cli system.sti
+					system
+					system.byte
+					system.bit system.msk
+					system.fp system.setfp
+					system.sp system.setsp
+					system.lnk system.setlnk
+					system.pc system.setpc
+					system.ldpsr system.stpsr
+					system.ldcpr system.stcpr
+					system.flush
+					system.null
+					system.xor
+					system.muld
+					system.addc
+					system.pack system.unpk		
+					system.typecode		
+					halt
+				</Group>
+				<Group style="Debug">
+					KernelLog
+					KernelLog.Send
+					KernelLog.String KernelLog.Ln
+					KernelLog.Char KernelLog.Int KernelLog.Boolean
+					KernelLog.IntSuffix KernelLog.Hex
+					KernelLog.Address KernelLog.HIntHex
+					KernelLog.Memory KernelLog.Buffer
+					KernelLog.Bits
+					KernelLog.OpenBuffer
+					KernelLog.CloseBuffer
+					Trace
+					Trace.Send
+					Trace.Ln Trace.String Trace.StringLn
+					Trace.Int Trace.Boolean Trace.IntSuffix
+					Trace.Hex Trace.Address
+					Trace.HIntHex
+					Trace.Memory Trace.Buffer Trace.Bits
+					Trace.Blue Trace.Green Trace.Red Trace.Yellow Trace.Default
+				</Group>
+			</Words>
+
+			<Regions>
+				<Region
+					style="Comment" styleOpen="Comment" styleClose="Comment"
+					open="(*" close="*)" nesting="TRUE" multiline="TRUE"
+				/>
+				<Region
+					style="ToDo" styleOpen="Comment" styleClose="Comment"
+					open="(*!" close="*)" nesting="TRUE" multiline="TRUE"
+				/>
+				<Region
+					style="Red" styleOpen="Comment" styleClose="Comment"
+					open="(*?" close="*)" nesting="TRUE" multiline="TRUE"
+				/>
+				<Region
+					style="Comment" styleOpen="CommentItalic" styleClose="CommentItalic"
+					open="(**" close="*)" nesting="TRUE" multiline="TRUE"
+				/>
+				<Region
+					style="String" styleOpen="Comment" styleClose="Comment"
+					open='"' close='"' nesting="FALSE" multiline="FALSE"
+				/>
+				<Region
+					style="String" styleOpen="Comment" styleClose="Comment"
+					open="'" close="'" nesting="FALSE" multiline="FALSE"
+				/>
+			</Regions>
+
+		</Highlighter>
+
 	
 	
 
 
 		<Highlighter name="Assembler">
 		<Highlighter name="Assembler">
@@ -254,4 +427,4 @@
 
 
 	</Highlighters>
 	</Highlighters>
 
 
-</SyntaxHighlighter>
+</SyntaxHighlighter>