Skip to content

Commit e71e7dc

Browse files
authored
Merge pull request #26 from csprasad/dev
Syntax Highlighting Revamp
2 parents 77088c8 + dd824e7 commit e71e7dc

8 files changed

Lines changed: 827 additions & 1 deletion

File tree

DevLint/DevLint.xcodeproj/project.pbxproj

Lines changed: 154 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
C81EF13C2D6B1D6A001B3B5E /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C81EF13B2D6B1D6A001B3B5E /* ContentView.swift */; };
1414
C81EF13E2D6B1D6E001B3B5E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C81EF13D2D6B1D6E001B3B5E /* Assets.xcassets */; };
1515
C81EF1412D6B1D6E001B3B5E /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C81EF1402D6B1D6E001B3B5E /* Preview Assets.xcassets */; };
16+
C81FA9692D897B5B00A33FEC /* Tokenizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = C81FA9682D897B5B00A33FEC /* Tokenizer.swift */; };
17+
C81FA96B2D897B6900A33FEC /* Token.swift in Sources */ = {isa = PBXBuildFile; fileRef = C81FA96A2D897B6900A33FEC /* Token.swift */; };
18+
C81FA9742D8989C000A33FEC /* DevLintTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C81FA9732D8989C000A33FEC /* DevLintTests.swift */; };
19+
C81FA97B2D898A0E00A33FEC /* TokenizerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C81FA97A2D898A0E00A33FEC /* TokenizerTests.swift */; };
20+
C81FA97E2D899CB100A33FEC /* LanguageRules.swift in Sources */ = {isa = PBXBuildFile; fileRef = C81FA97D2D899CB100A33FEC /* LanguageRules.swift */; };
21+
C81FA9802D899CD200A33FEC /* SwiftLanguageRules.swift in Sources */ = {isa = PBXBuildFile; fileRef = C81FA97F2D899CD200A33FEC /* SwiftLanguageRules.swift */; };
1622
C8601D452D7EEEA60058AEAB /* CustomToolbar.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8601D442D7EEEA60058AEAB /* CustomToolbar.swift */; };
1723
C8601D472D7EFA770058AEAB /* ToolbarButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8601D462D7EFA770058AEAB /* ToolbarButton.swift */; };
1824
C8763EBD2D7CCC1E00D535E6 /* LineNumberView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8763EBC2D7CCC1E00D535E6 /* LineNumberView.swift */; };
@@ -30,6 +36,16 @@
3036
C8F849BB2D75AF4A002090E5 /* SyntaxHighlighter.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8F849BA2D75AF4A002090E5 /* SyntaxHighlighter.swift */; };
3137
/* End PBXBuildFile section */
3238

39+
/* Begin PBXContainerItemProxy section */
40+
C81FA9752D8989C000A33FEC /* PBXContainerItemProxy */ = {
41+
isa = PBXContainerItemProxy;
42+
containerPortal = C81EF12E2D6B1D6A001B3B5E /* Project object */;
43+
proxyType = 1;
44+
remoteGlobalIDString = C81EF1352D6B1D6A001B3B5E;
45+
remoteInfo = DevLint;
46+
};
47+
/* End PBXContainerItemProxy section */
48+
3349
/* Begin PBXFileReference section */
3450
C813D9D72D7AED5500833098 /* CodeEditorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CodeEditorModel.swift; sourceTree = "<group>"; };
3551
C813D9D92D7AED7600833098 /* ThemeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemeModel.swift; sourceTree = "<group>"; };
@@ -39,6 +55,13 @@
3955
C81EF13D2D6B1D6E001B3B5E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
4056
C81EF1402D6B1D6E001B3B5E /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
4157
C81EF1422D6B1D6E001B3B5E /* DevLint.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DevLint.entitlements; sourceTree = "<group>"; };
58+
C81FA9682D897B5B00A33FEC /* Tokenizer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tokenizer.swift; sourceTree = "<group>"; };
59+
C81FA96A2D897B6900A33FEC /* Token.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Token.swift; sourceTree = "<group>"; };
60+
C81FA9712D8989C000A33FEC /* DevLintTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DevLintTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
61+
C81FA9732D8989C000A33FEC /* DevLintTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DevLintTests.swift; sourceTree = "<group>"; };
62+
C81FA97A2D898A0E00A33FEC /* TokenizerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TokenizerTests.swift; sourceTree = "<group>"; };
63+
C81FA97D2D899CB100A33FEC /* LanguageRules.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LanguageRules.swift; sourceTree = "<group>"; };
64+
C81FA97F2D899CD200A33FEC /* SwiftLanguageRules.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftLanguageRules.swift; sourceTree = "<group>"; };
4265
C8601D442D7EEEA60058AEAB /* CustomToolbar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomToolbar.swift; sourceTree = "<group>"; };
4366
C8601D462D7EFA770058AEAB /* ToolbarButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToolbarButton.swift; sourceTree = "<group>"; };
4467
C8763EBC2D7CCC1E00D535E6 /* LineNumberView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LineNumberView.swift; sourceTree = "<group>"; };
@@ -64,13 +87,21 @@
6487
);
6588
runOnlyForDeploymentPostprocessing = 0;
6689
};
90+
C81FA96E2D8989C000A33FEC /* Frameworks */ = {
91+
isa = PBXFrameworksBuildPhase;
92+
buildActionMask = 2147483647;
93+
files = (
94+
);
95+
runOnlyForDeploymentPostprocessing = 0;
96+
};
6797
/* End PBXFrameworksBuildPhase section */
6898

