Skip to content

Commit

Permalink
feat: add the TreeConstructor module
Browse files Browse the repository at this point in the history
WIP: The implementation of this module is in progress.
  • Loading branch information
kkebo committed Apr 10, 2024
1 parent bba9930 commit b5e0355
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 2 deletions.
14 changes: 13 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ let package = Package(
.visionOS(.v1),
],
products: [
.library(name: "Tokenizer", targets: ["Tokenizer"])
.library(name: "Tokenizer", targets: ["Tokenizer"]),
.library(name: "TreeConstructor", targets: ["TreeConstructor"]),
],
dependencies: [
.package(url: "https://github.com/apple/swift-syntax", "509.0.0"..<"601.0.0"),
Expand All @@ -36,6 +37,17 @@ let package = Package(
.enableUpcomingFeature("ExistentialAny"),
]
),
.target(
name: "TreeConstructor",
dependencies: [
"Tokenizer"
],
swiftSettings: [
.unsafeFlags(["-Xfrontend", "-warn-long-function-bodies=100"], .when(configuration: .debug)),
.unsafeFlags(["-Xfrontend", "-warn-long-expression-type-checking=100"], .when(configuration: .debug)),
.enableUpcomingFeature("ExistentialAny"),
]
),
.macro(
name: "TokenizerMacros",
dependencies: [
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ Zyphy is (or will be) a fast web browser engine written in Swift.
- (Nothing)
- 🚧 Work in Progress
- `Tokenizer` - An HTML tokenizer ([specs](https://html.spec.whatwg.org/multipage/parsing.html#tokenization))
- `TreeConstructor` - An HTML tree constructor ([specs](https://html.spec.whatwg.org/multipage/parsing.html#tree-construction))
- 🥚 To Do
- `Zyphy` - The main module
- `TreeConstructor` - An HTML tree constructor ([specs](https://html.spec.whatwg.org/multipage/parsing.html#tree-construction))

## Prerequisites

Expand Down
25 changes: 25 additions & 0 deletions Sources/TreeConstructor/InsertionMode.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
enum InsertionMode {
case initial
case beforeHTML
case beforeHead
case inHead
case inHeadNoscript
case afterHead
case inBody
case text
case inTable
case inTableText
case inCaption
case inColumnGroup
case inTableBody
case inRow
case inCell
case inSelect
case inSelectInTable
case inTemplate
case afterBody
case inFrameset
case afterFrameset
case afterAfterBody
case afterAfterFrameset
}
15 changes: 15 additions & 0 deletions Sources/TreeConstructor/TreeConstructor.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Tokenizer

public struct TreeConstructor {
private var mode: InsertionMode

public init() {
self.mode = .initial
}
}

extension TreeConstructor: TokenSink {
mutating func process(_ token: consuming Token) {
// TODO: Implement here
}
}

0 comments on commit b5e0355

Please sign in to comment.