Added support for CRLF windows line endings #11

Merged
dbidwell merged 1 commits from 41-support-windows-crlf-line-endings into master 2025-12-29 12:33:00 -07:00
6 changed files with 26 additions and 5 deletions

View File

@@ -1,5 +1,9 @@
# Changelog # Changelog
[0.4.7]
- Added support for Windows CRLF endings
[0.4.6] [0.4.6]
- Fixed bug in compiler where you were unable to assign a `const` value to - Fixed bug in compiler where you were unable to assign a `const` value to

View File

@@ -2,7 +2,7 @@
<ModMetadata xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ModMetadata xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Name>Slang</Name> <Name>Slang</Name>
<Author>JoeDiertay</Author> <Author>JoeDiertay</Author>
<Version>0.4.6</Version> <Version>0.4.7</Version>
<Description> <Description>
[h1]Slang: High-Level Programming for Stationeers[/h1] [h1]Slang: High-Level Programming for Stationeers[/h1]

View File

@@ -39,7 +39,7 @@ namespace Slang
{ {
public const string PluginGuid = "com.biddydev.slang"; public const string PluginGuid = "com.biddydev.slang";
public const string PluginName = "Slang"; public const string PluginName = "Slang";
public const string PluginVersion = "0.4.6"; public const string PluginVersion = "0.4.7";
private static Harmony? _harmony; private static Harmony? _harmony;

View File

@@ -930,7 +930,7 @@ checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e"
[[package]] [[package]]
name = "slang" name = "slang"
version = "0.4.6" version = "0.4.7"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"clap", "clap",

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "slang" name = "slang"
version = "0.4.6" version = "0.4.7"
edition = "2021" edition = "2021"
[workspace] [workspace]

View File

@@ -115,7 +115,7 @@ macro_rules! keyword {
} }
#[derive(Debug, PartialEq, Hash, Eq, Clone, Logos)] #[derive(Debug, PartialEq, Hash, Eq, Clone, Logos)]
#[logos(skip r"[ \t\f]+")] #[logos(skip r"[ \r\t\f]+")]
#[logos(extras = Extras)] #[logos(extras = Extras)]
#[logos(error(LexError, LexError::from_lexer))] #[logos(error(LexError, LexError::from_lexer))]
pub enum TokenType<'a> { pub enum TokenType<'a> {
@@ -843,3 +843,20 @@ documented! {
} }
} }
#[cfg(test)]
mod tests {
use super::TokenType;
use logos::Logos;
#[test]
fn test_windows_crlf_endings() -> anyhow::Result<()> {
let src = "let i = 0;\r\n";
let lexer = TokenType::lexer(src);
let tokens = lexer.collect::<Vec<_>>();
assert!(!tokens.iter().any(|res| res.is_err()));
Ok(())
}
}