libdparse

Library for lexing and parsing D source code

Github星跟蹤圖

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

CI Status

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

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);
}

Open on run.dlang.io

主要指標

概覽
名稱與所有者socialtables/react-user-tour
主編程語言JavaScript
編程語言D (語言數: 1)
平台
許可證Apache License 2.0
所有者活动
創建於2015-10-27 19:45:21
推送於2023-04-13 19:59:14
最后一次提交
發布數16
最新版本名稱v3.0.0 (發布於 2017-05-26 10:55:04)
第一版名稱v1.0.0 (發布於 2015-10-30 16:06:47)
用户参与
星數152
關注者數37
派生數37
提交數88
已啟用問題?
問題數21
打開的問題數6
拉請求數19
打開的拉請求數0
關閉的拉請求數1
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?