- Notifications
You must be signed in to change notification settings - Fork60
Library for lexing and parsing D source code
License
NotificationsYou must be signed in to change notification settings
dlang-community/libdparse
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Library for lexing and parsing D source code.
Online documentation is availablehere.
A HTML version of libdparse's grammar is alsoautomatically generated.
Tests are present in the test directory. To run them execute the run_tests.shscript. Running the tests on Windows is not currently supported.
- 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.
- Class allocators. These are deprecated in D2.
- Class deallocators. These are deprecated in D2.
/+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);}
About
Library for lexing and parsing D source code
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.