mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:47:34 +00:00
LibGLSL: Add initial GLSL parser implementation
This commit is contained in:
parent
0b6424d883
commit
29972876e4
11 changed files with 4093 additions and 0 deletions
44
Userland/Libraries/LibGLSL/Token.cpp
Normal file
44
Userland/Libraries/LibGLSL/Token.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright (c) 2023, the SerenityOS developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "Token.h"
|
||||
#include <AK/String.h>
|
||||
|
||||
namespace GLSL {
|
||||
|
||||
bool Position::operator<(Position const& other) const
|
||||
{
|
||||
return line < other.line || (line == other.line && column < other.column);
|
||||
}
|
||||
|
||||
bool Position::operator>(Position const& other) const
|
||||
{
|
||||
return !(*this < other) && !(*this == other);
|
||||
}
|
||||
|
||||
bool Position::operator==(Position const& other) const
|
||||
{
|
||||
return line == other.line && column == other.column;
|
||||
}
|
||||
|
||||
bool Position::operator<=(Position const& other) const
|
||||
{
|
||||
return !(*this > other);
|
||||
}
|
||||
|
||||
ErrorOr<String> Token::to_string() const
|
||||
{
|
||||
return String::formatted("{} {}:{}-{}:{} ({})", type_to_string(m_type), start().line, start().column, end().line, end().column, text());
|
||||
}
|
||||
|
||||
ErrorOr<String> Token::type_as_string() const
|
||||
{
|
||||
auto str = type_to_string(m_type);
|
||||
auto view = StringView(str, strlen(str));
|
||||
return String::from_utf8(view);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue