remove as and imports

This commit is contained in:
gluax 2022-03-28 07:42:23 -07:00
parent ef4b3787a9
commit 78b04ff000
40 changed files with 13 additions and 701 deletions

View File

@ -1,46 +0,0 @@
// Copyright (C) 2019-2022 Aleo Systems Inc.
// This file is part of the Leo library.
// The Leo library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// The Leo library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::Type;
use super::*;
/// A cast expression `e as U`.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct CastExpression {
/// The expression `e` of a type `T` that is being cast to `U`.
pub inner: Box<Expression>,
/// The type `U` to cast `e` to.
pub target_type: Type,
/// Span for the entire expression `e as U` to.
pub span: Span,
}
impl fmt::Display for CastExpression {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{} as {}", self.inner, self.target_type)
}
}
impl Node for CastExpression {
fn span(&self) -> &Span {
&self.span
}
fn set_span(&mut self, span: Span) {
self.span = span;
}
}

View File

@ -35,8 +35,6 @@ mod value;
pub use value::*;
mod call;
pub use call::*;
mod cast;
pub use cast::*;
mod err;
pub use err::*;
@ -53,8 +51,6 @@ pub enum Expression {
Unary(UnaryExpression),
/// A ternary conditional expression `cond ? if_expr : else_expr`.
Ternary(TernaryExpression),
/// A cast expression `expr as type`.
Cast(CastExpression),
/// An access expression of some sort, e.g., `array[idx]` or `foo.bar`.
Access(AccessExpression),
/// A tuple expression e.g., `(foo, 42, true)`.
@ -77,7 +73,6 @@ impl Node for Expression {
Ternary(n) => n.span(),
TupleInit(n) => n.span(),
Call(n) => n.span(),
Cast(n) => n.span(),
Access(n) => n.span(),
Err(n) => n.span(),
}
@ -93,7 +88,6 @@ impl Node for Expression {
Ternary(n) => n.set_span(span),
TupleInit(n) => n.set_span(span),
Call(n) => n.set_span(span),
Cast(n) => n.set_span(span),
Access(n) => n.set_span(span),
Err(n) => n.set_span(span),
}
@ -111,7 +105,6 @@ impl fmt::Display for Expression {
Ternary(n) => n.fmt(f),
TupleInit(n) => n.fmt(f),
Call(n) => n.fmt(f),
Cast(n) => n.fmt(f),
Access(n) => n.fmt(f),
Err(n) => n.fmt(f),
}

View File

@ -1,119 +0,0 @@
// Copyright (C) 2019-2022 Aleo Systems Inc.
// This file is part of the Leo library.
// The Leo library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// The Leo library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::Identifier;
use leo_span::{Span, Symbol};
use serde::{Deserialize, Serialize};
use std::fmt;
/// Represents an import statement in a Leo program.
#[derive(Clone, Eq, PartialEq, Serialize, Deserialize)]
pub struct ImportStatement {
/// The tree specifying what items or packages to import.
pub tree: ImportTree,
/// The span, excluding the `;`.
pub span: Span,
}
impl ImportStatement {
/// Returns the the package file name of the self import statement.
pub fn get_file_name(&self) -> Symbol {
self.tree.base.first().unwrap().name
}
}
impl fmt::Display for ImportStatement {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "import {};", self.tree)
}
}
impl fmt::Debug for ImportStatement {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(self, f)
}
}
/// An import tree specifies item(s) to import.
#[derive(Clone, Eq, PartialEq, Serialize, Deserialize)]
pub struct ImportTree {
/// A path to the base item or package to import or import from.
/// The list is always non-empty.
pub base: Vec<Identifier>,
/// Specifies the kind of import and the meaning of `base`.
/// This includes plain imports, renames, globs (`*`), and nested imports.
pub kind: ImportTreeKind,
/// The span for the import excluding `import` and `;`.
pub span: Span,
}
impl fmt::Display for ImportTree {
/// Formats `self` to `f`.
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
// Format the path.
for (i, part) in self.base.iter().enumerate() {
write!(f, "{}", part)?;
if i < self.base.len() - 1 {
write!(f, ".")?;
}
}
// Format the kind.
match &self.kind {
ImportTreeKind::Glob { .. } => write!(f, ".*"),
ImportTreeKind::Leaf { alias: None } => Ok(()),
ImportTreeKind::Leaf { alias: Some(alias) } => write!(f, "as {}", alias),
ImportTreeKind::Nested { tree } => {
write!(f, ".(")?;
for (i, node) in tree.iter().enumerate() {
write!(f, "{}", node)?;
if i < tree.len() - 1 {
write!(f, ", ")?;
}
}
write!(f, ")")
}
}
}
}
impl fmt::Debug for ImportTree {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(self, f)
}
}
/// Specifies the import kind and the meaning of `base`.
#[derive(Clone, Eq, PartialEq, Serialize, Deserialize)]
pub enum ImportTreeKind {
/// A glob import `*`.
Glob {
/// The span for the `*`.
span: Span,
},
/// A leaf package to import.
Leaf {
/// When specified, the package is imported under a different name.
/// Otherwise, the `base` name is used as in the `ImportTree`.
alias: Option<Identifier>,
},
/// A nested import of items or sub-packages.
Nested {
/// The sub-tree specifying what to import from the `base`.
tree: Vec<ImportTree>,
},
}

