Skip to content

Commit

Permalink
Declaration: be clairvoyant with literal objects & collections
Browse files Browse the repository at this point in the history
  • Loading branch information
vdelachaux committed Jul 4, 2023
1 parent 17a8547 commit 4ebda88
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 28 deletions.
Binary file modified Build/Components/4DPop Macros.4dbase/4DPop Macros.4DZ
Binary file not shown.
8 changes: 4 additions & 4 deletions Build/Components/4DPop Macros.4dbase/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
<key>CFBundleName</key>
<string>4DPop Macros</string>
<key>CFBundleVersion</key>
<string>258</string>
<string>259</string>
<key>NSHumanReadableCopyright</key>
<string>©vdl 2009-2023</string>
<key>CFBundleGetInfoString</key>
<string>20R3</string>
<string>20R2</string>
<key>CFBundleLongVersionString</key>
<string>20R3 (257)</string>
<string>20R2 (258)</string>
<key>CFBundleShortVersionString</key>
<string>20R3</string>
<string>20R2</string>
<key>CFBundleDisplayName</key>
<string>4DPop Macros</string>
</dict>
Expand Down
Binary file modified Build/Components/4DPop Macros.4dbase/Libraries/lib4d-arm64.dylib
Binary file not shown.
Binary file modified Build/Components/4DPop Macros.4dbase/Resources/InfoPlist.strings
Binary file not shown.
Binary file modified Build/Components/4DPop Macros.dmg
Binary file not shown.
8 changes: 4 additions & 4 deletions Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
<key>CFBundleName</key>
<string>4DPop Macros</string>
<key>CFBundleVersion</key>
<string>258</string>
<string>259</string>
<key>NSHumanReadableCopyright</key>
<string>©vdl 2009-2023</string>
<key>CFBundleGetInfoString</key>
<string>20R3</string>
<string>20R2</string>
<key>CFBundleLongVersionString</key>
<string>20R3 (257)</string>
<string>20R2 (258)</string>
<key>CFBundleShortVersionString</key>
<string>20R3</string>
<string>20R2</string>
<key>CFBundleDisplayName</key>
<string>4DPop Macros</string>
</dict>
Expand Down
53 changes: 34 additions & 19 deletions Project/Sources/Classes/declaration.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -1317,13 +1317,28 @@ Function addNewLine($text : Text)->$result : Text
End if

//==============================================================
Function clairvoyant($text : Text; $line : Text)->$varType : Integer
Function clairvoyant($text : Text; $line : Text) : Integer

var $pattern; $t; $type : Text
var $indx : Integer
var $indx; $varType : Integer

ARRAY LONGINT:C221($pos; 0)
ARRAY LONGINT:C221($len; 0)
ARRAY LONGINT:C221($pos; 0)

Case of

//______________________________________________________
: (Match regex:C1019("(?mi-s).*:=\\{"; $line; 1; *)) // Object literal

return (Is object:K8:27)

//______________________________________________________
: (Match regex:C1019("(?mi-s).*:=\\["; $line; 1; *)) // Collection literal

return (Is collection:K8:32)

//______________________________________________________
End case

$t:=Replace string:C233(Replace string:C233($text; "{"; "\\{"); "}"; "\\}")

Expand All @@ -1332,19 +1347,19 @@ Function clairvoyant($text : Text; $line : Text)->$varType : Integer
//______________________________________________________
: (Match regex:C1019("(?m-si)(\\$\\w*):=((?:cs|4d)\\.\\w*)\\.new\\([^)]*\\)(?!\\.)"; $line; 1; $pos; $len)) // Class

$varType:=Is object:K8:27

// Keep class definition
This:C1470.classes.push(New object:C1471(\
"value"; Substring:C12($line; \
$pos{1}; $len{1}); \
"class"; Substring:C12($line; $pos{2}; $len{2})))

return (Is object:K8:27)

//______________________________________________________
: (Match regex:C1019("(?m-si)\\"+$t+":=\"[^\"]*\""\
+"|"+Command name:C538(16)+"\\(\\"+$t+"\\)"; $line; 1)) // Length

$varType:=Is text:K8:3
return (Is text:K8:3)

