dlang-community / Libdparse
Licence: bsl-1.0
Library for lexing and parsing D source code
Stars: ✭ 91
Projects that are alternatives of or similar to Libdparse
Escaya
An blazing fast 100% spec compliant, incremental javascript parser written in Typescript
Stars: ✭ 217 (+138.46%)
Mutual labels: ast, syntax-tree, parser, parsing
Metric Parser
📜 AST-based advanced mathematical parser written by Typescript.
Stars: ✭ 26 (-71.43%)
Mutual labels: ast, syntax-tree, parser
Meriyah
A 100% compliant, self-hosted javascript parser - https://meriyah.github.io/meriyah
Stars: ✭ 690 (+658.24%)
Mutual labels: ast, parser, parsing
Astexplorer.app
https://astexplorer.net with ES Modules support and Hot Reloading
Stars: ✭ 65 (-28.57%)
Mutual labels: ast, syntax-tree, parser
Graphql Go Tools
Tools to write high performance GraphQL applications using Go/Golang.
Stars: ✭ 96 (+5.49%)
Mutual labels: ast, parser, parsing
Kgt
BNF wrangling and railroad diagrams
Stars: ✭ 312 (+242.86%)
Mutual labels: syntax-tree, parser, parsing
Cppsharp
Tools and libraries to glue C/C++ APIs to high-level languages
Stars: ✭ 2,221 (+2340.66%)
Mutual labels: syntax-tree, parser, parsing
Javaparser
Java 1-15 Parser and Abstract Syntax Tree for Java, including preview features to Java 13
Stars: ✭ 3,972 (+4264.84%)
Mutual labels: ast, syntax-tree, parser
Esprima
ECMAScript parsing infrastructure for multipurpose analysis
Stars: ✭ 6,391 (+6923.08%)
Mutual labels: ast, parser, parsing
Diffsitter
A tree-sitter based AST difftool to get meaningful semantic diffs
Stars: ✭ 89 (-2.2%)
Mutual labels: ast, parser
Spoon
Spoon is a metaprogramming library to analyze and transform Java source code (up to Java 15). 🥄 is made with ❤️, 🍻 and ✨. It parses source files to build a well-designed AST with powerful analysis and transformation API.
Stars: ✭ 1,078 (+1084.62%)
Mutual labels: ast, parser
Formula Parser
Parsing and evaluating mathematical formulas given as strings.
Stars: ✭ 62 (-31.87%)
Mutual labels: parser, parsing
Errorstacks
Tiny library to parse error stack traces
Stars: ✭ 29 (-68.13%)
Mutual labels: parser, parsing
Csstree
A tool set for CSS including fast detailed parser, walker, generator and lexer based on W3C specs and browser implementations
Stars: ✭ 1,121 (+1131.87%)
Mutual labels: ast, parser
Jkt
Simple helper to parse JSON based on independent schema
Stars: ✭ 22 (-75.82%)
Mutual labels: parser, parsing
Parser Javascript
Browser sniffing gone too far — A useragent parser library for JavaScript
Stars: ✭ 66 (-27.47%)
Mutual labels: parser, parsing
Charly Vm
Fibers, Closures, C-Module System | NaN-boxing, bytecode-VM written in C++
Stars: ✭ 66 (-27.47%)
Mutual labels: ast, parser
Php Svg Lib
SVG file parsing / rendering library
Stars: ✭ 1,146 (+1159.34%)
Mutual labels: parser, parsing
libdparse
Library for lexing and parsing D source code.
Documentation
Online documentation is available here.
A HTML version of libdparse's grammar is also automatically generated.
Testing
Tests are present in the test directory. To run them execute the run_tests.sh script. Running the tests on Windows is not currently supported.
Differences with the official grammar
- Static array initialization syntax. Due to ambiguities they are supported when the expression that gives the elements indexes is not an array. In the opposite case they are parsed as associative array literals.
Unsupported Syntax
- Class allocators. These are deprecated in D2.
- Class deallocators. These are deprecated in D2.
Example
/+dub.sdl:
dependency "libdparse" version="~>0.7"
+/
import dparse.ast;
import std.stdio, std.range;
class TestVisitor : ASTVisitor
{
alias visit = ASTVisitor.visit;
int indentLevel;
override void visit(const FunctionDeclaration decl)
{
writeln(' '.repeat(indentLevel * 4), decl.name.text);
indentLevel++;
scope (exit) indentLevel--;
decl.accept(this);
}
}
void main()
{
import dparse.lexer;
import dparse.parser : parseModule;
import dparse.rollback_allocator : RollbackAllocator;
auto sourceCode = q{
void foo() @safe {
void bar();
}
};
LexerConfig config;
auto cache = StringCache(StringCache.defaultBucketCount);
auto tokens = getTokensForParser(sourceCode, config, &cache);
RollbackAllocator rba;
auto m = parseModule(tokens, "test.d", &rba);
auto visitor = new TestVisitor();
visitor.visit(m);
}
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].