View File

@ -43,9 +43,6 @@ pub use self::functions::*;
pub mod groups;
pub use self::groups::*;
pub mod imports;
pub use self::imports::*;
pub mod input;
pub use self::input::*;

View File

@ -17,9 +17,7 @@
//! A Leo program consists of import, circuit, and function definitions.
//! Each defined type consists of ast statements and expressions.
use crate::{Alias, DefinitionStatement, Function, FunctionInput, Identifier, ImportStatement};
use leo_span::Symbol;
use crate::{Alias, DefinitionStatement, Function, FunctionInput, Identifier};
use indexmap::IndexMap;
use serde::{Deserialize, Serialize};
@ -34,11 +32,6 @@ pub struct Program {
/// Expected main function inputs.
/// Empty after parsing.
pub expected_input: Vec<FunctionInput>,
/// The collected import statements.
pub import_statements: Vec<ImportStatement>,
#[serde(with = "crate::common::imported_modules")]
/// A map from paths to injected programs.
pub imports: IndexMap<Vec<Symbol>, Program>,
/// A map from alias names to type aliases.
pub aliases: IndexMap<Identifier, Alias>,
/// A map from constant names to their definitions.
@ -56,21 +49,11 @@ impl AsRef<Program> for Program {
impl fmt::Display for Program {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
for import in self.import_statements.iter() {
import.fmt(f)?;
writeln!(f,)?;
}
writeln!(f,)?;
for (_, alias) in self.aliases.iter() {
alias.fmt(f)?;
writeln!(f,)?;
}
writeln!(f,)?;
for (_, import) in self.imports.iter() {
import.fmt(f)?;
writeln!(f,)?;
}
writeln!(f,)?;
for (_, function) in self.functions.iter() {
function.fmt(f)?;
writeln!(f,)?;
@ -85,8 +68,6 @@ impl Program {
Self {
name,
expected_input: vec![],
import_statements: vec![],
imports: IndexMap::new(),
aliases: IndexMap::new(),
global_consts: IndexMap::new(),
functions: IndexMap::new(),

View File

@ -20,7 +20,7 @@
use crate::*;
use leo_errors::{AstError, Result};
use leo_span::{Span, Symbol};
use leo_span::Span;
use indexmap::IndexMap;
@ -58,7 +58,6 @@ impl<R: ReconstructingReducer> ReconstructingDirector<R> {
Expression::Binary(binary) => Expression::Binary(self.reduce_binary(binary)?),
Expression::Unary(unary) => Expression::Unary(self.reduce_unary(unary)?),
Expression::Ternary(ternary) => Expression::Ternary(self.reduce_ternary(ternary)?),
Expression::Cast(cast) => Expression::Cast(self.reduce_cast(cast)?),
Expression::Access(access) => Expression::Access(self.reduce_access(access)?),
Expression::TupleInit(tuple_init) => Expression::TupleInit(self.reduce_tuple_init(tuple_init)?),
@ -124,13 +123,6 @@ impl<R: ReconstructingReducer> ReconstructingDirector<R> {
self.reducer.reduce_ternary(ternary, condition, if_true, if_false)
}
pub fn reduce_cast(&mut self, cast: &CastExpression) -> Result<CastExpression> {
let inner = self.reduce_expression(&cast.inner)?;
let target_type = self.reduce_type(&cast.target_type, &cast.span)?;
self.reducer.reduce_cast(cast, inner, target_type)
}
pub fn reduce_member_access(&mut self, member_access: &MemberAccess) -> Result<MemberAccess> {
let inner = self.reduce_expression(&member_access.inner)?;
let name = self.reduce_identifier(&member_access.name)?;
@ -327,17 +319,6 @@ impl<R: ReconstructingReducer> ReconstructingDirector<R> {
inputs.push(self.reduce_function_input(input)?);
}
let mut import_statements = vec![];
for import in program.import_statements.iter() {
import_statements.push(self.reduce_import_statement(import)?);
}
let mut imports = IndexMap::new();
for (identifier, program) in program.imports.iter() {
let (ident, import) = self.reduce_import(identifier, program)?;
imports.insert(ident, import);
}
let mut aliases = IndexMap::new();
for (name, alias) in program.aliases.iter() {
let represents = self.reduce_type(&alias.represents, &alias.name.span)?;
@ -361,15 +342,8 @@ impl<R: ReconstructingReducer> ReconstructingDirector<R> {
global_consts.insert(name.clone(), self.reduce_definition(definition)?);
}
self.reducer.reduce_program(
program,
inputs,
import_statements,
imports,
aliases,
functions,
global_consts,
)
self.reducer
.reduce_program(program, inputs, aliases, functions, global_consts)
}
pub fn reduce_function_input_variable(
@ -392,41 +366,6 @@ impl<R: ReconstructingReducer> ReconstructingDirector<R> {
self.reducer.reduce_function_input(input, new)
}
pub fn reduce_import_tree(&mut self, tree: &ImportTree) -> Result<ImportTree> {
let new = ImportTree {
base: tree
.base
.iter()
.map(|i| self.reduce_identifier(i))
.collect::<Result<_>>()?,
kind: match &tree.kind {
ImportTreeKind::Glob { .. } | ImportTreeKind::Leaf { alias: None } => tree.kind.clone(),
ImportTreeKind::Leaf { alias: Some(alias) } => {
let alias = self.reduce_identifier(alias)?;
ImportTreeKind::Leaf { alias: Some(alias) }
}
ImportTreeKind::Nested { tree } => ImportTreeKind::Nested {
tree: tree.iter().map(|n| self.reduce_import_tree(n)).collect::<Result<_>>()?,
},
},
span: tree.span.clone(),
};
self.reducer.reduce_import_tree(tree, new)
}
pub fn reduce_import_statement(&mut self, import: &ImportStatement) -> Result<ImportStatement> {
let tree = self.reduce_import_tree(&import.tree)?;
self.reducer.reduce_import_statement(import, tree)
}
pub fn reduce_import(&mut self, identifier: &[Symbol], import: &Program) -> Result<(Vec<Symbol>, Program)> {
let new_identifer = identifier.to_vec();
let new_import = self.reduce_program(import)?;
self.reducer.reduce_import(new_identifer, new_import)
}
pub fn reduce_function(&mut self, function: &Function) -> Result<Function> {
let identifier = self.reduce_identifier(&function.identifier)?;

View File

@ -113,14 +113,6 @@ pub trait ReconstructingReducer {
})
}
fn reduce_cast(&mut self, cast: &CastExpression, inner: Expression, target_type: Type) -> Result<CastExpression> {
Ok(CastExpression {
inner: Box::new(inner),
target_type,
span: cast.span.clone(),
})
}
fn reduce_member_access(
&mut self,
member_access: &MemberAccess,
@ -299,8 +291,6 @@ pub trait ReconstructingReducer {
&mut self,
program: &Program,
expected_input: Vec<FunctionInput>,
import_statements: Vec<ImportStatement>,
imports: IndexMap<Vec<Symbol>, Program>,
aliases: IndexMap<Identifier, Alias>,
functions: IndexMap<Identifier, Function>,
global_consts: IndexMap<Vec<Identifier>, DefinitionStatement>,
@ -308,8 +298,6 @@ pub trait ReconstructingReducer {
Ok(Program {
name: program.name.clone(),
expected_input,
import_statements,
imports,
aliases,
functions,
global_consts,
@ -335,17 +323,6 @@ pub trait ReconstructingReducer {
Ok(new)
}
fn reduce_import_tree(&mut self, _tree: &ImportTree, new: ImportTree) -> Result<ImportTree> {
Ok(new)
}
fn reduce_import_statement(&mut self, import: &ImportStatement, tree: ImportTree) -> Result<ImportStatement> {
Ok(ImportStatement {
tree,
span: import.span.clone(),
})
}
fn reduce_import(&mut self, identifier: Vec<Symbol>, import: Program) -> Result<(Vec<Symbol>, Program)> {
Ok((identifier, import))
}

View File

@ -199,9 +199,9 @@ impl ParserContext<'_> {
/// Returns an [`Expression`] AST node if the next tokens represent a
/// binary exponentiation expression.
///
/// Otherwise, tries to parse the next token using [`parse_cast_expression`].
/// Otherwise, tries to parse the next token using [`parse_unary_expression`].
pub fn parse_exponential_expression(&mut self) -> Result<Expression> {
let mut expr = self.parse_cast_expression()?;
let mut expr = self.parse_unary_expression()?;
if self.eat(Token::Exp).is_some() {
let right = self.parse_exponential_expression()?;
@ -211,25 +211,6 @@ impl ParserContext<'_> {
Ok(expr)
}
///
/// Returns an [`Expression`] AST node if the next tokens represent a
/// type cast expression.
///
/// Otherwise, tries to parse the next token using [`parse_unary_expression`].
///
pub fn parse_cast_expression(&mut self) -> Result<Expression> {
let mut expr = self.parse_unary_expression()?;
while self.eat(Token::As).is_some() {
let (type_, type_span) = self.parse_type()?;
expr = Expression::Cast(CastExpression {
span: expr.span() + &type_span,
inner: Box::new(expr),
target_type: type_,
})
}
Ok(expr)
}
///
/// Returns an [`Expression`] AST node if the next tokens represent a
/// unary not, negate, or bitwise not expression.

View File

@ -15,7 +15,6 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use super::*;
use crate::KEYWORD_TOKENS;
use leo_errors::{ParserError, Result};
use leo_span::sym;
@ -25,7 +24,6 @@ impl ParserContext<'_> {
/// Returns a [`Program`] AST if all tokens can be consumed and represent a valid Leo program.
///
pub fn parse_program(&mut self) -> Result<Program> {
let mut import_statements = Vec::new();
let mut aliases = IndexMap::new();
let mut functions = IndexMap::new();
let mut global_consts = IndexMap::new();
@ -33,9 +31,6 @@ impl ParserContext<'_> {
while self.has_next() {
let token = self.peek()?;
match &token.token {
Token::Import => {
import_statements.push(self.parse_import_statement()?);
}
Token::Ident(sym::test) => return Err(ParserError::test_function(&token.span).into()),
// Const functions share the first token with the global Const.
Token::Const if self.peek_is_function()? => {
@ -60,8 +55,6 @@ impl ParserContext<'_> {
Ok(Program {
name: String::new(),
expected_input: Vec::new(),
import_statements,
imports: IndexMap::new(),
aliases,
functions,
global_consts,
@ -71,7 +64,7 @@ impl ParserContext<'_> {
fn unexpected_item(token: &SpannedToken) -> ParserError {
ParserError::unexpected(
&token.token,
[Token::Import, Token::Function, Token::Ident(sym::test)]
[Token::Function, Token::Ident(sym::test)]
.iter()
.map(|x| format!("'{}'", x))
.collect::<Vec<_>>()
@ -80,75 +73,6 @@ impl ParserContext<'_> {
)
}
/// Returns an [`Identifier`] AST node if the next tokens represent a valid package name.
pub fn parse_package_name(&mut self) -> Result<Identifier> {
// Build the package name, starting with valid characters up to a dash `-` (Token::Minus).
let base = self.expect_loose_identifier()?;
// Return an error if the package name contains a keyword.
if let Some(token) = KEYWORD_TOKENS.iter().find(|x| x.keyword_to_symbol() == Some(base.name)) {
self.emit_err(ParserError::unexpected_str(token, "package name", &base.span));
}
// Return the package name.
Ok(base)
}
/// Returns an [`ImportTree`] AST node if the next tokens represent a valid package import
/// with accesses.
// Public solely for writing import parsing tests.
pub fn parse_import_tree(&mut self) -> Result<ImportTree> {
// Parse the first part of the path.
let first_name = self.parse_package_name()?;
let start = first_name.span.clone();
let mut base = vec![first_name];
let make = |base, end, kind| {
let span = start + end;
ImportTree { base, span, kind }
};
// Paths are separated by `.`s.
while self.eat(Token::Dot).is_some() {
if self.peek_is_left_par() {
// Encountered `.(`, so we have a nested import. Recurse!
let (tree, _, end) = self.parse_paren_comma_list(|p| p.parse_import_tree().map(Some))?;
if tree.is_empty() {
self.emit_err(ParserError::invalid_import_list(&end));
}
return Ok(make(base, end, ImportTreeKind::Nested { tree }));
} else if let Some(SpannedToken { span, .. }) = self.eat(Token::Mul) {
// Encountered `.*`, so we have a glob import.
return Ok(make(base, span.clone(), ImportTreeKind::Glob { span }));
}
// Parse another path segment.
base.push(self.parse_package_name()?);
}
let (end, alias) = if self.eat(Token::As).is_some() {
// Encountered `as`, so interpret as `path as rename`.
let alias = self.expect_ident()?;
(alias.span.clone(), Some(alias))
} else {
(base.last().unwrap().span.clone(), None)
};
Ok(make(base, end, ImportTreeKind::Leaf { alias }))
}
/// Returns a [`ImportStatement`] AST node if the next tokens represent an import statement.
pub fn parse_import_statement(&mut self) -> Result<ImportStatement> {
self.expect(Token::Import)?;
let tree = self.parse_import_tree()?;
self.expect(Token::Semicolon)?;
Ok(ImportStatement {
span: tree.span.clone(),
tree,
})
}
///
/// Returns a [`FunctionInput`] AST node if the next tokens represent a function parameter.
///

View File

@ -111,27 +111,6 @@ impl Namespace for ParseExpressionNamespace {
}
}
struct ParseImportNamespace;
impl Namespace for ParseImportNamespace {
fn parse_type(&self) -> ParseType {
ParseType::ContinuousLines
}
fn run_test(&self, test: Test) -> Result<Value, String> {
create_session_if_not_set_then(|_| {
let tokenizer = tokenize(test)?;
if all_are_comments(&tokenizer) {
return Ok(yaml_or_fail(Statement::Expression(ExpressionStatement {
expression: implicit_value_expr(),
span: Span::default(),
})));
}
with_handler(tokenizer, |p| p.parse_import_statement()).map(yaml_or_fail)
})
}
}
struct ParseStatementNamespace;
impl Namespace for ParseStatementNamespace {
@ -248,7 +227,6 @@ impl Runner for TestRunner {
fn resolve_namespace(&self, name: &str) -> Option<Box<dyn Namespace>> {
Some(match name {
"Parse" => Box::new(ParseNamespace),
"ParseImport" => Box::new(ParseImportNamespace),
"ParseExpression" => Box::new(ParseExpressionNamespace),
"ParseStatement" => Box::new(ParseStatementNamespace),
"Serialize" => Box::new(SerializeNamespace),

View File

@ -401,7 +401,6 @@ impl Token {
match &*ident {
x if x.starts_with("aleo1") => Token::AddressLit(ident),
"address" => Token::Address,
"as" => Token::As,
"bool" => Token::Bool,
"char" => Token::Char,
"console" => Token::Console,
@ -418,7 +417,6 @@ impl Token {
"i64" => Token::I64,
"i128" => Token::I128,
"if" => Token::If,
"import" => Token::Import,
"in" => Token::In,
"input" => Token::Input,
"let" => Token::Let,

View File

@ -124,9 +124,7 @@ mod tests {
test_ident
12345
address
as
bool
circuit
const
else
false
@ -140,7 +138,6 @@ mod tests {
i16
i8
if
import
in
input
let
@ -202,7 +199,7 @@ mod tests {
assert_eq!(
output,
r#"'a' '😭' "test" "test{}test" "test{}" "{}test" "test{" "test}" "test{test" "test}test" "te{{}}" aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8 test_ident 12345 address as bool circuit const else false field for function group i128 i64 i32 i16 i8 if import in input let mut return string test true u128 u64 u32 u16 u8 console ! != && ( ) * ** **= *= + += , - -= -> _ . .. / /= : ; < <= = == > >= [ ] { { } } || ? // test
r#"'a' '😭' "test" "test{}test" "test{}" "{}test" "test{" "test}" "test{test" "test}test" "te{{}}" aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8 test_ident 12345 address bool const else false field for function group i128 i64 i32 i16 i8 if in input let mut return string test true u128 u64 u32 u16 u8 console ! != && ( ) * ** **= *= + += , - -= -> _ . .. / /= : ; < <= = == > >= [ ] { { } } || ? // test
/* test */ // "#
);
});

View File

@ -117,11 +117,7 @@ pub enum Token {
// primary expresion
Input,
// Import
Import,
// Regular Keywords
As,
Console,
/// Const variable and a const function.
Const,
@ -142,7 +138,6 @@ pub enum Token {
/// Represents all valid Leo keyword tokens.
pub const KEYWORD_TOKENS: &[Token] = &[
Token::Address,
Token::As,
Token::Bool,
Token::Char,
Token::Console,
@ -159,7 +154,6 @@ pub const KEYWORD_TOKENS: &[Token] = &[
Token::I64,
Token::I128,
Token::If,
Token::Import,
Token::In,
Token::Input,
Token::Let,
@ -184,7 +178,6 @@ impl Token {
pub fn keyword_to_symbol(&self) -> Option<Symbol> {
Some(match self {
Token::Address => sym::address,
Token::As => sym::As,
Token::Bool => sym::bool,
Token::Char => sym::char,
Token::Console => sym::console,
@ -201,7 +194,6 @@ impl Token {
Token::I64 => sym::i64,
Token::I128 => sym::i128,
Token::If => sym::If,
Token::Import => sym::import,
Token::In => sym::In,
Token::Input => sym::input,
Token::Let => sym::Let,
@ -293,9 +285,6 @@ impl fmt::Display for Token {
Input => write!(f, "input"),
Import => write!(f, "import"),
As => write!(f, "as"),
Console => write!(f, "console"),
Const => write!(f, "const"),
Else => write!(f, "else"),

View File

@ -102,7 +102,6 @@ symbols! {
address,
AlwaysConst,
array,
As: "as",
assert,
bool,
char,
@ -125,7 +124,6 @@ symbols! {
i64,
i128,
If: "if",
import,
In: "in",
input,
Let: "let",

View File

@ -116,141 +116,3 @@ outputs:
col_stop: 12
path: ""
content: 1 ** 2 ** 3
- Binary:
left:
Cast:
inner:
Value:
Implicit:
- "1"
- span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 2
path: ""
content: 1 as i8 ** 3 as i8
target_type:
IntegerType: I8
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 8
path: ""
content: 1 as i8 ** 3 as i8
right:
Cast:
inner:
Value:
Implicit:
- "3"
- span:
line_start: 1
line_stop: 1
col_start: 12
col_stop: 13
path: ""
content: 1 as i8 ** 3 as i8
target_type:
IntegerType: I8
span:
line_start: 1
line_stop: 1
col_start: 12
col_stop: 19
path: ""
content: 1 as i8 ** 3 as i8
op: Pow
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 19
path: ""
content: 1 as i8 ** 3 as i8
- Binary:
left:
Cast:
inner:
Value:
Implicit:
- "1"
- span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 2
path: ""
content: 1 as i8 ** 3 as i8 ** 5 as i8
target_type:
IntegerType: I8
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 8
path: ""
content: 1 as i8 ** 3 as i8 ** 5 as i8
right:
Binary:
left:
Cast:
inner:
Value:
Implicit:
- "3"
- span:
line_start: 1
line_stop: 1
col_start: 12
col_stop: 13
path: ""
content: 1 as i8 ** 3 as i8 ** 5 as i8
target_type:
IntegerType: I8
span:
line_start: 1
line_stop: 1
col_start: 12
col_stop: 19
path: ""
content: 1 as i8 ** 3 as i8 ** 5 as i8
right:
Cast:
inner:
Value:
Implicit:
- "5"
- span:
line_start: 1
line_stop: 1
col_start: 23
col_stop: 24
path: ""
content: 1 as i8 ** 3 as i8 ** 5 as i8
target_type:
IntegerType: I8
span:
line_start: 1
line_stop: 1
col_start: 23
col_stop: 30
path: ""
content: 1 as i8 ** 3 as i8 ** 5 as i8
op: Pow
span:
line_start: 1
line_stop: 1
col_start: 12
col_stop: 30
path: ""
content: 1 as i8 ** 3 as i8 ** 5 as i8
op: Pow
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 30
path: ""
content: 1 as i8 ** 3 as i8 ** 5 as i8

View File

@ -4,8 +4,6 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
import_statements: []
imports: {}
aliases: {}
global_consts: {}
functions: {}

View File

@ -62,8 +62,6 @@ outputs:
- "Error [EPAR0370030]: Could not lex the following content: `~`."
- "Error [EPAR0370030]: Could not lex the following content: `~`."
- "Error [EPAR0370030]: Could not lex the following content: `~`."
- "Error [EPAR0370009]: unexpected string: expected 'expression', got 'import'\n --> test:1:1\n |\n 1 | import\n | ^^^^^^"
- "Error [EPAR0370009]: unexpected string: expected 'expression', got 'as'\n --> test:1:1\n |\n 1 | as\n | ^^"
- "Error [EPAR0370009]: unexpected string: expected 'expression', got 'console'\n --> test:1:1\n |\n 1 | console\n | ^^^^^^^"
- "Error [EPAR0370009]: unexpected string: expected 'expression', got 'const'\n --> test:1:1\n |\n 1 | const\n | ^^^^^"
- "Error [EPAR0370009]: unexpected string: expected 'expression', got 'else'\n --> test:1:1\n |\n 1 | else\n | ^^^^"

View File

@ -4,8 +4,6 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
import_statements: []
imports: {}
aliases: {}
global_consts: {}
functions:

View File

@ -4,8 +4,6 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
import_statements: []
imports: {}
aliases: {}
global_consts: {}
functions:

View File

@ -4,8 +4,6 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
import_statements: []
imports: {}
aliases: {}
global_consts: {}
functions:

View File

@ -4,8 +4,6 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
import_statements: []
imports: {}
aliases: {}
global_consts: {}
functions:

View File

@ -4,8 +4,6 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
import_statements: []
imports: {}
aliases: {}
global_consts: {}
functions:

View File

@ -2,4 +2,4 @@
namespace: Parse
expectation: Fail
outputs:
- "Error [EPAR0370005]: expected 'import', 'function', 'test' -- got '1'\n --> test:3:1\n |\n 3 | 1 main() {}\n | ^"
- "Error [EPAR0370005]: expected 'function', 'test' -- got '1'\n --> test:3:1\n |\n 3 | 1 main() {}\n | ^"

View File

@ -4,8 +4,6 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
import_statements: []
imports: {}
aliases: {}
global_consts: {}
functions:

View File

@ -4,8 +4,6 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
import_statements: []
imports: {}
aliases: {}
global_consts: {}
functions:

View File

@ -4,8 +4,6 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
import_statements: []
imports: {}
aliases: {}
global_consts: {}
functions:

View File

@ -4,8 +4,6 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
import_statements: []
imports: {}
aliases: {}
global_consts: {}
functions:

View File

@ -4,8 +4,6 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
import_statements: []
imports: {}
aliases: {}
global_consts: {}
functions:

View File

@ -4,8 +4,6 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
import_statements: []
imports: {}
aliases: {}
global_consts: {}
functions:

View File

@ -4,8 +4,6 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
import_statements: []
imports: {}
aliases: {}
global_consts: {}
functions:

View File

@ -2,4 +2,4 @@
namespace: Serialize
expectation: Fail
outputs:
- "Error [EPAR0370005]: expected 'import', 'function', 'test' -- got 'invalid'\n --> test:3:1\n |\n 3 | invalid\n | ^^^^^^^"
- "Error [EPAR0370005]: expected 'function', 'test' -- got 'invalid'\n --> test:3:1\n |\n 3 | invalid\n | ^^^^^^^"

View File

@ -4,8 +4,6 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
import_statements: []
imports: {}
aliases:
"{\"name\":\"a\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":6,\\\"col_stop\\\":7,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"type a = u32;\\\"}\"}":
name: "{\"name\":\"a\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":6,\\\"col_stop\\\":7,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"type a = u32;\\\"}\"}"

View File

@ -8,7 +8,7 @@ outputs:
- "Error [EPAR0370011]: invalid assignment target\n --> test:1:1\n |\n 1 | -x = y;\n | ^^"
- "Error [EPAR0370011]: invalid assignment target\n --> test:1:1\n |\n 1 | !x = y;\n | ^^"
- "Error [EPAR0370011]: invalid assignment target\n --> test:1:1\n |\n 1 | a? x : x = y;\n | ^^^^^^^^"
- "Error [EPAR0370011]: invalid assignment target\n --> test:1:1\n |\n 1 | x as u32 = y;\n | ^^^^^^^^"
- "Error [EPAR0370005]: expected ; -- got 'as'\n --> test:1:3\n |\n 1 | x as u32 = y;\n | ^^"
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '['\n --> test:1:1\n |\n 1 | [x, x, x] = y;\n | ^"
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '['\n --> test:1:1\n |\n 1 | [x; 3] = y;\n | ^"
- "Error [EPAR0370011]: invalid assignment target\n --> test:1:1\n |\n 1 | (x, x, x) = y;\n | ^^^^^^^^^"

View File

@ -4,8 +4,6 @@ expectation: Pass
outputs:
- name: ""
expected_input: []
import_statements: []
imports: {}
aliases: {}
global_consts:
x:

View File

@ -4,7 +4,7 @@ expectation: Fail
outputs:
- "Error [EPAR0370009]: unexpected string: expected 'expression', got ';'\n --> test:1:1\n |\n 1 | ; x = 10u8;\n | ^"
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '.'\n --> test:1:1\n |\n 1 | . x = 10u8;\n | ^"
- "Error [EPAR0370009]: unexpected string: expected 'expression', got 'import'\n --> test:1:1\n |\n 1 | import x = 10u8;\n | ^^^^^^"
- "Error [EPAR0370005]: expected ; -- got 'x'\n --> test:1:8\n |\n 1 | import x = 10u8;\n | ^"
- "Error [EPAR0370009]: unexpected string: expected 'expression', got ','\n --> test:1:1\n |\n 1 | , x = 10u8;\n | ^"
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '['\n --> test:1:1\n |\n 1 | [ x = 10u8;\n | ^"
- "Error [EPAR0370009]: unexpected string: expected 'expression', got ']'\n --> test:1:1\n |\n 1 | ] x = 10u8;\n | ^"
@ -26,7 +26,7 @@ outputs:
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '<='\n --> test:1:1\n |\n 1 | <= x = 10u8;\n | ^^"
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '>'\n --> test:1:1\n |\n 1 | > x = 10u8;\n | ^"
- "Error [EPAR0370009]: unexpected string: expected 'expression', got '..'\n --> test:1:1\n |\n 1 | .. x = 10u8;\n | ^^"
- "Error [EPAR0370009]: unexpected string: expected 'expression', got 'as'\n --> test:1:1\n |\n 1 | as x = 10u8;\n | ^^"
- "Error [EPAR0370005]: expected ; -- got 'x'\n --> test:1:4\n |\n 1 | as x = 10u8;\n | ^"
- "Error [EPAR0370005]: expected . -- got 'x'\n --> test:1:9\n |\n 1 | console x = 10u8;\n | ^"
- "Error [EPAR0370005]: expected in -- got '='\n --> test:1:7\n |\n 1 | for x = 10u8;\n | ^"
- "Error [EPAR0370005]: expected { -- got '='\n --> test:1:6\n |\n 1 | if x = 10u8;\n | ^"

View File

@ -274,60 +274,6 @@ outputs:
col_stop: 14
path: ""
content: let x = a > b;
- Definition:
declaration_type: Let
variable_names:
- mutable: true
identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":5,\\\"col_stop\\\":6,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"let x = a as b;\\\"}\"}"
span:
line_start: 1
line_stop: 1
col_start: 5
col_stop: 6
path: ""
content: let x = a as b;
type_: ~
value:
Cast:
inner:
Identifier: "{\"name\":\"a\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":9,\\\"col_stop\\\":10,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"let x = a as b;\\\"}\"}"
target_type:
Identifier: "{\"name\":\"b\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":14,\\\"col_stop\\\":15,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"let x = a as b;\\\"}\"}"
span:
line_start: 1
line_stop: 1
col_start: 9
col_stop: 15
path: ""
content: let x = a as b;
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 15
path: ""
content: let x = a as b;
- Assign:
operation: Assign
assignee:
identifier: "{\"name\":\"ximport\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":1,\\\"col_stop\\\":8,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"ximport=b;\\\"}\"}"
accesses: []
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 8
path: ""
content: ximport=b;
value:
Identifier: "{\"name\":\"b\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":9,\\\"col_stop\\\":10,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"ximport=b;\\\"}\"}"
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 10
path: ""
content: ximport=b;
- Assign:
operation: Assign
assignee:
@ -459,27 +405,6 @@ outputs:
col_stop: 5
path: ""
content: x>=b;
- Assign:
operation: Assign
assignee:
identifier: "{\"name\":\"xas\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":1,\\\"col_stop\\\":4,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"xas=b;\\\"}\"}"
accesses: []
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 4
path: ""
content: xas=b;
value:
Identifier: "{\"name\":\"b\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":5,\\\"col_stop\\\":6,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"xas=b;\\\"}\"}"
span:
line_start: 1
line_stop: 1
col_start: 1
col_stop: 6
path: ""
content: xas=b;
- Assign:
operation: Assign
assignee:

View File

@ -8,7 +8,3 @@ expectation: Pass
2**3
1 ** 2 ** 3
1 as i8 ** 3 as i8
1 as i8 ** 3 as i8 ** 5 as i8

View File

@ -1,16 +0,0 @@
/*
namespace: ParseExpression
expectation: Pass
*/
x as u8
y as id
z as u32
x as i128
x as u8 as u128
x as field
x as group
x ** y as u32 ** z
// ~x as u32
!x as u32
-x as u32

View File

@ -123,10 +123,6 @@ char ~
input ~
import
as
console
const

View File

@ -19,10 +19,6 @@ let x = a <= b;
let x = a > b;
let x = a as b;
ximport=b;
x_=b;
x==b;
@ -35,8 +31,6 @@ x<=b;
x>=b;
xas=b;
xconsole=b;
xconst=b;