summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-parser.h
blob: 5ca1b9f695db7cc2573375c4c6d2cb2c9e9061c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef SLANG_PARSER_H
#define SLANG_PARSER_H

#include "../compiler-core/slang-lexer.h"
#include "slang-compiler.h"
#include "slang-syntax.h"

namespace Slang
{
// Parse a source file into an existing translation unit
void parseSourceFile(
    ASTBuilder* astBuilder,
    TranslationUnitRequest* translationUnit,
    SourceLanguage sourceLanguage,
    TokenSpan const& tokens,
    DiagnosticSink* sink,
    Scope* outerScope,
    ContainerDecl* parentDecl);

Expr* parseTermFromSourceFile(
    ASTBuilder* astBuilder,
    TokenSpan const& tokens,
    DiagnosticSink* sink,
    Scope* outerScope,
    NamePool* namePool,
    SourceLanguage sourceLanguage);

struct SemanticsVisitor;

Stmt* parseUnparsedStmt(
    ASTBuilder* astBuilder,
    SemanticsVisitor* semantics,
    TranslationUnitRequest* translationUnit,
    SourceLanguage sourceLanguage,
    TokenSpan const& tokens,
    DiagnosticSink* sink,
    Scope* currentScope,
    Scope* outerScope);

ModuleDecl* populateBaseLanguageModule(ASTBuilder* astBuilder, Scope* scope);

/// Information used to set up SyntaxDecl. Such decls
/// when correctly setup define a callback. For some of the callbacks it's necessary
/// for the `parseUserData` to be set the the associated classInfo
struct SyntaxParseInfo
{
    const char* keywordName;         ///< The keyword associated with this parse
    SyntaxParseCallback callback;    ///< The callback to apply to the parse
    SyntaxClass<NodeBase> classInfo; ///<
};

/// Get all of the predefined SyntaxParseInfos
ConstArrayView<SyntaxParseInfo> getSyntaxParseInfos();

/// Assumes the userInfo is the ReflectClassInfo
NodeBase* parseSimpleSyntax(Parser* parser, void* userData);

} // namespace Slang

#endif