Skip to content

Commit f9e9304

Browse files
committed
Fix auto code-formatter disaster
1 parent 51a6d74 commit f9e9304

4 files changed

Lines changed: 227 additions & 421 deletions

File tree

lib/include/pl/core/lexer.hpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@
1313

1414
#include <pl/core/errors/result.hpp>
1515

16-
namespace pl::core
17-
{
16+
namespace pl::core {
1817

19-
class Lexer : err::ErrorCollector
20-
{
18+
class Lexer : err::ErrorCollector {
2119
public:
2220
Lexer() = default;
2321

@@ -26,7 +24,7 @@ namespace pl::core
2624

2725
private:
2826
[[nodiscard]] char peek(size_t p = 1) const;
29-
bool processToken(auto parserFunction, const std::string_view &identifier);
27+
bool processToken(auto parserFunction, const std::string_view& identifier);
3028
Location location() override;
3129

3230
std::optional<char> parseCharacter();
@@ -49,12 +47,11 @@ namespace pl::core
4947
std::optional<double> parseFloatingPoint(std::string_view literal, char suffix);
5048
std::optional<u128> parseInteger(std::string_view literal);
5149

52-
Token makeToken(const Token &token, size_t length = 1);
53-
static Token makeTokenAt(const Token &token, Location &location, size_t length = 1);
54-
void addToken(const Token &token);
50+
Token makeToken(const Token& token, size_t length = 1);
51+
static Token makeTokenAt(const Token& token, Location &location, size_t length = 1);
52+
void addToken(const Token& token);
5553

56-
bool skipLineEnding()
57-
{
54+
bool skipLineEnding() {
5855
char ch = m_sourceCode[m_cursor];
5956
if (ch == '\n') {
6057
m_tabCompensation = 0;

lib/include/pl/pattern_language.hpp

Lines changed: 45 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,17 @@
2727
namespace pl
2828
{
2929

30-
namespace core
31-
{
30+
namespace core {
3231
class Preprocessor;
3332
class Lexer;
3433
class Parser;
3534
class Validator;
3635
class Evaluator;
3736

38-
namespace ast
39-
{
40-
class ASTNode;
41-
}
37+
namespace ast { class ASTNode; }
4238
}
4339

44-
namespace ptrn
45-
{
40+
namespace ptrn {
4641
class Pattern;
4742
class IIterable;
4843
}
@@ -52,34 +47,33 @@ namespace pl
5247
* @note The runtime can be reused for multiple executions, but if you want to execute multiple files at once, you should create a new runtime for each file
5348
* @note Things like the abort function and getter functions to check if the runtime is currently executing code are thread safe. However, the runtime is not thread safe in general
5449
*/
55-
class PatternLanguage
56-
{
50+
class PatternLanguage {
5751
public:
52+
5853
/**
5954
* @brief Construct a new Pattern Language object
6055
* @param addLibStd Whether to add the standard library functions to the language
6156
*/
6257
explicit PatternLanguage(bool addLibStd = true);
6358
~PatternLanguage();
6459

65-
PatternLanguage(const PatternLanguage &) = delete;
60+
PatternLanguage(const PatternLanguage&) = delete;
6661
PatternLanguage(PatternLanguage &&other) noexcept;
6762

68-
struct Internals
69-
{
63+
struct Internals {
7064
std::unique_ptr<core::Preprocessor> preprocessor;
71-
std::unique_ptr<core::Lexer> lexer;
72-
std::unique_ptr<core::Parser> parser;
73-
std::unique_ptr<core::Validator> validator;
74-
std::unique_ptr<core::Evaluator> evaluator;
65+
std::unique_ptr<core::Lexer> lexer;
66+
std::unique_ptr<core::Parser> parser;
67+
std::unique_ptr<core::Validator> validator;
68+
std::unique_ptr<core::Evaluator> evaluator;
7569
};
7670

7771
/**
78-
* @brief Lexes and preprocesses a pattern language code string and returns a token stream
79-
* @param code Code to preprocess
80-
* @param source Source of the code
81-
* @return token stream
82-
*/
72+
* @brief Lexes and preprocesses a pattern language code string and returns a token stream
73+
* @param code Code to preprocess
74+
* @param source Source of the code
75+
* @return token stream
76+
*/
8377
[[nodiscard]] std::optional<std::vector<pl::core::Token>> preprocessString(const std::string &code, const std::string &source);
8478

8579
/**
@@ -124,7 +118,7 @@ namespace pl
124118
* @param source the source of the code
125119
* @return the source that was added or that already existed
126120
*/
127-
[[nodiscard]] api::Source *addVirtualSource(const std::string &code, const std::string &source, bool mainSource = false) const;
121+
[[nodiscard]] api::Source* addVirtualSource(const std::string& code, const std::string& source, bool mainSource = false) const;
128122

129123
/**
130124
* @brief Aborts the currently running execution asynchronously
@@ -138,7 +132,7 @@ namespace pl
138132
* @param readFunction Function to read data from the data source
139133
* @param writerFunction Optional function to write data to the data source
140134
*/
141-
void setDataSource(u64 baseAddress, u64 size, std::function<void(u64, u8 *, size_t)> readFunction, std::optional<std::function<void(u64, const u8 *, size_t)>> writerFunction = std::nullopt);
135+
void setDataSource(u64 baseAddress, u64 size, std::function<void(u64, u8*, size_t)> readFunction, std::optional<std::function<void(u64, const u8*, size_t)>> writerFunction = std::nullopt);
142136

143137
/**
144138
* @brief Sets the base address of the data source
@@ -195,13 +189,13 @@ namespace pl
195189
* @brief Sets the include paths for where to look for include files
196190
* @param paths List of paths to look in
197191
*/
198-
void setIncludePaths(const std::vector<std::fs::path> &paths);
192+
void setIncludePaths(const std::vector<std::fs::path>& paths);
199193

200194
/**
201195
* @brief Sets the source resolver of the pattern language
202196
* @param resolver Resolver to use
203197
*/
204-
void setResolver(const core::Resolver &resolver);
198+
void setResolver(const core::Resolver& resolver);
205199

206200
/**
207201
* @brief Registers a callback to be called when a dangerous function is being executed
@@ -228,7 +222,7 @@ namespace pl
228222
* @brief Gets the errors that occurred during the last compilation (e.g. parseString())
229223
* @return A vector of errors (can be empty if no errors occurred)
230224
*/
231-
[[nodiscard]] const std::vector<core::err::CompileError> &getCompileErrors() const;
225+
[[nodiscard]] const std::vector<core::err::CompileError>& getCompileErrors() const;
232226

233227
/**
234228
* @brief Gets a map of all out variables and their values that have been defined in the last execution
@@ -253,13 +247,13 @@ namespace pl
253247
* @param id ID of the section
254248
* @return Memory of the section
255249
*/
256-
[[nodiscard]] const std::vector<u8> &getSection(u64 id) const;
250+
[[nodiscard]] const std::vector<u8>& getSection(u64 id) const;
257251

258252
/**
259253
* @brief Gets all custom sections that were created
260254
* @return Custom sections
261255
*/
262-
[[nodiscard]] const std::map<u64, api::Section> &getSections() const;
256+
[[nodiscard]] const std::map<u64, api::Section>& getSections() const;
263257

264258
/**
265259
* @brief Gets all patterns that were created in the given section
@@ -293,17 +287,15 @@ namespace pl
293287
* @brief Checks whether the runtime is currently running
294288
* @return True if the runtime is running, false otherwise
295289
*/
296-
[[nodiscard]] bool isRunning() const
297-
{
290+
[[nodiscard]] bool isRunning() const {
298291
return this->m_running;
299292
}
300293

301294
/**
302295
* @brief Gets the time the last execution took
303296
* @return Time the last execution took
304297
*/
305-
[[nodiscard]] double getLastRunningTime() const
306-
{
298+
[[nodiscard]] double getLastRunningTime() const {
307299
return this->m_runningTime;
308300
}
309301

@@ -339,41 +331,37 @@ namespace pl
339331
* @warning Generally this should only be used by "IDEs" or other tools that need to access the internals of the pattern language
340332
* @return Internals
341333
*/
342-
[[nodiscard]] const Internals &getInternals() const
334+
[[nodiscard]] const Internals& getInternals() const
343335
{
344336
return this->m_internals;
345337
}
346338

347-
[[nodiscard]] const std::map<std::string, std::string> &getDefines() const
339+
[[nodiscard]] const std::map<std::string, std::string>& getDefines() const
348340
{
349341
return this->m_defines;
350342
}
351343

352-
[[nodiscard]] const std::vector<std::shared_ptr<core::ast::ASTNode>> getAST() const
353-
{
344+
[[nodiscard]] const std::vector<std::shared_ptr<core::ast::ASTNode>> getAST() const {
354345
return this->m_currAST;
355346
}
356347

357-
[[nodiscard]] const std::map<std::string, api::PragmaHandler> &getPragmas() const
358-
{
348+
[[nodiscard]] const std::map<std::string, api::PragmaHandler> &getPragmas() const {
359349
return this->m_pragmas;
360350
}
361351

362352
/**
363353
* @brief Gets the source resolver of the pattern language
364354
* @return Mutable reference to the Resolver
365355
*/
366-
[[nodiscard]] core::Resolver &getResolver()
367-
{
356+
[[nodiscard]] core::Resolver& getResolver() {
368357
return this->m_resolvers;
369358
}
370359

371360
/**
372361
* @brief Gets the source resolver of the pattern language
373362
* @return Resolver
374363
*/
375-
[[nodiscard]] const core::Resolver &getResolver() const
376-
{
364+
[[nodiscard]] const core::Resolver& getResolver() const {
377365
return this->m_resolvers;
378366
}
379367

@@ -382,41 +370,37 @@ namespace pl
382370
* @note This is useful for built-in functions that need to clean up their state
383371
* @param callback Callback to call
384372
*/
385-
void addCleanupCallback(const std::function<void(PatternLanguage &)> &callback)
386-
{
373+
void addCleanupCallback(const std::function<void(PatternLanguage&)> &callback) {
387374
this->m_cleanupCallbacks.push_back(callback);
388375
}
389376

390377
/**
391378
* @brief Checks whether the patterns are valid
392379
* @return True if the patterns are valid, false otherwise
393380
*/
394-
[[nodiscard]] bool arePatternsValid() const
395-
{
381+
[[nodiscard]] bool arePatternsValid() const {
396382
return this->m_patternsValid;
397383
}
398384

399385
/**
400386
* @brief Gets the current run id
401387
* @return Run id
402388
*/
403-
[[nodiscard]] u64 getRunId() const
404-
{
389+
[[nodiscard]] u64 getRunId() const {
405390
return this->m_runId;
406391
}
407392

408-
[[nodiscard]] const std::atomic<u64> &getLastReadAddress() const;
409-
[[nodiscard]] const std::atomic<u64> &getLastWriteAddress() const;
410-
[[nodiscard]] const std::atomic<u64> &getLastPatternPlaceAddress() const;
393+
[[nodiscard]] const std::atomic<u64>& getLastReadAddress() const;
394+
[[nodiscard]] const std::atomic<u64>& getLastWriteAddress() const;
395+
[[nodiscard]] const std::atomic<u64>& getLastPatternPlaceAddress() const;
411396

412397
PatternLanguage cloneRuntime() const;
413398

414-
[[nodiscard]] bool isSubRuntime() const
415-
{
399+
[[nodiscard]] bool isSubRuntime() const {
416400
return this->m_subRuntime;
417401
}
418402

419-
[[nodiscard]] const std::set<pl::ptrn::Pattern *> &getPatternsWithAttribute(const std::string &attribute) const;
403+
[[nodiscard]] const std::set<pl::ptrn::Pattern *>& getPatternsWithAttribute(const std::string &attribute) const;
420404

421405
private:
422406
void flattenPatterns();
@@ -435,30 +419,29 @@ namespace pl
435419

436420
std::map<u64, std::vector<std::shared_ptr<ptrn::Pattern>>> m_patterns;
437421
std::atomic<bool> m_flattenedPatternsValid = false;
438-
std::map<u64, wolv::container::IntervalTree<ptrn::Pattern *, u64, 5>> m_flattenedPatterns;
422+
std::map<u64, wolv::container::IntervalTree<ptrn::Pattern*, u64, 5>> m_flattenedPatterns;
439423
std::thread m_flattenThread;
440-
std::vector<std::function<void(PatternLanguage &)>> m_cleanupCallbacks;
424+
std::vector<std::function<void(PatternLanguage&)>> m_cleanupCallbacks;
441425
std::vector<std::shared_ptr<core::ast::ASTNode>> m_currAST;
442426

443427
std::atomic<bool> m_running = false;
444428
std::atomic<bool> m_patternsValid = false;
445429
std::atomic<bool> m_aborted = false;
446-
std::atomic<u64> m_runId = 0;
430+
std::atomic<u64> m_runId = 0;
447431

448432
std::optional<u64> m_startAddress;
449433
std::endian m_defaultEndian = std::endian::little;
450434
double m_runningTime = 0;
451435

452436
u64 m_dataBaseAddress;
453437
u64 m_dataSize;
454-
std::function<void(u64, u8 *, size_t)> m_dataReadFunction;
455-
std::optional<std::function<void(u64, const u8 *, size_t)>> m_dataWriteFunction;
438+
std::function<void(u64, u8*, size_t)> m_dataReadFunction;
439+
std::optional<std::function<void(u64, const u8*, size_t)>> m_dataWriteFunction;
456440

457441
std::function<bool()> m_dangerousFunctionCallCallback;
458442
core::LogConsole::Callback m_logCallback;
459443

460-
struct Function
461-
{
444+
struct Function {
462445
api::Namespace nameSpace;
463446
std::string name;
464447
api::FunctionParameterCount parameterCount;

0 commit comments

Comments
 (0)