6999
/* Begin PBXGroup section */
70100
C81EF12D2D6B1D6A001B3B5E = {
71101
isa = PBXGroup;
72102
children = (
73103
C81EF1382D6B1D6A001B3B5E /* DevLint */,
104+
C81FA9722D8989C000A33FEC /* DevLintTests */,
74105
C81EF1372D6B1D6A001B3B5E /* Products */,
75106
);
76107
sourceTree = "<group>";
@@ -79,6 +110,7 @@
79110
isa = PBXGroup;
80111
children = (
81112
C81EF1362D6B1D6A001B3B5E /* DevLint.app */,
113+
C81FA9712D8989C000A33FEC /* DevLintTests.xctest */,
82114
);
83115
name = Products;
84116
sourceTree = "<group>";
@@ -93,6 +125,7 @@
93125
C8F849B32D75AD81002090E5 /* Views */,
94126
C8EF75F52D7CC0370023A5DE /* Components */,
95127
C8F849B92D75AF32002090E5 /* Utilities */,
128+
C81FA9672D897B4100A33FEC /* SyntaxHighlighting */,
96129
C8EF75F22D7CBEBD0023A5DE /* Resources */,
97130
C8EF75F32D7CBEE30023A5DE /* Supporting Files */,
98131
C81EF1422D6B1D6E001B3B5E /* DevLint.entitlements */,
@@ -109,6 +142,35 @@
109142
path = "Preview Content";
110143
sourceTree = "<group>";
111144
};
145+
C81FA9672D897B4100A33FEC /* SyntaxHighlighting */ = {
146+
isa = PBXGroup;
147+
children = (
148+
C81FA9812D899F8D00A33FEC /* Tokenizer */,
149+
C8F849BA2D75AF4A002090E5 /* SyntaxHighlighter.swift */,
150+
);
151+
path = SyntaxHighlighting;
152+
sourceTree = "<group>";
153+
};
154+
C81FA9722D8989C000A33FEC /* DevLintTests */ = {
155+
isa = PBXGroup;
156+
children = (
157+
C81FA9732D8989C000A33FEC /* DevLintTests.swift */,
158+
C81FA97A2D898A0E00A33FEC /* TokenizerTests.swift */,
159+
);
160+
path = DevLintTests;
161+
sourceTree = "<group>";
162+
};
163+
C81FA9812D899F8D00A33FEC /* Tokenizer */ = {
164+
isa = PBXGroup;
165+
children = (
166+
C81FA96A2D897B6900A33FEC /* Token.swift */,
167+
C81FA9682D897B5B00A33FEC /* Tokenizer.swift */,
168+
C81FA97D2D899CB100A33FEC /* LanguageRules.swift */,
169+
C81FA97F2D899CD200A33FEC /* SwiftLanguageRules.swift */,
170+
);
171+
path = Tokenizer;
172+
sourceTree = "<group>";
173+
};
112174
C887B66F2D77784A00AE1A03 /* Models */ = {
113175
isa = PBXGroup;
114176
children = (
@@ -161,7 +223,6 @@
161223
C8EF75F42D7CC0250023A5DE /* Core */ = {
162224
isa = PBXGroup;
163225
children = (
164-
C8F849BA2D75AF4A002090E5 /* SyntaxHighlighter.swift */,
165226
C8AC32312D7AF2B7003F496D /* ThemeManager.swift */,
166227
);
167228
path = Core;
@@ -230,6 +291,24 @@
230291
productReference = C81EF1362D6B1D6A001B3B5E /* DevLint.app */;
231292
productType = "com.apple.product-type.application";
232293
};
294+
C81FA9702D8989C000A33FEC /* DevLintTests */ = {
295+
isa = PBXNativeTarget;
296+
buildConfigurationList = C81FA9772D8989C000A33FEC /* Build configuration list for PBXNativeTarget "DevLintTests" */;
297+
buildPhases = (
298+
C81FA96D2D8989C000A33FEC /* Sources */,
299+
C81FA96E2D8989C000A33FEC /* Frameworks */,
300+
C81FA96F2D8989C000A33FEC /* Resources */,
301+
);
302+
buildRules = (
303+
);
304+
dependencies = (
305+
C81FA9762D8989C000A33FEC /* PBXTargetDependency */,
306+
);
307+
name = DevLintTests;
308+
productName = DevLintTests;
309+
productReference = C81FA9712D8989C000A33FEC /* DevLintTests.xctest */;
310+
productType = "com.apple.product-type.bundle.unit-test";
311+
};
233312
/* End PBXNativeTarget section */
234313

235314
/* Begin PBXProject section */
@@ -243,6 +322,10 @@
243322
C81EF1352D6B1D6A001B3B5E = {
244323
CreatedOnToolsVersion = 14.2;
245324
};
325+
C81FA9702D8989C000A33FEC = {
326+
CreatedOnToolsVersion = 14.2;
327+
TestTargetID = C81EF1352D6B1D6A001B3B5E;
328+
};
246329
};
247330
};
248331
buildConfigurationList = C81EF1312D6B1D6A001B3B5E /* Build configuration list for PBXProject "DevLint" */;
@@ -262,6 +345,7 @@
262345
projectRoot = "";
263346
targets = (
264347
C81EF1352D6B1D6A001B3B5E /* DevLint */,
348+
C81FA9702D8989C000A33FEC /* DevLintTests */,
265349
);
266350
};
267351
/* End PBXProject section */
@@ -276,6 +360,13 @@
276360
);
277361
runOnlyForDeploymentPostprocessing = 0;
278362
};
363+
C81FA96F2D8989C000A33FEC /* Resources */ = {
364+
isa = PBXResourcesBuildPhase;
365+
buildActionMask = 2147483647;
366+
files = (
367+
);
368+
runOnlyForDeploymentPostprocessing = 0;
369+
};
279370
/* End PBXResourcesBuildPhase section */
280371

