Add any type
This commit is contained in:
parent
8db95b237c
commit
ab769b4b2a
@ -5,6 +5,7 @@ use crate::{AbstractTree, Error, Map, Result, Value};
|
|||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
|
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
|
||||||
pub enum Type {
|
pub enum Type {
|
||||||
|
Any,
|
||||||
Boolean,
|
Boolean,
|
||||||
Float,
|
Float,
|
||||||
Function,
|
Function,
|
||||||
@ -20,6 +21,7 @@ impl AbstractTree for Type {
|
|||||||
Error::expect_syntax_node(source, "type", node)?;
|
Error::expect_syntax_node(source, "type", node)?;
|
||||||
|
|
||||||
let r#type = match &source[node.byte_range()] {
|
let r#type = match &source[node.byte_range()] {
|
||||||
|
"any" => Type::Any,
|
||||||
"bool" => Type::Boolean,
|
"bool" => Type::Boolean,
|
||||||
"float" => Type::Float,
|
"float" => Type::Float,
|
||||||
"fn" => Type::Function,
|
"fn" => Type::Function,
|
||||||
@ -42,15 +44,6 @@ impl AbstractTree for Type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn run(&self, _source: &str, _context: &mut Map) -> Result<Value> {
|
fn run(&self, _source: &str, _context: &mut Map) -> Result<Value> {
|
||||||
match self {
|
Ok(Value::Empty)
|
||||||
Type::Boolean => Ok(Value::String("bool".to_string())),
|
|
||||||
Type::Float => Ok(Value::String("float".to_string())),
|
|
||||||
Type::Function => Ok(Value::String("fn".to_string())),
|
|
||||||
Type::Integer => Ok(Value::String("int".to_string())),
|
|
||||||
Type::List => Ok(Value::String("list".to_string())),
|
|
||||||
Type::Map => Ok(Value::String("map".to_string())),
|
|
||||||
Type::String => Ok(Value::String("string".to_string())),
|
|
||||||
Type::Table => Ok(Value::String("table".to_string())),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -259,6 +259,7 @@ module.exports = grammar({
|
|||||||
),
|
),
|
||||||
|
|
||||||
type_definition: $ => choice(
|
type_definition: $ => choice(
|
||||||
|
'any',
|
||||||
'bool',
|
'bool',
|
||||||
'fn',
|
'fn',
|
||||||
'int',
|
'int',
|
||||||
|
Loading…
Reference in New Issue
Block a user