compiler: Add Ability to Annotate Preprocessed Source
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
@@ -156,6 +156,35 @@ import TreeSitterP4
|
||||
== SourceLocation(48..<166))
|
||||
}
|
||||
|
||||
@Test func test_preprocessor_nested_includes_annotated_source() async throws {
|
||||
let sm = SourceManager(["./TestData/Sources/"])
|
||||
let prep = SourceCodePreprocessor(sm)
|
||||
let file = FilePath.init(stringLiteral: "./TestData/Sources/annotate.p4")
|
||||
|
||||
let expected = """
|
||||
<struct Testing {
|
||||
< bool yesno;
|
||||
int count;>
|
||||
};
|
||||
<parser main_parser() {
|
||||
< state start {
|
||||
Testing ts;
|
||||
ts.yesno = true;
|
||||
ts.count = 5;
|
||||
transition select (ts.count == 5) {
|
||||
true: accept;
|
||||
false: reject;
|
||||
};
|
||||
}
|
||||
>
|
||||
}>>
|
||||
"""
|
||||
|
||||
#expect(#RequireOkResult(prep.preprocess(file)))
|
||||
let source = try! (#UseOkResult(prep.preprocess(file)))
|
||||
#expect(source.getSource(annotated: true) == expected)
|
||||
}
|
||||
|
||||
|
||||
@Test func test_source_location_contains() async throws {
|
||||
let outer = SourceLocation(0..<500)
|
||||
|
||||
Reference in New Issue
Block a user