281372
/* Begin PBXSourcesBuildPhase section */
@@ -284,7 +375,9 @@
284375
buildActionMask = 2147483647;
285376
files = (
286377
C8F849BB2D75AF4A002090E5 /* SyntaxHighlighter.swift in Sources */,
378+
C81FA9692D897B5B00A33FEC /* Tokenizer.swift in Sources */,
287379
C8601D472D7EFA770058AEAB /* ToolbarButton.swift in Sources */,
380+
C81FA9802D899CD200A33FEC /* SwiftLanguageRules.swift in Sources */,
288381
C8AC32342D7AF3ED003F496D /* CodeEditorView.swift in Sources */,
289382
C8AC32302D7AF297003F496D /* CodeEditorViewModel.swift in Sources */,
290383
C81EF13C2D6B1D6A001B3B5E /* ContentView.swift in Sources */,
@@ -293,6 +386,7 @@
293386
C8763EBD2D7CCC1E00D535E6 /* LineNumberView.swift in Sources */,
294387
C8763EC12D7CCD1000D535E6 /* CodeInputView.swift in Sources */,
295388
C8763EC32D7CCD4000D535E6 /* CodeOutputView.swift in Sources */,
389+
C81FA96B2D897B6900A33FEC /* Token.swift in Sources */,
296390
C8AC32322D7AF2B7003F496D /* ThemeManager.swift in Sources */,
297391
C8763EBF2D7CCCBE00D535E6 /* EditorSectionView.swift in Sources */,
298392
C8B705482D88415700034249 /* SwiftFormatAdapter.swift in Sources */,
@@ -301,11 +395,29 @@
301395
C8EF75F72D7CC0910023A5DE /* Extensions.swift in Sources */,
302396
C8B705452D88410500034249 /* CodeFormatter.swift in Sources */,
303397
C8F849B52D75AEF1002090E5 /* CodeEditorContainer.swift in Sources */,
398+
C81FA97E2D899CB100A33FEC /* LanguageRules.swift in Sources */,
399+
);
400+
runOnlyForDeploymentPostprocessing = 0;
401+
};
402+
C81FA96D2D8989C000A33FEC /* Sources */ = {
403+
isa = PBXSourcesBuildPhase;
404+
buildActionMask = 2147483647;
405+
files = (
406+
C81FA9742D8989C000A33FEC /* DevLintTests.swift in Sources */,
407+
C81FA97B2D898A0E00A33FEC /* TokenizerTests.swift in Sources */,
304408
);
305409
runOnlyForDeploymentPostprocessing = 0;
306410
};
307411
/* End PBXSourcesBuildPhase section */
308412

