#FEATURE by cg
authorClaus Gittinger <cg@exept.de>
Wed, 24 Aug 2016 14:51:25 +0200
changeset 3945 e462043d335b
parent 3943 50f01a3f66b1
child 3946 d6a5d4cc96e0
#FEATURE by cg class: ParserFlags class definition added: #allowSTXExtendedArrayLiterals #allowSTXExtendedArrayLiterals: comment/format in: #documentation
ParserFlags.st
--- a/ParserFlags.st	Mon Aug 22 15:43:30 2016 +0200
+++ b/ParserFlags.st	Wed Aug 24 14:51:25 2016 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 1989 by Claus Gittinger
  COPYRIGHT (c) 2005 by eXept Software AG
@@ -54,8 +56,8 @@
 		allowStringEscapes allowAssignmentToBlockArgument
 		allowAssignmentToMethodArgument allowAssignmentToPoolVariable
 		lineNumberInfo allowSTXDelimiterComments
-		warnAssignmentToBlockArgument warnAssignmentToMethodArgument
-		warnAssignmentToPoolVariable'
+		allowSTXExtendedArrayLiterals warnAssignmentToBlockArgument
+		warnAssignmentToMethodArgument warnAssignmentToPoolVariable'
 	classVariableNames:'WarnST80Directives WarnUnusedVars WarnUndeclared
 		WarnAboutWrongVariableNames WarnAboutBadComments
 		WarnAboutVariableNameConventions WarnSTXSpecials
@@ -95,9 +97,9 @@
 		LineNumberInfo LibDirectory VCTop SDKTop BCCTop MingwTop
 		ForcedCompiler DefineForBorlandC DefineForVisualC DefineForMSC
 		DefineForGNUC PerMethodFlags AllowSTXDelimiterComments
-		DefineForMINGW32 DefineForMINGW64 DefineForMINGW DefineForCLANG
-		WarnAssignmentToBlockArgument WarnAssignmentToPoolVariable
-		WarnAssignmentToMethodArgument'
+		AllowSTXExtendedArrayLiterals DefineForMINGW32 DefineForMINGW64
+		DefineForMINGW DefineForCLANG WarnAssignmentToBlockArgument
+		WarnAssignmentToPoolVariable WarnAssignmentToMethodArgument'
 	poolDictionaries:''
 	category:'System-Compiler'
 !
@@ -124,13 +126,15 @@
     compiler flags (used to be defined in Scanner and Parser) have been extracted for easier
     individual-method customization (using ST as scripting).
 
+    The class side provides correspondingly-named variables, which hold the default values.
+
     howTo_fileInVSE:
-	ParserFlags allowSTVExtensions:true.
-	ParserFlags allowSTVPrimitives:true.
-	ParserFlags allowSTXEOLComments:false.
+        ParserFlags allowSTVExtensions:true.
+        ParserFlags allowSTVPrimitives:true.
+        ParserFlags allowSTXEOLComments:false.
 
     for stx debugging:
-	STCKeepCIntermediate := true
+        STCKeepCIntermediate := true
 
 "
 ! !
@@ -1027,6 +1031,19 @@
     "
 !
 
+allowSTXExtendedArrayLiterals
+    ^ AllowSTXExtendedArrayLiterals ? false
+!
+
+allowSTXExtendedArrayLiterals:aBoolean
+    AllowSTXExtendedArrayLiterals := aBoolean.
+
+    "
+     self allowSTXExtendedArrayLiterals:true
+     self allowSTXExtendedArrayLiterals:false
+    "
+!
+
 allowSqueakExtensions
     "return true, if support for squeak extensions
 	computed arrays { .., }
@@ -1587,22 +1604,22 @@
     DefineForMINGW := '__MINGW__'.
     DefineForMINGW32 := '__MINGW32__'.
     DefineForMINGW64 := '__MINGW64__'.
