You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An easy, fast, and robust library to parse C/C++ source.
8
+
An easy, fast, and robust library to parse C/C++ source code.
9
9
10
10
## Features
11
-
- No pre-processing, and preprocessors are part of the ast.
12
-
-Most comments are preserved too.
13
-
-Developed from scratch and uses back-tracking yacc (BtYacc) to write C++ grammer, that means**no dependency on libclang**.
14
-
-The result of parsing is an AST where elements of a file are arranged in a tree.
15
-
-Minimum dependency. Only external dependency is a [lexer](https://github.com/westes/flex)which is by default available on unix like platforms (Linux, Mac, etc.) and [Flex for Windows](http://gnuwin32.sourceforge.net/packages/flex.htm) is bundled with the project so it works out of thebox on all Windows platforms too.
16
-
-Parsing of multi-file program is supported too.
17
-
18
-
## Motivation
11
+
- No preprocessing; preprocessor constructs are part of the AST.
12
+
-Preserves most comments.
13
+
-Implemented from scratch using backtracking Yacc (BtYacc), so**no dependency on libclang**.
14
+
-Parses into a structured AST where file elements form a tree.
15
+
-Minimal dependencies: [Flex](https://github.com/westes/flex) on Unix-like platforms (Linux, macOS, etc.). On Windows, [Flex for Windows](http://gnuwin32.sourceforge.net/packages/flex.htm) is bundled for out-of-the-box usage.
16
+
-Supports parsing multi-file programs.
17
+
18
+
## Motivation
19
19
CppParser can be used to build tools that need parsing of C/C++ files.
20
-
I am using it to develop [cib](https://github.com/satya-das/cib/) which implements ABIstable SDK architecture for C++ library.
20
+
It is also used to develop [cib](https://github.com/satya-das/cib/), which implements ABI-stable SDK architecture for C++ libraries.
21
21
22
22
## Example
23
23
24
-
To begin with we will see an example of parsing a hello-world program and see what is the AST that `CppParser` creates:
24
+
To begin with we will see an example of parsing a hello-world program and see the AST that `CppParser` creates:
25
25
```c++
26
26
#include<iostream>
27
27
@@ -34,11 +34,11 @@ int main()
34
34
35
35
```
36
36
37
-
For the above hello-world program we can expect that when it is parsed the generated AST should look like following:
37
+
For the above hello-world program we can expect the generated AST to look like the following:
38
38

39
39
40
-
So, how we are going to access these elements of AST using `CppParser`?
41
-
Below is the program written as unit-test for validating the correctness of generated AST:
40
+
So, how do we access these elements of AST using `CppParser`?
41
+
Below is the program written as a unittest for validating the correctness of the generated AST:
42
42
43
43
```c++
44
44
#include<catch/catch.hpp>
@@ -86,9 +86,9 @@ TEST_CASE("Parsing hello world program")
86
86
87
87
```
88
88
89
-
**This example is a real one and is part of actual unit test of CppParser**.
89
+
**This example is real and is part of the actual unit tests for CppParser**.
90
90
91
-
For AST traversing, see the [CppWriter](cppwriter), that uses the generated AST to create files.
91
+
For AST traversal, see [CppWriter](cppwriter), which uses the generated AST to create files.
92
92
93
93
## Building CppParser
94
94
@@ -120,15 +120,15 @@ ninja
120
120
121
121
## For contributors who need to run tests
122
122
123
-
Make sure you also clone the dependencies. Run the following command in the parent directory of root of the`cppparser`.
123
+
Make sure you also clone the dependencies. Run the following command in the parent directory of the root of `cppparser`.
124
124
125
125
```sh
126
126
git clone https://github.com/satya-das/common.git
127
127
```
128
128
129
-
After this command the `common` and `cppparser` should be in the same folder.
129
+
After this command the `common` and `cppparser`folders should be side by side.
An easy, fast, and robust library to parse C/C++ source.
8
+
An easy, fast, and robust library to parse C/C++ source code.
9
9
10
10
## Features
11
-
- No pre-processing, and preprocessors are part of the ast.
12
-
- Most comments are preserved too.
13
-
- Developed from scratch and uses back-tracking yacc (BtYacc) to write C++ grammer, that means **no dependency on libclang**.
14
-
- The result of parsing is an AST where elements of a file are arranged in a tree.
15
-
- Minimum dependency. Only external dependency is a [lexer](https://github.com/westes/flex) which is by default available on unix like platforms (Linux, Mac, etc.) and [Flex for Windows](http://gnuwin32.sourceforge.net/packages/flex.htm) is bundled with the project so it works out of thebox on all Windows platforms too.
16
-
- Parsing of multi-file program is supported too.
17
-
18
-
## Motivation
11
+
- No preprocessing; preprocessor constructs are part of the AST.
12
+
- Preserves most comments.
13
+
- Implemented from scratch using backtracking Yacc (BtYacc), so **no dependency on libclang**.
14
+
- Parses into a structured AST where file elements form a tree.
15
+
- Minimal dependencies: [Flex](https://github.com/westes/flex) on Unix-like platforms (Linux, macOS, etc.). On Windows, [Flex for Windows](http://gnuwin32.sourceforge.net/packages/flex.htm) is bundled for out-of-the-box usage.
16
+
- Supports parsing multi-file programs.
17
+
18
+
## Motivation
19
19
CppParser can be used to build tools that need parsing of C/C++ files.
20
-
I am using it to develop [cib](https://github.com/satya-das/cib/) which implements ABIstable SDK architecture for C++ library.
20
+
It is also used to develop [cib](https://github.com/satya-das/cib/), which implements ABI-stable SDK architecture for C++ libraries.
21
21
22
22
## Example
23
23
24
-
To begin with we will see an example of parsing a hello-world program and see what is the AST that `CppParser` creates:
24
+
To begin with we will see an example of parsing a hello-world program and see the AST that `CppParser` creates:
For the above hello-world program we can expect that when it is parsed the generated AST should look like following:
27
+
For the above hello-world program we can expect the generated AST to look like the following:
28
28

29
29
30
-
So, how we are going to access these elements of AST using `CppParser`?
31
-
Below is the program written as unit-test for validating the correctness of generated AST:
30
+
So, how do we access these elements of AST using `CppParser`?
31
+
Below is the program written as a unittest for validating the correctness of the generated AST:
0 commit comments