413+
/* Begin PBXTargetDependency section */
414+
C81FA9762D8989C000A33FEC /* PBXTargetDependency */ = {
415+
isa = PBXTargetDependency;
416+
target = C81EF1352D6B1D6A001B3B5E /* DevLint */;
417+
targetProxy = C81FA9752D8989C000A33FEC /* PBXContainerItemProxy */;
418+
};
419+
/* End PBXTargetDependency section */
420+
309421
/* Begin XCBuildConfiguration section */
310422
C81EF1432D6B1D6E001B3B5E /* Debug */ = {
311423
isa = XCBuildConfiguration;
@@ -472,6 +584,38 @@
472584
};
473585
name = Release;
474586
};
587+
C81FA9782D8989C000A33FEC /* Debug */ = {
588+
isa = XCBuildConfiguration;
589+
buildSettings = {
590+
BUNDLE_LOADER = "$(TEST_HOST)";
591+
CODE_SIGN_STYLE = Automatic;
592+
CURRENT_PROJECT_VERSION = 1;
593+
GENERATE_INFOPLIST_FILE = YES;
594+
MARKETING_VERSION = 1.0;
595+
PRODUCT_BUNDLE_IDENTIFIER = com.codeAlligator.DevLintTests;
596+
PRODUCT_NAME = "$(TARGET_NAME)";
597+
SWIFT_EMIT_LOC_STRINGS = NO;
598+
SWIFT_VERSION = 5.0;
599+
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DevLint.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/DevLint";
600+
};
601+
name = Debug;
602+
};
603+
C81FA9792D8989C000A33FEC /* Release */ = {
604+
isa = XCBuildConfiguration;
605+
buildSettings = {
606+
BUNDLE_LOADER = "$(TEST_HOST)";
607+
CODE_SIGN_STYLE = Automatic;
608+
CURRENT_PROJECT_VERSION = 1;
609+
GENERATE_INFOPLIST_FILE = YES;
610+
MARKETING_VERSION = 1.0;
611+
PRODUCT_BUNDLE_IDENTIFIER = com.codeAlligator.DevLintTests;
612+
PRODUCT_NAME = "$(TARGET_NAME)";
613+
SWIFT_EMIT_LOC_STRINGS = NO;
614+
SWIFT_VERSION = 5.0;
615+
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DevLint.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/DevLint";
616+
};
617+
name = Release;
618+
};
475619
/* End XCBuildConfiguration section */
476620