-    DefineForCLANG := '__clang__'.
+    DefineForCLANG := '__CLANG__'.
 
     (executablePath := OperatingSystem pathOfSTXExecutable) notNil ifTrue:[
-        executablePath := executablePath asFilename directory.
-        (((executablePath / 'include') exists and:[(executablePath / 'stc') exists])
-          or:[
-            executablePath := executablePath directory.
-            ((executablePath / 'include') exists and:[(executablePath / 'stc') exists])
-              or:[
-                executablePath := executablePath directory.
-                ((executablePath / 'include') exists and:[(executablePath / 'stc') exists])
-              ]
-           ]
-        ) ifTrue:[
-            self initializeSTCFlagsForTopDirectory: executablePath.
-        ]
+	executablePath := executablePath asFilename directory.
+	(((executablePath / 'include') exists and:[(executablePath / 'stc') exists])
+	  or:[
+	    executablePath := executablePath directory.
+	    ((executablePath / 'include') exists and:[(executablePath / 'stc') exists])
+	      or:[
+		executablePath := executablePath directory.
+		((executablePath / 'include') exists and:[(executablePath / 'stc') exists])
+	      ]
+	   ]
+	) ifTrue:[
+	    self initializeSTCFlagsForTopDirectory: executablePath.
+	]
     ].
 
     "
@@ -1619,199 +1636,199 @@
      visualC setup still fails."
 
     |topDir topDirName vcTop sdkTop bccTop mingwTop
