-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
693c93e
commit 3acba85
Showing
11 changed files
with
113 additions
and
10 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,5 @@ | |
//! scene. | ||
pub use os::*; | ||
pub use variant::*; | ||
|
||
mod os; | ||
mod variant; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[package] | ||
name = "surreal-scripting" | ||
description = "Scripting engine for Surreal" | ||
authors.workspace = true | ||
edition.workspace = true | ||
version.workspace = true | ||
|
||
[dependencies] | ||
common = { package = "surreal-common", path = "../common" } | ||
|
||
[features] | ||
wren = [] | ||
lua = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//! Scripting language abstractions | ||
use common::ToVirtualPath; | ||
#[cfg(feature = "lua")] | ||
pub use lua::*; | ||
#[cfg(feature = "wren")] | ||
pub use wren::*; | ||
|
||
#[cfg(feature = "lua")] | ||
mod lua; | ||
#[cfg(feature = "wren")] | ||
mod wren; | ||
|
||
/// Represents a scripting language | ||
pub trait ScriptLanguage { | ||
/// Loads a script from the given path | ||
fn load(path: impl ToVirtualPath) -> Result<Script, ScriptError>; | ||
} | ||
|
||
/// Represents a parsed script | ||
pub struct Script { | ||
module: ast::Module, | ||
} | ||
|
||
/// Represents an error that occurred while parsing a script | ||
pub enum ScriptError { | ||
NotFound, | ||
ParseError, | ||
} | ||
|
||
mod ast { | ||
//! The internal AST representation of a script | ||
pub struct Module {} | ||
pub enum Statement {} | ||
pub enum Expression {} | ||
pub enum Literal {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//! Lua support for Surreal | ||
use super::*; | ||
|
||
/// The Lua scripting language | ||
pub struct Lua; | ||
|
||
impl ScriptLanguage for Lua { | ||
fn load(_path: impl ToVirtualPath) -> Result<Script, ScriptError> { | ||
todo!() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//! Wren support for surreal | ||
use super::*; | ||
|
||
/// The Wren scripting language and virtual machine. | ||
pub struct Wren; | ||
|
||
impl ScriptLanguage for Wren { | ||
fn load(path: impl ToVirtualPath) -> Result<Script, ScriptError> { | ||
let path = path.to_virtual_path(); | ||
let text = path.read_all_text().map_err(|_| ScriptError::ParseError)?; | ||
|
||
parser::parse(&text).map_err(|_| ScriptError::ParseError)?; | ||
|
||
todo!() | ||
} | ||
} | ||
|
||
mod parser { | ||
use super::*; | ||
|
||
pub fn parse(text: &str) -> Result<ast::Module, ()> { | ||
todo!() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
//! Scripting engine for Surreal | ||
pub use lang::*; | ||
pub use variant::*; | ||
|
||
mod lang; | ||
mod variant; | ||
|
||
/// Represents a script in a scripting language | ||
pub trait Script {} |
5 changes: 1 addition & 4 deletions
5
crates/common/src/abstractions/variant.rs → crates/scripting/src/variant.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters