Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Roblox
GitHub Repository: Roblox/luau
Path: blob/master/Ast/include/Luau/PrettyPrinter.h
2727 views
1
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2
#pragma once
3
4
#include "Luau/Location.h"
5
#include "Luau/ParseOptions.h"
6
#include "Luau/ParseResult.h"
7
8
#include <string>
9
10
namespace Luau
11
{
12
class AstNode;
13
class AstStatBlock;
14
15
struct PrettyPrintResult
16
{
17
std::string code;
18
Location errorLocation;
19
std::string parseError; // Nonempty if the transpile failed
20
};
21
22
std::string toString(AstNode* node);
23
void dump(AstNode* node);
24
25
// Never fails on a well-formed AST
26
std::string prettyPrint(AstStatBlock& ast);
27
std::string prettyPrintWithTypes(AstStatBlock& block);
28
std::string prettyPrintWithTypes(AstStatBlock& block, const CstNodeMap& cstNodeMap);
29
30
// Only fails when parsing fails
31
PrettyPrintResult prettyPrint(std::string_view source, ParseOptions options = ParseOptions{}, bool withTypes = false);
32
33
} // namespace Luau
34
35