//______________________________________________________
: (Match regex:C1019("(?mi-s)\\"+$t+"[:><]?[=><]?\\d+[."+This:C1470.decimalSeparator+"]\\d+"; $line; 1))\
Expand All @@ -1353,7 +1368,7 @@ Function clairvoyant($text : Text; $line : Text)->$varType : Integer
| (Match regex:C1019(":=\\s*"+Parse formula:C1576(":K30:3"); $line; 1))\
| (Match regex:C1019(":=\\s*"+Parse formula:C1576(":K30:4"); $line; 1))

$varType:=Is real:K8:4
return (Is real:K8:4)

//______________________________________________________
: (Match regex:C1019("(?m-si)\\"+$t+"[:><]?[=><]?\\d+"; $line; 1))\
Expand All @@ -1362,44 +1377,44 @@ Function clairvoyant($text : Text; $line : Text)->$varType : Integer
| (Match regex:C1019(":=\\s*"+Parse formula:C1576(":K35:2"); $line; 1))\
| (Match regex:C1019(":=\\s*"+Parse formula:C1576(":K35:3"); $line; 1))

$varType:=Is longint:K8:6
return (Is longint:K8:6)

//______________________________________________________
: (Match regex:C1019("(?m-si)\\"+$t+":=(?:"+Command name:C538(214)+"|"+Command name:C538(215)+")(?=$|\\(|(?:\\s*//)|(?:\\s*/\\*))"; $line; 1))

$varType:=Is boolean:K8:9
return (Is boolean:K8:9)

//______________________________________________________
: (Match regex:C1019("(?m-si)\\"+$t+"\\."; $line; 1))\
| (Match regex:C1019("(?m-si):="+Parse formula:C1576("Form:C1466")+"[^.]"; $line; 1))

$varType:=Is object:K8:27
return (Is object:K8:27)

//______________________________________________________
: (Match regex:C1019("(?m-si)\\"+$t+":=(?:!\\d+-\\d+-\\d+!)"; $line; 1))

$varType:=Is date:K8:7
return (Is date:K8:7)

//______________________________________________________
: (Match regex:C1019("(?m-si)\\"+$t+":=(?:\\?\\d+:\\d+:\\d+\\?)"; $line; 1))

$varType:=Is time:K8:8
return (Is time:K8:8)

//______________________________________________________
: (Match regex:C1019("(?mi-s)\\"+$t+":=->"; $line; 1))\
| (Match regex:C1019("(?mi-s)\\"+$t+"->"; $line; 1))

$varType:=Is pointer:K8:14
return (Is pointer:K8:14)

//______________________________________________________
: (Match regex:C1019("(?m-si)(?:For|Boucle)\\s\\((?:[^;]*;\\s*){0,3}(\\"+$t+")"; $line; 1))

$varType:=Is longint:K8:6
return (Is longint:K8:6)

//______________________________________________________
: (Match regex:C1019("(?m-si)(?:If|Si|Not|Non)\\s*\\(\\"+$t+"\\)"; $line; 1))

$varType:=Is boolean:K8:9
return (Is boolean:K8:9)

//______________________________________________________

Expand All @@ -1411,22 +1426,22 @@ Function clairvoyant($text : Text; $line : Text)->$varType : Integer

If ($indx>0)

For each ($pattern; This:C1470.gramSyntax[$type]) While ($varType=0)
For each ($pattern; This:C1470.gramSyntax[$type])

If (Match regex:C1019(Replace string:C233($pattern; "%"; $t); $line; 1))

$varType:=Num:C11(Substring:C12($type; 1; $indx-1))
return Num:C11(Substring:C12($type; 1; $indx-1))

End if
End for each

Else

For each ($pattern; This:C1470.gramSyntax[$type]) While ($varType=0)
For each ($pattern; This:C1470.gramSyntax[$type])

If (Match regex:C1019(Replace string:C233($pattern; "%"; $t)+"(?=$|\\(|(?:\\s*//)|(?:\\s*/\\*))"+")"; $line; 1))

$varType:=Num:C11($type)
return Num:C11($type)

End if
End for each
Expand Down
Binary file modified Resources/InfoPlist.strings
Binary file not shown.
2 changes: 1 addition & 1 deletion lastbuild
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20R3
20R2

0 comments on commit 4ebda88

Please sign in to comment.