-     borlandDir useBorlandC useVisualC useMingw32 useMingw64 
+     borlandDir useBorlandC useVisualC useMingw32 useMingw64
      programFiles archArg picArg|
 
     topDir := topDirArg.
     OperatingSystem isMSWINDOWSlike ifTrue:[
-        topDirArg isString ifTrue:[
-            topDir := topDirArg copyReplaceAll:$/ with:$\ ifNone:topDirArg.
-        ]
+	topDirArg isString ifTrue:[
+	    topDir := topDirArg copyReplaceAll:$/ with:$\ ifNone:topDirArg.
+	]
     ].
     topDir := topDir asFilename.
     topDirName := topDir name.
 
     "/ if in the development directory, use ./modules
     Smalltalk isSmalltalkDevelopmentSystem ifTrue:[
-        STCModulePath := 'modules'.
+	STCModulePath := 'modules'.
     ] ifFalse:[
-        STCModulePath := Filename tempDirectory constructString:'modules'.
+	STCModulePath := Filename tempDirectory constructString:'modules'.
     ].
 
     (topDir construct:'stc') exists ifFalse:[
-        ('ParserFlags [warning]: stc not found in "',topDirName,'"') infoPrintCR.
-        'ParserFlags [warning]: stc-compiling (primitive code) will not work in the browser' infoPrintCR.
-        STCCompilation := #never.
+	('ParserFlags [warning]: stc not found in "',topDirName,'"') infoPrintCR.
+	'ParserFlags [warning]: stc-compiling (primitive code) will not work in the browser' infoPrintCR.
+	STCCompilation := #never.
     ].
 
     OperatingSystem isMSWINDOWSlike ifTrue:[
-        useBorlandC := useVisualC := useMingw32 := useMingw64 := false.
-        programFiles := OperatingSystem getEnvironment:'ProgramFiles'.
-        programFiles isEmptyOrNil ifTrue:[ programFiles := 'C:\Program Files' ].
-
-        STCCompilationIncludes := '-I',topDirName,'\include -I',topDirName,'\libopengl'.
-
-        ExternalAddress pointerSize == 4 ifFalse:[
-            bccTop := nil
-        ] ifTrue:[    
-            (bccTop := BCCTop) isNil ifTrue:[
-                borlandDir := OperatingSystem getEnvironment:'BCCDIR'.
-                borlandDir isEmptyOrNil ifTrue:[ borlandDir := 'C:\Borland\bcc55' ].
-                bccTop := {
-                            (borlandDir) .
-                            (programFiles , '\Borland\bcc55') .
-                            (programFiles , '\bcc55') .
-                          } detect:[:path | path asFilename exists and:[(path asFilename construct:'include') exists]]
-                             ifNone:nil.
-            ].
-        ].
-
-        STCCompilationDefines := '-DWIN32'.
-
-        (bccTop notNil and:[bccTop asFilename exists]) ifTrue:[
-            STCCompilationIncludes := STCCompilationIncludes,' -I',bccTop,'\Include'.
-            LibDirectory := topDirName,'\lib\bc'.
-            LinkArgs := '-L',topDirName,'\lib\bc'.
-            LinkArgs := LinkArgs,' -L',bccTop,'\Lib -r -c -ap -Tpd -Gi -w-dup'.
-            CCPath := 'bcc32'.
-            MakeCommand := 'bmake'.
-            LinkCommand := 'ilink32'.
-            CCCompilationOptions := '-w-'.
-            useBorlandC := true.
-        ] ifFalse:[
-            ExternalAddress pointerSize == 4 ifFalse:[
-                vcTop := nil.
-            ] ifTrue:[
-                (vcTop := VCTop) isNil ifTrue:[
-                    vcTop := {
-                                (programFiles,'\Microsoft Visual Studio 13.0\VC') .
-                                (programFiles,'\Microsoft Visual Studio 12.0\VC') .
-                                (programFiles,'\Microsoft Visual Studio 11.0\VC') .
-                                (programFiles,'\Microsoft Visual Studio 10.0\VC') .
-                                (programFiles,'\Microsoft Visual Studio 9.0\VC' ) .
-                             } detect:[:path | path asFilename exists and:[(path asFilename construct:'bin/cl.exe') exists]]
-                               ifNone:nil.
-                ].
-            ].
-            (vcTop notNil and:[vcTop asFilename exists]) ifTrue:[
-                useVisualC := true.
-                STCCompilationIncludes := STCCompilationIncludes,' -I',vcTop,'include'.
-
-                (sdkTop := SDKTop) isNil ifTrue:[
-                    sdkTop := {
-                                (programFiles,'\Microsoft SDKs\Windows\v9.0A') .
-                                (programFiles,'\Microsoft SDKs\Windows\v8.0A') .
-                                (programFiles,'\Microsoft SDKs\Windows\v8.0A') .
-                                (programFiles,'\Microsoft SDKs\Windows\v7.0A') .
-                                (programFiles,'\Microsoft SDKs\Windows\v6.0A') .
-                             }  detect:[:path | path asFilename exists and:[(path asFilename construct:'include') exists]] ifNone:nil.
-                ].
-                (sdkTop notNil and:[sdkTop asFilename exists]) ifTrue:[
-                    STCCompilationIncludes := STCCompilationIncludes,' -I',sdkTop,'\include'.
-                ].
-                LibDirectory := topDirName,'\lib\vc'.
-                LinkArgs := '-L',topDirName,'\lib\vc'.
-                LinkArgs := LinkArgs,' -r -c -ap -Tpd -Gi -w-dup'.
-                CCPath := vcTop,'\bin\cl.exe'.
-                LinkCommand := 'ilink32'.
-                MakeCommand := 'vcmake'.
-                CCCompilationOptions := '/nologo /ZI  /w /GF /EHsc /FR.\objvc\'.
-            ] ifFalse:[
-                "/ add definitions for lcc, mingc etc.
-                "/ STCCompilationIncludes := STCCompilationIncludes,' -IC:\xxxxx\Include'.
-                ExternalAddress pointerSize == 4 ifTrue:[
-                    (mingwTop := MingwTop) isNil ifTrue:[
-                        mingwTop := {
-                                    (programFiles,'\mingw') .
-                                    (programFiles,'\mingw') .
-                                    ('c:\mingw32') .
-                                    ('c:\mingw') .
-                                 } detect:[:path | path asFilename exists and:[(path asFilename construct:'bin/gcc.exe') exists]]
-                                   ifNone:nil.
-                    ].
-                    (mingwTop notNil and:[mingwTop asFilename exists]) ifTrue:[
-                        useMingw32 := true.
-                        STCCompilationDefines := STCCompilationDefines,' -D__MINGW32__'.
-                        CCCompilationOptions := '-w32'.
-                    ].
-                ] ifFalse:[
-                    (mingwTop := MingwTop) isNil ifTrue:[
-                        mingwTop := {
-                                    (programFiles,'\mingw64') .
-                                    (programFiles,'\mingw') .
-                                    ('c:\mingw64') .
-                                    ('c:\mingw') .
-                                 } detect:[:path | path asFilename exists and:[(path asFilename construct:'bin/gcc.exe') exists]]
-                                   ifNone:nil.
-                    ].
-                    (mingwTop notNil and:[mingwTop asFilename exists]) ifTrue:[
-                        STCCompilationDefines := STCCompilationDefines,' -D__MINGW64__'.
-                        "/ CCCompilationOptions := '-w64'.
-                    ].
-                ].    
-                (mingwTop notNil and:[mingwTop asFilename exists]) ifTrue:[
-                    STCCompilationDefines := STCCompilationDefines,' -D__MINGW__'.
-                    CCPath := mingwTop,'\bin\gcc.exe'.
-                    LinkCommand := 'gcc'.
-                    MakeCommand := 'mingwmake'.
-                    LibDirectory := topDirName,'\lib\mingw'.
-                    LinkArgs := '-L',topDirName,'\lib\mingw'.
-                    "/ LinkArgs := LinkArgs,' -r -c -ap -Tpd -Gi -w-dup'.
-                ].
-            ].
-        ].
-        STCCompilationOptions := '+optinline +inlineNew'.
-        (topDirName,'\stc\stc.exe') asFilename exists ifTrue:[
-            STCPath := (topDirName,'\stc\stc.exe').
-        ] ifFalse:[
-            STCPath := 'stc.exe'.
-        ].
-        LibPath := ''.
-        SearchedLibraries := #('import32.lib').
-        "/ SearchedLibraries := #('import32.lib' 'glu32.lib' 'opengl32.lib').
+	useBorlandC := useVisualC := useMingw32 := useMingw64 := false.
+	programFiles := OperatingSystem getEnvironment:'ProgramFiles'.
+	programFiles isEmptyOrNil ifTrue:[ programFiles := 'C:\Program Files' ].
+
+	STCCompilationIncludes := '-I',topDirName,'\include -I',topDirName,'\libopengl'.
+
+	ExternalAddress pointerSize == 4 ifFalse:[
+	    bccTop := nil
+	] ifTrue:[
+	    (bccTop := BCCTop) isNil ifTrue:[
+		borlandDir := OperatingSystem getEnvironment:'BCCDIR'.
+		borlandDir isEmptyOrNil ifTrue:[ borlandDir := 'C:\Borland\bcc55' ].
+		bccTop := {
+			    (borlandDir) .
+			    (programFiles , '\Borland\bcc55') .
+			    (programFiles , '\bcc55') .
+			  } detect:[:path | path asFilename exists and:[(path asFilename construct:'include') exists]]
+			     ifNone:nil.
+	    ].
+	].
+
+	STCCompilationDefines := '-DWIN32'.
+
+	(bccTop notNil and:[bccTop asFilename exists]) ifTrue:[
+	    STCCompilationIncludes := STCCompilationIncludes,' -I',bccTop,'\Include'.
+	    LibDirectory := topDirName,'\lib\bc'.
+	    LinkArgs := '-L',topDirName,'\lib\bc'.
+	    LinkArgs := LinkArgs,' -L',bccTop,'\Lib -r -c -ap -Tpd -Gi -w-dup'.
+	    CCPath := 'bcc32'.
+	    MakeCommand := 'bmake'.
+	    LinkCommand := 'ilink32'.
+	    CCCompilationOptions := '-w-'.
+	    useBorlandC := true.
+	] ifFalse:[
+	    ExternalAddress pointerSize == 4 ifFalse:[
+		vcTop := nil.
+	    ] ifTrue:[
+		(vcTop := VCTop) isNil ifTrue:[
+		    vcTop := {
+				(programFiles,'\Microsoft Visual Studio 13.0\VC') .
+				(programFiles,'\Microsoft Visual Studio 12.0\VC') .
+				(programFiles,'\Microsoft Visual Studio 11.0\VC') .
+				(programFiles,'\Microsoft Visual Studio 10.0\VC') .
+				(programFiles,'\Microsoft Visual Studio 9.0\VC' ) .
+			     } detect:[:path | path asFilename exists and:[(path asFilename construct:'bin/cl.exe') exists]]
+			       ifNone:nil.
+		].
+	    ].
+	    (vcTop notNil and:[vcTop asFilename exists]) ifTrue:[
+		useVisualC := true.
+		STCCompilationIncludes := STCCompilationIncludes,' -I',vcTop,'include'.
+
+		(sdkTop := SDKTop) isNil ifTrue:[
+		    sdkTop := {
+				(programFiles,'\Microsoft SDKs\Windows\v9.0A') .
+				(programFiles,'\Microsoft SDKs\Windows\v8.0A') .
+				(programFiles,'\Microsoft SDKs\Windows\v8.0A') .
+				(programFiles,'\Microsoft SDKs\Windows\v7.0A') .
+				(programFiles,'\Microsoft SDKs\Windows\v6.0A') .
+			     }  detect:[:path | path asFilename exists and:[(path asFilename construct:'include') exists]] ifNone:nil.
+		].
+		(sdkTop notNil and:[sdkTop asFilename exists]) ifTrue:[
+		    STCCompilationIncludes := STCCompilationIncludes,' -I',sdkTop,'\include'.
+		].
+		LibDirectory := topDirName,'\lib\vc'.
+		LinkArgs := '-L',topDirName,'\lib\vc'.
+		LinkArgs := LinkArgs,' -r -c -ap -Tpd -Gi -w-dup'.
+		CCPath := vcTop,'\bin\cl.exe'.
+		LinkCommand := 'ilink32'.
+		MakeCommand := 'vcmake'.
+		CCCompilationOptions := '/nologo /ZI  /w /GF /EHsc /FR.\objvc\'.
+	    ] ifFalse:[
+		"/ add definitions for lcc, mingc etc.
+		"/ STCCompilationIncludes := STCCompilationIncludes,' -IC:\xxxxx\Include'.
+		ExternalAddress pointerSize == 4 ifTrue:[
+		    (mingwTop := MingwTop) isNil ifTrue:[
+			mingwTop := {
+				    (programFiles,'\mingw') .
+				    (programFiles,'\mingw') .
+				    ('c:\mingw32') .
+				    ('c:\mingw') .
+				 } detect:[:path | path asFilename exists and:[(path asFilename construct:'bin/gcc.exe') exists]]
+				   ifNone:nil.
+		    ].
+		    (mingwTop notNil and:[mingwTop asFilename exists]) ifTrue:[
+			useMingw32 := true.
+			STCCompilationDefines := STCCompilationDefines,' -D__MINGW32__'.
+			CCCompilationOptions := '-w32'.
+		    ].
+		] ifFalse:[
+		    (mingwTop := MingwTop) isNil ifTrue:[
+			mingwTop := {
+				    (programFiles,'\mingw64') .
+				    (programFiles,'\mingw') .
+				    ('c:\mingw64') .
+				    ('c:\mingw') .
+				 } detect:[:path | path asFilename exists and:[(path asFilename construct:'bin/gcc.exe') exists]]
+				   ifNone:nil.
+		    ].
+		    (mingwTop notNil and:[mingwTop asFilename exists]) ifTrue:[
+			STCCompilationDefines := STCCompilationDefines,' -D__MINGW64__'.
+			"/ CCCompilationOptions := '-w64'.
+		    ].
+		].
+		(mingwTop notNil and:[mingwTop asFilename exists]) ifTrue:[
+		    STCCompilationDefines := STCCompilationDefines,' -D__MINGW__'.
+		    CCPath := mingwTop,'\bin\gcc.exe'.
+		    LinkCommand := 'gcc'.
+		    MakeCommand := 'mingwmake'.
+		    LibDirectory := topDirName,'\lib\mingw'.
+		    LinkArgs := '-L',topDirName,'\lib\mingw'.
+		    "/ LinkArgs := LinkArgs,' -r -c -ap -Tpd -Gi -w-dup'.
+		].
+	    ].
+	].
+	STCCompilationOptions := '+optinline +inlineNew'.
+	(topDirName,'\stc\stc.exe') asFilename exists ifTrue:[
+	    STCPath := (topDirName,'\stc\stc.exe').
+	] ifFalse:[
+	    STCPath := 'stc.exe'.
+	].
+	LibPath := ''.
+	SearchedLibraries := #('import32.lib').
+	"/ SearchedLibraries := #('import32.lib' 'glu32.lib' 'opengl32.lib').
     ] ifFalse:[
-        STCCompilationIncludes := '-I',topDirName,'/include'.
-        STCCompilationDefines := ''.
-        STCCompilationOptions := '+optinline +inlineNew'.
-        STCPath := topDirName,'/stc/stc'.
-
-        archArg := picArg := ''.
-        (ExternalAddress pointerSize == 4) ifTrue:[
-            archArg := ' -m32'
-        ] ifFalse:[
-            archArg := ' -m64'.            "gcc -m64 needs -fPIC to make a shared library"
-            picArg := ' -fPIC'.
-        ].
-        CCCompilationOptions := OperatingSystem getCPUDefine,
-                                ' -D', self usedCompilerDefine,
-                                ' ', OperatingSystem getOSDefine,
-                                ' ', '-O', archArg, picArg.
-        ParserFlags useClang ifTrue:[
-            CCPath := 'clang'
-        ] ifFalse:[
-            ParserFlags useGnuC ifTrue:[
-                CCPath := 'gcc'
-            ] ifFalse:[
-                CCPath := 'cc'
-            ].
-        ].
-        LinkArgs := archArg.
-        LinkSharedArgs := '-shared'.
-        LinkCommand := CCPath.
-        LibPath := ''.
-        SearchedLibraries := #().
-        MakeCommand := 'make'.
+	STCCompilationIncludes := '-I',topDirName,'/include'.
+	STCCompilationDefines := ''.
+	STCCompilationOptions := '+optinline +inlineNew'.
+	STCPath := topDirName,'/stc/stc'.
+
+	archArg := picArg := ''.
+	(ExternalAddress pointerSize == 4) ifTrue:[
+	    archArg := ' -m32'
+	] ifFalse:[
+	    archArg := ' -m64'.            "gcc -m64 needs -fPIC to make a shared library"
+	    picArg := ' -fPIC'.
+	].
+	CCCompilationOptions := OperatingSystem getCPUDefine,
+				' -D', self usedCompilerDefine,
+				' ', OperatingSystem getOSDefine,
+				' ', '-O', archArg, picArg.
+	ParserFlags useClang ifTrue:[
+	    CCPath := 'clang'
+	] ifFalse:[
+	    ParserFlags useGnuC ifTrue:[
+		CCPath := 'gcc'
+	    ] ifFalse:[
+		CCPath := 'cc'
+	    ].
+	].
+	LinkArgs := archArg.
+	LinkSharedArgs := '-shared'.
+	LinkCommand := CCPath.
+	LibPath := ''.
+	SearchedLibraries := #().
+	MakeCommand := 'make'.
     ].
 
     Smalltalk infoPrinting ifTrue:[
-        'ParserFlags [info]:' infoPrintCR.
-        '  STC Setup:' infoPrintCR.
-        ('    STCCompilationDefines: ',STCCompilationDefines asString) infoPrintCR.
-        ('    CCPath: ',CCPath asString) infoPrintCR.
-        ('    CCCompilationOptions: ',CCCompilationOptions asString) infoPrintCR.
-        ('    LinkCommand: ',LinkCommand asString) infoPrintCR.
-        ('    MakeCommand: ',MakeCommand asString) infoPrintCR.
-        ('    LinkArgs: ',LinkArgs asString) infoPrintCR.
+	'ParserFlags [info]:' infoPrintCR.
+	'  STC Setup:' infoPrintCR.
+	('    STCCompilationDefines: ',STCCompilationDefines asString) infoPrintCR.
+	('    CCPath: ',CCPath asString) infoPrintCR.
+	('    CCCompilationOptions: ',CCCompilationOptions asString) infoPrintCR.
+	('    LinkCommand: ',LinkCommand asString) infoPrintCR.
+	('    MakeCommand: ',MakeCommand asString) infoPrintCR.
+	('    LinkArgs: ',LinkArgs asString) infoPrintCR.
     ].
 
     "
@@ -2257,6 +2274,14 @@
     "
 !
 
+allowSTXExtendedArrayLiterals
+    ^ allowSTXExtendedArrayLiterals ? false
+!
+
+allowSTXExtendedArrayLiterals:aBoolean
+    allowSTXExtendedArrayLiterals := aBoolean
+!
+
 allowSTXFunctions
     ^ false