sillyyyy :P
All checks were successful
/ test (push) Successful in 54s

This commit is contained in:
xqtc161 2024-07-11 12:03:42 +02:00
parent 9b00529bbd
commit c6b35b795b
3 changed files with 48 additions and 6 deletions

View file

@ -0,0 +1,6 @@
on: [push]
jobs:
test:
runs-on: docker
steps:
- run: echo All Good

View file

@ -81,11 +81,11 @@
"locked": {
"lastModified": 1,
"narHash": "sha256-8wkkYGr1dPSnX9oVMX8D6dTOROXKOYpBTKfriA0sEBI=",
"path": "/nix/store/z4by2bx56bm456s77isfwvr59mqg9brg-source/flake.systems.nix",
"path": "/nix/store/7rlwm9hr4df367974cszjpbmjbd36jvn-source/flake.systems.nix",
"type": "path"
},
"original": {
"path": "/nix/store/z4by2bx56bm456s77isfwvr59mqg9brg-source/flake.systems.nix",
"path": "/nix/store/7rlwm9hr4df367974cszjpbmjbd36jvn-source/flake.systems.nix",
"type": "path"
}
},

View file

@ -1,26 +1,62 @@
// WIP THAT SHIT STILL WONKY AF
//! A simple lexer for GLSL.
//!
//! Adheres to the GLSL 440. Read the spec
//! [here](https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.40.pdf).
//! ## Example
//! ```
//! use glsl_lexer::*;
//!
//! fn main() {
//! let source = r#"
//! #version 440
//! uniform float time;
//! void main() {
//! gl_FragColor = vec4(1.0, 0.5, 0.2, 1.0);
//! }
//! "#;
//! let mut lexer = glsl_lexer::Lexer::new(&source);
//! let tokens = lexer.get_tokens();
//! dbg!("{}", tokens);
//! }
//! ```
//! # WIP THAT SHIT STILL WONKY AF
#[derive(Debug, PartialEq)]
pub enum Token {
/// Something like `float`
Identifier(String),
/// Something like `uniform`
Keyword(String),
/// Something like `13`
IntegerLiteral(i64),
/// Something like `3.5` or `.5`
FloatLiteral(f64),
/// Something like `+`
Operator(String),
/// Something like `{`
Symbol(char),
/// Should be self-explanatory
Whitespace,
/// Something like `// uwu`
Comment(String),
/// Shrouded in mystery
Unknown(char),
/// End Of File
EOF,
}
pub struct Lexer {
input: Vec<char>,
position: usize,
current_char: Option<char>,
/// GLSL source
pub input: Vec<char>,
/// Position in source
pub position: usize,
/// [`char`] under position
pub current_char: Option<char>,
}
impl Lexer {
/// Instantiates the [`Lexer`]
pub fn new(input: &str) -> Self {
let mut lexer = Lexer {
input: input.chars().collect(),