Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#5573: Experimental PEGTL integration. Parsing works but speed (just …
…cutting out the def blocks) is one order of magnitude than using the DefBlockTokeniser, taking almost 30 seconds here in my debug environment.
- Loading branch information
1 parent
907fb02
commit 6c46edd
Showing
5 changed files
with
151 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#pragma once | ||
|
||
#include <tao/pegtl.hpp> | ||
|
||
namespace shaders | ||
{ | ||
|
||
namespace parser | ||
{ | ||
|
||
using namespace tao; | ||
using namespace tao::pegtl; | ||
|
||
struct Nothing : space {}; | ||
|
||
struct TableKeywordPlusSpace : seq<pegtl::string<'t', 'a', 'b', 'l', 'e'>, space> {}; | ||
|
||
struct DeclName : plus<alnum, plus<sor<alnum, one<'/', '_'>>>> {}; | ||
|
||
struct LineComment : until<eolf> {}; | ||
struct BlockComment : until<pegtl::string<'*', '/'>> {}; | ||
|
||
struct Comment : if_must<pegtl::string<'/', '/'>, LineComment> {}; | ||
struct CommentBlock : if_must<pegtl::string<'/', '*'>, BlockComment> {}; | ||
|
||
struct BlockStart : one<'{'> {}; | ||
struct BlockEnd : one<'}'> {}; | ||
|
||
struct BlockContents : not_one<'{', '}'> {}; | ||
|
||
struct BlockDefinition : seq<BlockStart, star<sor<BlockContents, BlockDefinition>>, BlockEnd> {}; | ||
|
||
struct MaterialBlockDefinition : seq<BlockStart, star<sor<BlockContents, BlockDefinition>>, BlockEnd> {}; | ||
|
||
struct MaterialDeclaration : if_must<DeclName, star<sor<space, Comment, CommentBlock>>, MaterialBlockDefinition> {}; | ||
|
||
struct TableDeclaration : if_must<TableKeywordPlusSpace, DeclName, star<sor<space, Comment, CommentBlock>>, BlockDefinition> {}; | ||
|
||
// Any possible element of a material file (Tables, Materials, Comments and plain whitespace) | ||
struct Anything : sor<Nothing, TableDeclaration, MaterialDeclaration, Comment, CommentBlock> {}; | ||
|
||
// A Material has no required elements, it can include anything (including nothing) | ||
struct MaterialFile : until<eof, Anything> {}; | ||
|
||
template<typename Rule> struct MaterialFileSelector : std::true_type {}; | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ImportGroup Label="PropertySheets" /> | ||
<PropertyGroup Label="UserMacros" /> | ||
<PropertyGroup /> | ||
<ItemDefinitionGroup> | ||
<ClCompile> | ||
<AdditionalIncludeDirectories>$(DarkRadiantRoot)\w32deps\pegtl\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||
</ClCompile> | ||
</ItemDefinitionGroup> | ||
<ItemGroup /> | ||
</Project> |