Skip to content

Commit 4b6fc36

Browse files
committed
Checkpoint on bringing up AST and populating it
Signed-off-by: Matthew Ballance <[email protected]>
1 parent ef6d187 commit 4b6fc36

39 files changed

+1015
-513
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,6 @@ python/pssast.h
146146
python/pssast_api.h
147147
python/pssparser/pssast.pxd
148148
python/pssparser/pssast_decl.pxd
149+
python/PyBaseVisitor.*
150+
151+
gen/

.vscode/c_cpp_properties.json

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "Default",
5+
"includePath": [
6+
"src",
7+
"src/include",
8+
"test",
9+
"packages/antlr4-cpp-runtime/runtime/src",
10+
"packages/gtest/googletest/include",
11+
"build/pssast/include/pssast/include",
12+
"build/src/antlr4cpp_generated_src/PSSLexer",
13+
"build/src/antlr4cpp_generated_src/PSSParser"
14+
],
15+
"defines": [
16+
"${default}"
17+
],
18+
"macFrameworkPath": [
19+
"${default}"
20+
],
21+
"forcedInclude": [
22+
"${default}"
23+
],
24+
"compileCommands": "${default}",
25+
"browse": {
26+
"limitSymbolsToIncludedHeaders": true,
27+
"databaseFilename": "${default}",
28+
"path": [
29+
"${default}",
30+
"src",
31+
"build/pssast/src"
32+
]
33+
},
34+
"intelliSenseMode": "${default}",
35+
"cStandard": "${default}",
36+
"cppStandard": "${default}",
37+
"compilerPath": "${default}"
38+
}
39+
],
40+
"version": 4
41+
}

.vscode/settings.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"python.defaultInterpreterPath": "${workspaceFolder}/packages/python/bin/python3",
3+
"python.testing.unittestArgs": [
4+
"-v",
5+
"-s",
6+
"./ve/unit",
7+
"-p",
8+
"test_**.py"
9+
],
10+
"python.envFile": "${workspaceFolder}/.env",
11+
"python.testing.pytestEnabled": false,
12+
"python.testing.unittestEnabled": true,
13+
14+
"search.useIgnoreFiles": true,
15+
"search.useGlobalIgnoreFiles": true,
16+
"cmake.configureOnOpen": false
17+
}
18+

CMakeLists.txt

