Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Library for lexing and parsing D source code

License

NotificationsYou must be signed in to change notification settings

dlang-community/libdparse

Repository files navigation

Library for lexing and parsing D source code.

Documentation

Online documentation is availablehere.

A HTML version of libdparse's grammar is alsoautomatically generated.

Testing

CI Status

Tests are present in the test directory. To run them execute the run_tests.shscript. 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;importstd.stdio,std.range;classTestVisitor :ASTVisitor{alias visit = ASTVisitor.visit;int indentLevel;overridevoidvisit(const FunctionDeclaration decl)    {        writeln(''.repeat(indentLevel*4), decl.name.text);        indentLevel++;scope (exit) indentLevel--;        decl.accept(this);    }}voidmain(){import dparse.lexer;import dparse.parser : parseModule;import dparse.rollback_allocator : RollbackAllocator;auto sourceCode = q{voidfoo()@safe {voidbar();        }    };    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

About

Library for lexing and parsing D source code

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors38

Languages


[8]ページ先頭

©2009-2025 Movatter.jp