477621
/* Begin XCConfigurationList section */
@@ -493,6 +637,15 @@
493637
defaultConfigurationIsVisible = 0;
494638
defaultConfigurationName = Release;
495639
};
640+
C81FA9772D8989C000A33FEC /* Build configuration list for PBXNativeTarget "DevLintTests" */ = {
641+
isa = XCConfigurationList;
642+
buildConfigurations = (
643+
C81FA9782D8989C000A33FEC /* Debug */,
644+
C81FA9792D8989C000A33FEC /* Release */,
645+
);
646+
defaultConfigurationIsVisible = 0;
647+
defaultConfigurationName = Release;
648+
};
496649
/* End XCConfigurationList section */
497650

498651
/* Begin XCRemoteSwiftPackageReference section */
File renamed without changes.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
//
2+
// LanguageRules.swift
3+
// DevLint
4+
//
5+
// Created by CS Prasad on 18/03/25.
6+
//
7+
8+
import Foundation
9+
10+
protocol LanguageRules {
11+
var keywords: Set<String> { get } // func, var, let, if, else
12+
var identifiers: Set<String> { get } // Variable and function names (not predefined)
13+
var numbers: Set<String> { get } // Integers, floats, etc.
14+
var decimalNumbers: Set<String> { get } // Floating-point numbers (e.g., 3.14)
15+
var exponentNumbers: Set<String> { get } // Scientific notation (e.g., 1.23e10)
16+
var strings: Set<String> { get } // "Hello, World!"
17+
var rawStrings: Set<String> { get } // #"Hello, World!"#
18+
var multiLineStrings: Set<String> { get } // """Hello\nWorld!"""
19+
var interpolatedStrings: Set<String> { get } // "Hello \(name)!"
20+
var characters: Set<String> { get } // 'A', 'B', etc.
21+
var booleans: Set<String> { get } // true, false
22+
var operatorSymbols: Set<String> { get } // +, -, *, /, =, ==, !=, etc.
23+
var punctuation: Set<String> { get } // { }, ( ), [ ], ; , . , ,
24+
var comments: Set<String> { get } // //, /* */ (Single/Multi-line)
25+
var directives: Set<String> { get } // #if, #endif, #define (Preprocessor directives)
26+
var escapeSequences: Set<String> { get } // \n, \t, etc.
27+
var annotations: Set<String> { get } // @available, @objc, etc.
28+
var attributes: Set<String> { get } // Swift attributes (@available, @objc)
29+
var types: Set<String> { get } // Int, String, Double, custom class names
30+
var accessModifiers: Set<String> { get } // public, private, internal, protected
31+
var storageModifiers: Set<String> { get } // static, final, override, mutating
32+
var functionCalls: Set<String> { get } // print(), customFunction()
33+
var macros: Set<String> { get } // #macro (Used in some languages)
34+
var nullLiterals: Set<String> { get } // null, nil
35+
var escapedIdentifiers: Set<String> { get } // Backtick-wrapped names (`reserved`)
36+
var hexNumbers: Set<String> { get } // 0xFF, 0x1A
37+
var binaryNumbers: Set<String> { get } // 0b1010, 0b1101
38+
var octalNumbers: Set<String> { get } // 0o77, 0o123
39+
var regexLiterals: Set<String> { get } // /pattern/ (Used in JS, Swift 5.7+)
40+
var genericTypes: Set<String> { get } // <T>, <Key, Value>
41+
var shebang: Set<String> { get } // #!/usr/bin/swift
42+
var parameterLabels: Set<String> { get } // firstName in func greet(firstName name: String)
43+
var tupleTypes: Set<String> { get } // (x: Int, y: Int)
44+
var metatypes: Set<String> { get } // .Type, .Protocol
45+
var keyPaths: Set<String> { get } // \Person.name
46+
var implicitParameters: Set<String> { get } // $0, $1 in closures
47+
var dollarIdentifiers: Set<String> { get } // $var (Swift internals)
48+
var patternMatching: Set<String> { get } // case .some(_)
49+
var lazyStorage: Set<String> { get } // _storage variables
50+
var dependencyMacros: Set<String> { get } // #if canImport
51+
var moduleNames: Set<String> { get } // import MyCustomModule
52+
var escapedNewlines: Set<String> { get } // \ at EOL for line continuation
53+
54+
func getTokenType(for value: String) -> Token.TokenType
55+
}

0 commit comments

Comments
 (0)