+6-4
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ ExternalProject_Add(AST
7979

8080
enable_testing()
8181

82-
ExternalProject_Add(googletest
83-
PREFIX googletest
84-
SOURCE_DIR "${PACKAGES_DIR}/googletest"
82+
ExternalProject_Add(GTEST
83+
PREFIX gtest
84+
SOURCE_DIR "${PACKAGES_DIR}/gtest"
8585
CMAKE_CACHE_ARGS
86-
-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/googletest
86+
-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/gtest
8787
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
8888
-DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS}
8989
)
@@ -100,6 +100,8 @@ add_custom_target(build_ext ALL
100100
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/pssast/ext/pssast_decl.pxd ${CMAKE_CURRENT_SOURCE_DIR}/python/pssparser/pssast_decl.pxd
101101
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/pssast/ext/pssast.pxd ${CMAKE_CURRENT_SOURCE_DIR}/python/pssparser/pssast.pxd
102102
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/pssast/ext/pssast.pyx ${CMAKE_CURRENT_SOURCE_DIR}/python/pssast.pyx
103+
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/pssast/ext/PyBaseVisitor.cpp ${CMAKE_CURRENT_SOURCE_DIR}/python/PyBaseVisitor.cpp
104+
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/pssast/ext/PyBaseVisitor.h ${CMAKE_CURRENT_SOURCE_DIR}/python/PyBaseVisitor.h
103105
COMMAND ${CMAKE_COMMAND} -E env CMAKE_BINARY_DIR=${CMAKE_BINARY_DIR} $ENV{EXT_PYTHON} ${CMAKE_CURRENT_SOURCE_DIR}/setup.py build_ext --inplace
104106
COMMAND $ENV{EXT_PYTHON} ${CMAKE_CURRENT_SOURCE_DIR}/setup.py bdist_wheel
105107
)

ast/coretypes.yaml

+71-51
Original file line numberDiff line numberDiff line change
@@ -3,80 +3,100 @@
33
#*
44
#* Defines base types used by other segments of the AST
55
#****************************************************************************
6+
structs:
7+
- Location:
8+
data:
9+
- fileid:
10+
type: int32_t
11+
init: -1
12+
- lineno:
13+
type: int32_t
14+
init: -1
15+
- linepos:
16+
type: int32_t
17+
init: -1
18+
619
classes:
7-
- Location:
8-
- data:
9-
- fileid:
10-
- type: int32_t
11-
- init: -1
12-
- lineno:
13-
- type: int32_t
14-
- init: -1
15-
- linepos:
16-
- type: int32_t
17-
- init: -1
18-
1920
- Scope:
20-
- super: ScopeChild
21-
- data:
21+
super: ScopeChild
22+
data:
2223
- children: list<UP<ScopeChild>>
2324
- symtab:
24-
- type: map<string,P<NamedScopeChild>>
25-
- is_ctor: false
25+
type: map<string,P<NamedScopeChild>>
26+
is_ctor: false
2627

2728
- ScopeChild:
28-
- data:
29+
data:
2930
- docstring:
3031
- type: string
3132
- is_ctor: false
32-
# - location:
33-
# - type: Location
33+
- location:
34+
type: Location
35+
is_ctor: false
3436
- parent:
35-
- type: P<Scope>
36-
- is_ctor: false
37-
- init: 0
37+
type: P<Scope>
38+
is_ctor: false
39+
init: 0
3840
- index:
39-
- type: int32_t
40-
- is_ctor: false
41-
- init: -1
41+
type: int32_t
42+
is_ctor: false
43+
init: -1
4244

4345
- GlobalScope:
44-
- super: Scope
45-
- data:
46-
- fileid: int32_t
46+
super: Scope
47+
data:
48+
- fileid: int32_t
4749
- NamedScope:
48-
- super: Scope
49-
- data:
50-
- name : UP<ExprId>
50+
super: Scope
51+
data:
52+
- name : UP<ExprId>
53+
5154
- NamedScopeChild:
52-
- super: ScopeChild
53-
- data:
54-
- name: UP<ExprId>
55+
super: ScopeChild
56+
data:
57+
- name: UP<ExprId>
58+
5559
- PackageScope:
56-
- super: NamedScope
57-
- data:
58-
- sibling:
59-
- type: P<PackageScope>
60-
- is_ctor: false
61-
- init: 0
62-
- TypeScope:
63-
- super: NamedScope
64-
- data:
65-
- super_t : UP<TypeIdentifier>
60+
super: Scope
61+
data:
62+
- id:
63+
type: list<UP<ExprId>>
64+
is_ctor: false
65+
- sibling:
66+
type: P<PackageScope>
67+
is_ctor: false
68+
init: 0
69+
70+
- PackageImportStmt:
71+
super: ScopeChild
72+
data:
73+
- path: list<UP<ExprId>>
74+
- wildcard: bool
75+
- alias: UP<ExprId>
76+
6677
- Action:
67-
- super: TypeScope
78+
super: TypeScope
79+
data:
80+
- is_abstract: bool
81+
6882
- Component:
69-
- super: TypeScope
83+
super: TypeScope
84+
7085
- Struct:
71-
- super: TypeScope
86+
super: TypeScope
87+
7288
- Buffer:
73-
- super: Struct
89+
super: Struct
90+
7491
- Resource:
75-
- super: Struct
92+
super: Struct
93+
7694
- State:
77-
- super: Struct
95+
super: Struct
96+
7897
- Stream:
79-
- super: Struct
98+
super: Struct
99+
80100
flags:
81101
- FieldAttr:
82102
- values:

ast/datatype.yaml

+43-40
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,45 @@
11
#****************************************************************************
22
classes:
3-
- DataType:
4-
- super: ScopeChild
5-
- DataTypeArray:
6-
- super: DataType
7-
- data:
8-
- type: "UP<DataType>"
9-
- size: "UP<Expr>"
10-
- DataTypeBool:
11-
- super: DataType
12-
- DataTypeChandle:
13-
- super: DataType
14-
- DataTypeEnum:
15-
- super: DataType
16-
- data:
17-
- tid: UP<DataTypeUserDefined>
18-
- in_rangelist: UP<ExprOpenRangeList>
19-
- DataTypeInt:
20-
- super: DataType
21-
- data:
22-
- is_signed: bool
23-
- width_lhs: UP<Expr>
24-
- width_rhs: UP<Expr>
25-
- in_range: UP<ExprDomainOpenRangeList>
26-
- DataTypeString:
27-
- super: DataType
28-
- data:
29-
- has_range: bool
30-
- in_range: list<string>
31-
- DataTypeUserDefined:
32-
- super: DataType
33-
- data:
34-
- is_global: bool
35-
- elems: list<UP<TypeIdentifierElem>>
36-
# - target:
37-
# - is_ctor: false
38-
# - type: SP<RefExpr>
39-
- target_p:
40-
- is_ctor: false
41-
- type: P<ScopeChild>
42-
- init: 0
3+
- DataType:
4+
super: ScopeChild
5+
- DataTypeArray:
6+
super: DataType
7+
data:
8+
- type: "UP<DataType>"
9+
- size: "UP<Expr>"
10+
11+
- DataTypeBool:
12+
super: DataType
13+
14+
- DataTypeChandle:
15+
super: DataType
16+
17+
- DataTypeEnum:
18+
super: DataType
19+
data:
20+
- tid: UP<DataTypeUserDefined>
21+
- in_rangelist: UP<ExprOpenRangeList>
22+
- DataTypeInt:
23+
super: DataType
24+
data:
25+
- is_signed: bool
26+
- width_lhs: UP<Expr>
27+
- width_rhs: UP<Expr>
28+
- in_range: UP<ExprDomainOpenRangeList>
29+
- DataTypeString:
30+
super: DataType
31+
data:
32+
- has_range: bool
33+
- in_range: list<string>
34+
- DataTypeUserDefined:
35+
super: DataType
36+
data:
37+
- is_global: bool
38+
- elems: list<UP<TypeIdentifierElem>>
39+
# - target:
40+
# - is_ctor: false
41+
# - type: SP<RefExpr>
42+
- target_p:
43+
is_ctor: false
44+
type: P<ScopeChild>
45+
init: 0

0 commit comments

Comments
 (0)