Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
elamaunt committed Jun 22, 2021
1 parent 56e1956 commit d5c0a96
Showing 1 changed file with 79 additions and 15 deletions.
94 changes: 79 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,82 @@
# GDShrapt

GDShrapt is object-oriented one-pass parser of GDScript. Also it allows to convert code to C#.
GDShrapt is object-oriented one-pass parser of GDScript. Now the main goal is production-ready parser, lexical analyzer and GDScript-to-C# converter.
The project written in C#, consists of two parts **GDShrapt.Reader** and **GDShrapt.Converter** and free to use.
GDScript is the main language of [Godot Engine](https://github.com/godotengine/godot)

**The project is created on personal initiative and on enthusiasm.**

## GDShrapt.Reader

GDShrapt.Reader allows to build a lexical tree or generate a new code from scratch.

### How to install

Currently available prealpha version from [Nuget](https://www.nuget.org/packages/GDShrapt.Reader).
Currently the latest **2.0.0-alpha version** from [Nuget](https://www.nuget.org/packages/GDShrapt.Reader).

Installation from Nuget console:
```
Install-Package GDShrapt.Reader -Version 1.0.0-prealpha
Install-Package GDShrapt.Reader -Version 2.0.0-alpha
```

### Samples
## Capabilities, plan and what can be parsed

| Capability | Is completed |
| ------------- | ------------- |
| One pass parsing | YES |
| Lexical tree structure | YES |
| Class declaration parsing | YES |
| Methods declaration parsing | YES |
| Enums parsing | YES |
| Atributes declaration parsing | YES |
| Variables declaration parsing | YES |
| Export block parsing | YES |
| Arrays parsing | YES |
| Dictionary parsing | YES |
| 'Match' statement parsing | YES |
| 'For' statement parsing | YES |
| 'While' statement parsing | YES |
| 'If-Elif-Else' statement parsing | YES |
| 'Yield' statement parsing | YES |
| Ternar 'If' expression parsing | YES |
| Signals parsing | YES |
| Strings parsing | YES |
| Numbers parsing | YES |
| Methods calls parsing | YES |
| Single operators parsing | YES |
| Dual operators parsing | YES |
| Static types parsing | YES |
| Expressions priority sorting | YES |
| Basic tokenization managment | YES |
| Save formatting while parsing | YES |
| Save comments while parsing | YES |
| Moving from tokens to parent | YES |
| NodePath and GetNode short syntax parsing | YES |
| Inner class parsing | NOT TESTED |
| Asserts handling | IN PLAN |
| RPC annotations parsing | IN PLAN |
| Syntax errors managment and properly handling | IN PLAN |
| Tree walking and node visiting | IN PLAN |
| Syntax cloning | IN PLAN |
| Syntax factory | IN PLAN |
| Tree diff tool | IN PLAN |

## Version history

#### 2.0.0-alpha
The project is now in Net.Standart 2.1 and was
totally reworked with tokenization layer. The parser now performs token extraction and lexical tree construction at the same time.
No style data loss. Possibility to manage every token in code.
Implemented specific node parsing like NodePath, short form of 'get_node'.
Properly handling of comments and spaces.

#### 1.0.0-prealpha
.NET 5.0 version
Implemented all basic nodes and a lexical tree building with a style data loss.
Has limitations in specific situations.

## Reading samples

### Parse class

GDScript input:

Expand Down Expand Up @@ -80,23 +139,28 @@ Parser usage:
}
```


### Get comments from GDScript code

```csharp
var @class = reader.ParseFileContent(code);

// Add 'using System.Linq;'
var comments = @class.AllTokens
.OfType<GDComment>()
.Select(x => x.ToString()) // Convert token to string
.ToArray();
```

Tree building samples and runtime code generation are coming soon.
For more samples see the [tests](src/GDShrapt.Reader.Tests/ParsingTests.cs).


## GDShrapt.Converter

GDShrapt.Converter allows to convert lexical tree in same C# code.
This project is at very initial stage.

### Samples
### Conversion samples

Not ready.

# Current state

The project is in pre-pre-alpha stage. The reader has some specific limitations on parsing 'match' statements. It will be parsed but without specific node types.
It may be not convenient to handle this nodes by code.

# Current goals

Complete parsing of GDScript without limitations.

0 comments on commit d5c0a96

Please sign in to comment.