Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Memri
parsers
Commits
40678b65
Commit
40678b65
authored
4 years ago
by
Ruben Daniels
Browse files
Options
Download
Email Patches
Plain Diff
Parser ready for debugging
parent
aca3409c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
memri-parser.xcodeproj/project.pbxproj
+13
-11
memri-parser.xcodeproj/project.pbxproj
memri-parser.xcodeproj/project.xcworkspace/xcuserdata/rubendaniels.xcuserdatad/xcdebugger/Expressions.xcexplist
+38
-0
...rubendaniels.xcuserdatad/xcdebugger/Expressions.xcexplist
memri-parser.xcodeproj/xcuserdata/rubendaniels.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
+120
-40
...ndaniels.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
memri-parser/main.swift
+5
-3
memri-parser/main.swift
memri-parser/view-parser/color.extension.swift
+71
-0
memri-parser/view-parser/color.extension.swift
memri-parser/view-parser/example/example.view
+6
-6
memri-parser/view-parser/example/example.view
memri-parserTests/ExprParserTests.swift
+0
-1
memri-parserTests/ExprParserTests.swift
with
253 additions
and
61 deletions
+253
-61
memri-parser.xcodeproj/project.pbxproj
+
13
-
11
View file @
40678b65
...
...
@@ -15,9 +15,10 @@
864D0853246E63AD00A1ECF9
/* ExprParserTests.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
864D0852246E63AD00A1ECF9
/* ExprParserTests.swift */
;
};
8690AEE924702F3600FC49F4
/* Expression.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
8690AEE824702F3600FC49F4
/* Expression.swift */
;
};
8690AEEC24703C7600FC49F4
/* example.view in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
8690AEEB24703C7600FC49F4
/* example.view */
;
};
8690AF0F2472F8E500FC49F4
/* ViewLexer.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
8690AEF124705B3C00FC49F4
/* ViewLexer.swift */
;
};
8690AF102472F8E500FC49F4
/* ViewNodes.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
8690AEEF24705B3C00FC49F4
/* ViewNodes.swift */
;
};
8690AF112472F8E500FC49F4
/* ViewParser.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
8690AEF224705B3C00FC49F4
/* ViewParser.swift */
;
};
8690AF172473E8BC00FC49F4
/* ViewLexer.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
8690AEF124705B3C00FC49F4
/* ViewLexer.swift */
;
};
8690AF182473E8BC00FC49F4
/* ViewNodes.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
8690AEEF24705B3C00FC49F4
/* ViewNodes.swift */
;
};
8690AF192473E8BC00FC49F4
/* ViewParser.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
8690AEF224705B3C00FC49F4
/* ViewParser.swift */
;
};
8690AF1B24742EF100FC49F4
/* color.extension.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
8690AF1A24742EF100FC49F4
/* color.extension.swift */
;
};
86CDB71D246D100D007EAE67
/* ExprNodes.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
86CDB719246D100D007EAE67
/* ExprNodes.swift */
;
};
86CDB71E246D100D007EAE67
/* ExprParser.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
86CDB71A246D100D007EAE67
/* ExprParser.swift */
;
};
86CDB71F246D100D007EAE67
/* ExprLexer.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
86CDB71B246D100D007EAE67
/* ExprLexer.swift */
;
};
...
...
@@ -43,17 +44,17 @@
864D084A246E567400A1ECF9
/* Info.plist */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
text.plist.xml
;
path
=
Info.plist
;
sourceTree
=
"<group>"
;
};
864D0852246E63AD00A1ECF9
/* ExprParserTests.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ExprParserTests.swift
;
sourceTree
=
"<group>"
;
};
8690AEE824702F3600FC49F4
/* Expression.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Expression.swift
;
sourceTree
=
"<group>"
;
};
8690AEEB24703C7600FC49F4
/* example.view */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
archive.rsrc
;
path
=
example.view
;
sourceTree
=
"<group>"
;
wrapsLines
=
1
;
xcLanguageSpecificationIdentifier
=
xcode.lang.css
;
};
8690AEEE24705B3C00FC49F4
/* ViewInterpreter.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ViewInterpreter.swift
;
sourceTree
=
"<group>"
;
};
8690AEEB24703C7600FC49F4
/* example.view */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
archive.rsrc
;
path
=
example.view
;
sourceTree
=
"<group>"
;
wrapsLines
=
0
;
xcLanguageSpecificationIdentifier
=
xcode.lang.css
;
};
8690AEEF24705B3C00FC49F4
/* ViewNodes.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ViewNodes.swift
;
sourceTree
=
"<group>"
;
wrapsLines
=
0
;
};
8690AEF024705B3C00FC49F4
/* ViewDefinition.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ViewDefinition.swift
;
sourceTree
=
"<group>"
;
};
8690AEF124705B3C00FC49F4
/* ViewLexer.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ViewLexer.swift
;
sourceTree
=
"<group>"
;
};
8690AEF224705B3C00FC49F4
/* ViewParser.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ViewParser.swift
;
sourceTree
=
"<group>"
;
};
8690AEF224705B3C00FC49F4
/* ViewParser.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ViewParser.swift
;
sourceTree
=
"<group>"
;
wrapsLines
=
0
;
};
8690AF1A24742EF100FC49F4
/* color.extension.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
color.extension.swift
;
sourceTree
=
"<group>"
;
};
86CDB704246BC34C007EAE67
/* memri-parser */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
"compiled.mach-o.executable"
;
includeInIndex
=
0
;
path
=
"memri-parser"
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
86CDB719246D100D007EAE67
/* ExprNodes.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ExprNodes.swift
;
sourceTree
=
"<group>"
;
};
86CDB71A246D100D007EAE67
/* ExprParser.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ExprParser.swift
;
sourceTree
=
"<group>"
;
};
86CDB71B246D100D007EAE67
/* ExprLexer.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ExprLexer.swift
;
sourceTree
=
"<group>"
;
};
86CDB71C246D100D007EAE67
/* main.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
main.swift
;
sourceTree
=
"<group>"
;
wrapsLines
=
0
;
};
86CDB71C246D100D007EAE67
/* main.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
main.swift
;
sourceTree
=
"<group>"
;
wrapsLines
=
1
;
};
86CDB721246D1402007EAE67
/* ExprInterpreter.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ExprInterpreter.swift
;
sourceTree
=
"<group>"
;
};
/* End PBXFileReference section */
...
...
@@ -90,10 +91,10 @@
children
=
(
8690AEED24705B2700FC49F4
/* example */
,
8690AEF024705B3C00FC49F4
/* ViewDefinition.swift */
,
8690AEEE24705B3C00FC49F4
/* ViewInterpreter.swift */
,
8690AEF124705B3C00FC49F4
/* ViewLexer.swift */
,
8690AEEF24705B3C00FC49F4
/* ViewNodes.swift */
,
8690AEF224705B3C00FC49F4
/* ViewParser.swift */
,
8690AF1A24742EF100FC49F4
/* color.extension.swift */
,
);
path
=
"view-parser"
;
sourceTree
=
"<group>"
;
...
...
@@ -249,14 +250,15 @@
isa
=
PBXSourcesBuildPhase
;
buildActionMask
=
2147483647
;
files
=
(
8690AF0F2472F8E500FC49F4
/* ViewLexer.swift in Sources */
,
8690AF112472F8E500FC49F4
/* ViewParser.swift in Sources */
,
8690AF1B24742EF100FC49F4
/* color.extension.swift in Sources */
,
86CDB71E246D100D007EAE67
/* ExprParser.swift in Sources */
,
86CDB71F246D100D007EAE67
/* ExprLexer.swift in Sources */
,
8690AF182473E8BC00FC49F4
/* ViewNodes.swift in Sources */
,
86CDB722246D1402007EAE67
/* ExprInterpreter.swift in Sources */
,
8690AF102472F8E500FC49F4
/* ViewNodes.swift in Sources */
,
86CDB720246D100D007EAE67
/* main.swift in Sources */
,
86CDB71D246D100D007EAE67
/* ExprNodes.swift in Sources */
,
8690AF172473E8BC00FC49F4
/* ViewLexer.swift in Sources */
,
8690AF192473E8BC00FC49F4
/* ViewParser.swift in Sources */
,
8690AEEC24703C7600FC49F4
/* example.view in Sources */
,
8690AEE924702F3600FC49F4
/* Expression.swift in Sources */
,
);
...
...
This diff is collapsed.
Click to expand it.
memri-parser.xcodeproj/project.xcworkspace/xcuserdata/rubendaniels.xcuserdatad/xcdebugger/Expressions.xcexplist
+
38
-
0
View file @
40678b65
...
...
@@ -2,6 +2,17 @@
<VariablesViewState
version =
"1.0"
>
<ContextStates>
<ContextState
contextName =
"ViewParser.parseDict():ViewParser.swift"
>
<PersistentStrings>
<PersistentString
value =
"index"
>
</PersistentString>
<PersistentString
value =
"lastToken"
>
</PersistentString>
</PersistentStrings>
</ContextState>
<ContextState
contextName =
"Parser.parse():Parser.swift"
>
<PersistentStrings>
...
...
@@ -10,6 +21,22 @@
</PersistentString>
</PersistentStrings>
</ContextState>
<ContextState
contextName =
"ViewParser.parseDefinition(_:):ViewParser.swift"
>
<PersistentStrings>
<PersistentString
value =
"lastToken"
>
</PersistentString>
</PersistentStrings>
</ContextState>
<ContextState
contextName =
"ViewParser.parseKey():ViewParser.swift"
>
<PersistentStrings>
<PersistentString
value =
"lastToken"
>
</PersistentString>
</PersistentStrings>
</ContextState>
<ContextState
contextName =
"Parser.peekCurrentToken():Parser.swift"
>
<PersistentStrings>
...
...
@@ -21,5 +48,16 @@
</PersistentString>
</PersistentStrings>
</ContextState>
<ContextState
contextName =
"ViewParser.parse():ViewParser.swift"
>
<PersistentStrings>
<PersistentString
value =
"lastToken"
>
</PersistentString>
</PersistentStrings>
</ContextState>
<ContextState
contextName =
"closure #1 in ViewLexer.tokenize():ViewLexer.swift"
>
</ContextState>
</ContextStates>
</VariablesViewState>
This diff is collapsed.
Click to expand it.
memri-parser.xcodeproj/xcuserdata/rubendaniels.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
+
120
-
40
View file @
40678b65
...
...
@@ -7,49 +7,129 @@
<BreakpointProxy
BreakpointExtensionID =
"Xcode.Breakpoint.FileBreakpoint"
>
<BreakpointContent
uuid =
"A8DD5C78-9105-40C4-A2C0-59EE0E0D8A0D"
uuid =
"E4568A14-88CE-4190-A752-2F1E4EA48FA3"
shouldBeEnabled =
"No"
ignoreCount =
"0"
continueAfterRunningActions =
"No"
filePath =
"memri-parser/view-parser/ViewParser.swift"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"57"
endingLineNumber =
"57"
landmarkName =
"parse()"
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID =
"Xcode.Breakpoint.FileBreakpoint"
>
<BreakpointContent
uuid =
"30BF97E0-3383-406F-86E1-094FE9012440"
shouldBeEnabled =
"No"
ignoreCount =
"0"
continueAfterRunningActions =
"No"
filePath =
"memri-parser/view-parser/ViewParser.swift"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"64"
endingLineNumber =
"64"
landmarkName =
"parse()"
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID =
"Xcode.Breakpoint.FileBreakpoint"
>
<BreakpointContent
uuid =
"5B28E8C4-E5EC-462A-AABA-AE89A27AA392"
shouldBeEnabled =
"No"
ignoreCount =
"0"
continueAfterRunningActions =
"No"
filePath =
"memri-parser/view-parser/ViewParser.swift"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"58"
endingLineNumber =
"58"
landmarkName =
"parse()"
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID =
"Xcode.Breakpoint.FileBreakpoint"
>
<BreakpointContent
uuid =
"FD096918-9DD0-4176-AE72-5FAAAF728F62"
shouldBeEnabled =
"No"
ignoreCount =
"0"
continueAfterRunningActions =
"No"
filePath =
"memri-parser/view-parser/ViewParser.swift"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"59"
endingLineNumber =
"59"
landmarkName =
"parse()"
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID =
"Xcode.Breakpoint.FileBreakpoint"
>
<BreakpointContent
uuid =
"36C64E7C-167F-42F8-BEA6-41670C8B0FCE"
shouldBeEnabled =
"Yes"
ignoreCount =
"0"
continueAfterRunningActions =
"No"
filePath =
"memri-parser/view-parser/ViewParser.swift"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"154"
endingLineNumber =
"154"
landmarkName =
"parseKey()"
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID =
"Xcode.Breakpoint.FileBreakpoint"
>
<BreakpointContent
uuid =
"F0DA7F99-58EB-42BB-B6FE-3ABD70595137"
shouldBeEnabled =
"Yes"
ignoreCount =
"0"
continueAfterRunningActions =
"No"
filePath =
"memri-parser/view-parser/ViewParser.swift"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"218"
endingLineNumber =
"218"
landmarkName =
"parseDict()"
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID =
"Xcode.Breakpoint.FileBreakpoint"
>
<BreakpointContent
uuid =
"1C8F01AC-6E91-4252-A6F8-59132F3D40DB"
shouldBeEnabled =
"Yes"
ignoreCount =
"0"
continueAfterRunningActions =
"No"
filePath =
"memri-parser/main.swift"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"14"
endingLineNumber =
"14"
landmarkName =
"unknown"
landmarkType =
"0"
>
<Locations>
<Location
uuid =
"A8DD5C78-9105-40C4-A2C0-59EE0E0D8A0D - d9835511a5f3200f"
shouldBeEnabled =
"Yes"
ignoreCount =
"0"
continueAfterRunningActions =
"No"
symbolName =
"main"
moduleName =
"memri-parser"
usesParentBreakpointCondition =
"Yes"
urlString =
"file:///Users/rubendaniels/Development/memri-parser/memri-parser/main.swift"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"14"
endingLineNumber =
"14"
offsetFromSymbolStart =
"205"
>
</Location>
<Location
uuid =
"A8DD5C78-9105-40C4-A2C0-59EE0E0D8A0D - 125a6e29a548d7ce"
shouldBeEnabled =
"Yes"
ignoreCount =
"0"
continueAfterRunningActions =
"No"
symbolName =
"closure #1 (Swift.Int) -> Swift.String in memri_parser"
moduleName =
"memri-parser"
usesParentBreakpointCondition =
"Yes"
urlString =
"file:///Users/rubendaniels/Development/memri-parser/memri-parser/main.swift"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"14"
endingLineNumber =
"14"
offsetFromSymbolStart =
"4"
>
</Location>
</Locations>
filePath =
"memri-parser/view-parser/ViewParser.swift"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"223"
endingLineNumber =
"223"
landmarkName =
"parseDict()"
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID =
"Xcode.Breakpoint.FileBreakpoint"
>
<BreakpointContent
uuid =
"499C4113-783F-4B60-8A06-B81EF7BCA4B5"
shouldBeEnabled =
"Yes"
ignoreCount =
"0"
continueAfterRunningActions =
"No"
filePath =
"memri-parser/view-parser/ViewParser.swift"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"248"
endingLineNumber =
"248"
landmarkName =
"parseDict()"
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
...
...
This diff is collapsed.
Click to expand it.
memri-parser/main.swift
+
5
-
3
View file @
40678b65
...
...
@@ -18,15 +18,17 @@ if topic == "view" {
let
dt
=
Date
()
// let viewDef = ViewDefinition(code)
// print(try viewDef.parse())
let
lexer
=
ViewLexer
(
input
:
code
)
let
tokens
=
try
lexer
.
tokenize
()
// print(tokens)
print
(
"Parsing..."
)
let
parser
=
ViewParser
(
tokens
)
let
tree
=
try
parser
.
parse
()
print
(
Date
()
.
timeIntervalSince
(
dt
))
print
(
tree
)
}
else
if
topic
==
"expression"
||
topic
==
"all"
{
...
...
This diff is collapsed.
Click to expand it.
memri-parser/view-parser/color.extension.swift
0 → 100644
+
71
-
0
View file @
40678b65
import
SwiftUI
extension
Color
{
private
func
components
()
->
(
r
:
CGFloat
,
g
:
CGFloat
,
b
:
CGFloat
,
a
:
CGFloat
)
{
let
scanner
=
Scanner
(
string
:
self
.
description
.
trimmingCharacters
(
in
:
CharacterSet
.
alphanumerics
.
inverted
))
var
hexNumber
:
UInt64
=
0
var
r
:
CGFloat
=
0.0
,
g
:
CGFloat
=
0.0
,
b
:
CGFloat
=
0.0
,
a
:
CGFloat
=
0.0
let
result
=
scanner
.
scanHexInt64
(
&
hexNumber
)
if
result
{
r
=
CGFloat
((
hexNumber
&
0xff000000
)
>>
24
)
/
255
g
=
CGFloat
((
hexNumber
&
0x00ff0000
)
>>
16
)
/
255
b
=
CGFloat
((
hexNumber
&
0x0000ff00
)
>>
8
)
/
255
a
=
CGFloat
(
hexNumber
&
0x000000ff
)
/
255
}
return
(
r
,
g
,
b
,
a
)
}
init
(
hex
:
String
)
{
let
hex
=
hex
.
trimmingCharacters
(
in
:
CharacterSet
.
alphanumerics
.
inverted
)
var
int
:
UInt64
=
0
Scanner
(
string
:
hex
)
.
scanHexInt64
(
&
int
)
let
a
,
r
,
g
,
b
:
UInt64
switch
hex
.
count
{
case
3
:
// RGB (12-bit)
(
a
,
r
,
g
,
b
)
=
(
255
,
(
int
>>
8
)
*
17
,
(
int
>>
4
&
0xF
)
*
17
,
(
int
&
0xF
)
*
17
)
case
6
:
// RGB (24-bit)
(
a
,
r
,
g
,
b
)
=
(
255
,
int
>>
16
,
int
>>
8
&
0xFF
,
int
&
0xFF
)
case
8
:
// ARGB (32-bit)
(
a
,
r
,
g
,
b
)
=
(
int
>>
24
,
int
>>
16
&
0xFF
,
int
>>
8
&
0xFF
,
int
&
0xFF
)
default
:
(
a
,
r
,
g
,
b
)
=
(
1
,
1
,
1
,
0
)
}
self
.
init
(
.
sRGB
,
red
:
Double
(
r
)
/
255
,
green
:
Double
(
g
)
/
255
,
blue
:
Double
(
b
)
/
255
,
opacity
:
Double
(
a
)
/
255
)
}
// TODO
// extension UIColor {
//
// // Check if the color is light or dark, as defined by the injected lightness threshold.
// // Some people report that 0.7 is best. I suggest to find out for yourself.
// // A nil value is returned if the lightness couldn't be determined.
// func isLight(threshold: Float = 0.5) -> Bool? {
// let originalCGColor = self.cgColor
//
// // Now we need to convert it to the RGB colorspace. UIColor.white / UIColor.black are greyscale and not RGB.
// // If you don't do this then you will crash when accessing components index 2 below when evaluating greyscale colors.
// let RGBCGColor = originalCGColor.converted(to: CGColorSpaceCreateDeviceRGB(), intent: .defaultIntent, options: nil)
// guard let components = RGBCGColor?.components else {
// return nil
// }
// guard components.count >= 3 else {
// return nil
// }
//
// let brightness = Float(((components[0] * 299) + (components[1] * 587) + (components[2] * 114)) / 1000)
// return (brightness > threshold)
// }
// }
}
// https://medium.com/@masamichiueta/bridging-uicolor-system-color-to-swiftui-color-ef98f6e21206
This diff is collapsed.
Click to expand it.
memri-parser/view-parser/example/example.view
+
6
-
6
View file @
40678b65
...
...
@@ -18,7 +18,7 @@
background: background
}
[renderer = generalEditor] {
[renderer =
"
generalEditor
"
] {
sequence: labels starred other dates
excluded: deleted syncState uid
readOnly: uid
...
...
@@ -112,7 +112,7 @@
view: {
defaultRenderer: timeline
queryOptions
:
{
queryOptions {
query: "AuditItem appliesTo:{.id}"
sortProperty: dateCreated
sortAscending: true
...
...
@@ -128,9 +128,9 @@
contextButtons: star schedule
actionItems:
showSharePanel
{
title: "{$sharewith}" }
addToPanel
{
title: "{$addtolist}" }
duplicate
{
title: "{$duplicate} {type}" }
{ name:
showSharePanel
,
title: "{$sharewith}" }
{ name:
addToPanel
,
title: "{$addtolist}" }
{ name:
duplicate
,
title: "{$duplicate} {type}" }
navigateItems:
openView {
...
...
@@ -344,7 +344,7 @@ Person[] {
type: "Person"
}
}
editActionButton: toggleEditMode
filterButtons: showStarred toggleFilterPanel
...
...
This diff is collapsed.
Click to expand it.
memri-parserTests/ExprParserTests.swift
+
0
-
1
View file @
40678b65
...
...
@@ -66,7 +66,6 @@ class ExprParserTests: XCTestCase {
let
snippet
=
".bar and bar.foo(10) and bar[foo = 10] or shouldNeverGetHere"
let
result
=
try
parse
(
snippet
)
print
(
result
)
XCTAssertEqual
(
result
.
description
,
"BinaryOpNode(ConditionAND, lhs: BinaryOpNode(ConditionAND, lhs: LookupNode([VariableNode(__DEFAULT__), VariableNode(bar)]), rhs: CallNode(lookup: LookupNode([VariableNode(bar), VariableNode(foo)]), argument: [NumberNode(10.0)])), rhs: BinaryOpNode(ConditionOR, lhs: LookupNode([VariableNode(bar), LookupNode([BinaryOpNode(ConditionEquals, lhs: LookupNode([VariableNode(foo)]), rhs: NumberNode(10.0))])]), rhs: LookupNode([VariableNode(shouldNeverGetHere)])))"
)
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets