Refactor P4Compiler to P4Parser
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
@@ -22,9 +22,9 @@ import SwiftTreeSitter
|
||||
import Testing
|
||||
import TreeSitter
|
||||
import TreeSitterP4
|
||||
import P4CodeGen
|
||||
|
||||
@testable import P4Compiler
|
||||
@testable import P4Parser
|
||||
@testable import P4CodeGen
|
||||
|
||||
@Test func test_text_serializer() async throws {
|
||||
let simple_parser_declaration = """
|
||||
@@ -42,9 +42,9 @@ import P4CodeGen
|
||||
};
|
||||
"""
|
||||
|
||||
let program = try #UseOkResult(SpecialCompilers.ProgramCompiler.Compile(simple_parser_declaration))
|
||||
let v = TextSerializer()
|
||||
let c = TextSerializerContext();
|
||||
let vd = ASTVisitorDriver();
|
||||
let program = try #UseOkResult(compile(simple_parser_declaration))
|
||||
let v = CSTTextSerializer()
|
||||
let c = CSTTextSerializerContext();
|
||||
let vd = CSTVisitorDriver();
|
||||
#expect(#RequireOkResult((vd.visit(program: program, visitor: v, context: c))))
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
import Foundation
|
||||
import Macros
|
||||
import P4Compiler
|
||||
import SwiftTreeSitter
|
||||
import SystemPackage
|
||||
import Testing
|
||||
@@ -25,6 +24,7 @@ import TreeSitter
|
||||
import TreeSitterP4
|
||||
|
||||
@testable import Common
|
||||
@testable import P4Parser
|
||||
|
||||
@Test func test_preprocessor() async throws {
|
||||
let sm = SourceManager(["./TestData/Sources/"])
|
||||
@@ -32,7 +32,7 @@ import TreeSitterP4
|
||||
let file = FilePath.init(stringLiteral: "simple.p4")
|
||||
|
||||
let source = try! (#UseOkResult(prep.preprocess(file)))
|
||||
#expect(#RequireOkResult(SpecialCompilers.ProgramCompiler.Compile(source.getSource())))
|
||||
#expect(#RequireOkResult(compile(source.getSource())))
|
||||
#expect(source.getLocations().getPath() == file)
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ import TreeSitterP4
|
||||
let file = FilePath.init(stringLiteral: "simple.p4")
|
||||
|
||||
let source = try! (#UseOkResult(prep.preprocess(file)))
|
||||
#expect(#RequireOkResult(SpecialCompilers.ProgramCompiler.Compile(source.getSource())))
|
||||
#expect(#RequireOkResult(compile(source.getSource())))
|
||||
#expect(source.getLocations().getPath() == file)
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ import TreeSitterP4
|
||||
#expect(#RequireOkResult(prep.preprocess(file)))
|
||||
|
||||
let source = try! (#UseOkResult(prep.preprocess(file)))
|
||||
#expect(#RequireOkResult(SpecialCompilers.ProgramCompiler.Compile(source.getSource())))
|
||||
#expect(#RequireOkResult(compile(source.getSource())))
|
||||
#expect(source.getLocations().getPath() == file)
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ import TreeSitterP4
|
||||
#expect(#RequireOkResult(prep.preprocess(file)))
|
||||
|
||||
let source = try! (#UseOkResult(prep.preprocess(file)))
|
||||
#expect(#RequireOkResult(SpecialCompilers.ProgramCompiler.Compile(source.getSource())))
|
||||
#expect(#RequireOkResult(compile(source.getSource())))
|
||||
#expect(source.getLocations().getPath() == file)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user