浏览代码

Require Strict or SuperStrict in source files. Closes #405.

woollybah 6 年之前
父节点
当前提交
0cad7fec68
共有 2 个文件被更改,包括 30 次插入16 次删除
  1. 1 1
      options.bmx
  2. 29 15
      parser.bmx

+ 1 - 1
options.bmx

@@ -25,7 +25,7 @@ SuperStrict
 
 Import "base.configmap.bmx"
 
-Const version:String = "0.108"
+Const version:String = "0.109"
 
 Const BUILDTYPE_APP:Int = 0
 Const BUILDTYPE_MODULE:Int = 1

+ 29 - 15
parser.bmx

@@ -3955,6 +3955,35 @@ End Rem
 
 		Local attrs:Int
 
+		While _toke
+			SetErr
+			Select _toke.ToLower()
+			Case "~n"
+				NextToke
+			Case "strict"
+				If _module.attrs & (MODULE_STRICT | MODULE_SUPERSTRICT) Then
+					Err "Strict or SuperStrict already specified"
+				End If
+
+				_module.attrs :| MODULE_STRICT
+				nextToke
+			Case "superstrict"
+				If _module.attrs & (MODULE_STRICT | MODULE_SUPERSTRICT) Then
+					Err "Strict or SuperStrict already specified"
+				End If
+
+				_module.attrs :| MODULE_SUPERSTRICT
+				opt_issuperstrict = True
+				NextToke
+			Default
+				Exit
+			End Select
+		Wend
+
+		If Not (_module.attrs & (MODULE_STRICT | MODULE_SUPERSTRICT)) Then
+			Err "Strict or SuperStrict must be declared at the start of the file."
+		End If
+
 		'Parse header - imports etc.
 		While _toke
 			SetErr
@@ -4017,21 +4046,6 @@ End Rem
 				mainFunc.attrs :| DECL_NODEBUG
 				attrs :| DECL_NODEBUG
 				NextToke
-			Case "strict"
-				If _module.attrs & (MODULE_STRICT | MODULE_SUPERSTRICT) Then
-					Err "Strict or SuperStrict already specified"
-				End If
-
-				_module.attrs :| MODULE_STRICT
-				nextToke
-			Case "superstrict"
-				If _module.attrs & (MODULE_STRICT | MODULE_SUPERSTRICT) Then
-					Err "Strict or SuperStrict already specified"
-				End If
-
-				_module.attrs :| MODULE_SUPERSTRICT
-				opt_issuperstrict = True
-				nextToke
 			Case "moduleinfo"
 				NextToke
 				Local info:String = ParseStringLit()