diff --git a/.vscode/settings.json b/.vscode/settings.json index a9aba9f..92b237a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,5 @@ -{ - "cSpell.words": [ - "vuvoth" - ] +{ + "cSpell.words": [ + "vuvoth" + ] } \ No newline at end of file diff --git a/crates/lsp/Cargo.toml b/crates/lsp/Cargo.toml index a436e4e..ab278c1 100644 --- a/crates/lsp/Cargo.toml +++ b/crates/lsp/Cargo.toml @@ -27,3 +27,12 @@ path-absolutize = "3.1.1" [profile] dev.debug = 2 + +[dev-dependencies] +# for snapshot testing, yaml format +insta = { version = "1.41.1", features = ["yaml"] } + +[profile.dev.package] +# compile slightly slower once, but use less memory, have faster diffs +insta.opt-level = 3 +similar.opt-level = 3 diff --git a/crates/lsp/src/database.rs b/crates/lsp/src/database.rs index 245d44b..74126ce 100644 --- a/crates/lsp/src/database.rs +++ b/crates/lsp/src/database.rs @@ -1,450 +1,450 @@ -use std::{ - collections::HashMap, - hash::{Hash, Hasher}, - path::PathBuf, -}; - -use std::collections::hash_map::DefaultHasher; - -use lsp_types::{Position, Range, Url}; - -use rowan::{ast::AstNode, TextSize}; -use syntax::{ - abstract_syntax_tree::{ - AstCircomProgram, AstComponentDecl, AstInputSignalDecl, AstOutputSignalDecl, AstSignalDecl, - AstTemplateDef, AstVarDecl, - }, - syntax_node::{SyntaxNode, SyntaxToken}, -}; - -/** -* We will store -* Open data -> Parse -> output -> Syntax -> analyzer -> db{ - FileID { - Template { - signal, - - } - } - - value - Template map: { Hash(FileID, token) -> Template} - Vars map: {Hash(FileID, template, token)} -> Var} - Component map {Hash(FileID, template, token)} -> ComponentInfo - Signals map {Hash(FileID, template, token)} -> Signal - - - -} -*/ - -#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)] -pub struct FileId(pub u64); - -#[derive(Clone)] -pub struct FileDB { - pub file_id: FileId, - pub file_path: Url, - pub end_line_vec: Vec, -} - -use path_absolutize::*; - -impl FileDB { - pub fn create(content: &str, file_path: Url) -> Self { - let mut hasher = DefaultHasher::new(); - file_path - .to_file_path() - .unwrap() - .absolutize() - .unwrap() - .hash(&mut hasher); - Self::new(FileId(hasher.finish()), content, file_path) - } - - pub(super) fn new(file_id: FileId, content: &str, file_path: Url) -> Self { - let mut file_utils = Self { - file_id, - file_path, - end_line_vec: Vec::new(), - }; - - for (id, c) in content.chars().enumerate() { - if c == '\n' { - file_utils.end_line_vec.push(id as u32); - } - } - - file_utils - } - - pub fn get_path(&self) -> PathBuf { - let p = self.file_path.path(); - PathBuf::from(p) - } - - pub fn off_set(&self, position: Position) -> TextSize { - if position.line == 0 { - return position.character.into(); - } - (self.end_line_vec[position.line as usize - 1] + position.character + 1).into() - } - - pub fn position(&self, off_set: TextSize) -> Position { - let line = match self.end_line_vec.binary_search(&(off_set.into())) { - Ok(l) => l, - Err(l) => l, - }; - - Position::new( - line as u32, - if line > 0 { - (u32::from(off_set)) - self.end_line_vec[line - 1] - 1 - } else { - off_set.into() - }, - ) - } - - pub fn range(&self, syntax: &SyntaxNode) -> Range { - let syntax_range = syntax.text_range(); - Range { - start: self.position(syntax_range.start()), - end: self.position(syntax_range.end()), - } - } -} - -#[derive(Clone, Copy, Hash, PartialEq, Eq, Debug)] -pub struct Id(pub u64); - -pub trait TokenId { - fn token_id(&self) -> Id; -} - -impl TokenId for SyntaxNode { - fn token_id(&self) -> Id { - let mut hasher = DefaultHasher::new(); - self.to_string().hash(&mut hasher); - Id(hasher.finish()) - } -} - -impl TokenId for SyntaxToken { - fn token_id(&self) -> Id { - let mut hasher = DefaultHasher::new(); - self.to_string().hash(&mut hasher); - Id(hasher.finish()) - } -} - -#[derive(Debug, Clone)] -pub struct SemanticLocations(pub HashMap>); - -impl Default for SemanticLocations { - fn default() -> Self { - Self::new() - } -} - -impl SemanticLocations { - pub fn insert(&mut self, token_id: Id, range: Range) { - if let Some(locations) = self.0.get_mut(&token_id) { - locations.push(range); - } else { - self.0.insert(token_id, vec![range]); - } - } - pub fn new() -> Self { - Self(HashMap::new()) - } -} - -#[derive(Debug, Clone)] -pub struct TemplateDataSemantic { - pub signal: SemanticLocations, - pub variable: SemanticLocations, - pub component: SemanticLocations, -} - -impl TemplateDataSemantic { - fn new() -> Self { - Self { - signal: SemanticLocations::new(), - variable: SemanticLocations::new(), - component: SemanticLocations::new(), - } - } -} - -#[derive(Debug, Clone)] -pub struct SemanticData { - pub template: SemanticLocations, - pub template_data_semantic: HashMap, -} - -pub enum TemplateDataInfo { - Signal((Id, Range)), - Variable((Id, Range)), - Component((Id, Range)), -} -pub enum SemanticInfo { - Template((Id, Range)), - TemplateData((Id, TemplateDataInfo)), -} - -#[derive(Debug, Clone)] -pub struct SemanticDB { - pub semantic: HashMap, -} - -impl Default for SemanticDB { - fn default() -> Self { - Self::new() - } -} - -impl SemanticDB { - pub fn new() -> Self { - Self { - semantic: HashMap::new(), - } - } - - pub fn insert(&mut self, file_id: FileId, semantic_info: SemanticInfo) { - let semantic = self.semantic.entry(file_id).or_insert(SemanticData { - template: SemanticLocations::new(), - template_data_semantic: HashMap::new(), - }); - - match semantic_info { - SemanticInfo::Template((id, range)) => { - semantic.template.insert(id, range); - } - SemanticInfo::TemplateData((template_id, template_data_info)) => { - let template_semantic = semantic - .template_data_semantic - .entry(template_id) - .or_insert(TemplateDataSemantic::new()); - - match template_data_info { - TemplateDataInfo::Component((id, r)) => { - template_semantic.component.insert(id, r) - } - TemplateDataInfo::Variable((id, r)) => template_semantic.variable.insert(id, r), - TemplateDataInfo::Signal((id, r)) => template_semantic.signal.insert(id, r), - } - } - } - } - - pub fn circom_program_semantic( - &mut self, - file_db: &FileDB, - abstract_syntax_tree: &AstCircomProgram, - ) { - for template in abstract_syntax_tree.template_list() { - if let Some(name) = template.name() { - let template_id = name.syntax().token_id(); - self.insert( - file_db.file_id, - SemanticInfo::Template((template_id, file_db.range(template.syntax()))), - ); - self.template_semantic(file_db, &template); - } - } - } - - pub fn template_semantic(&mut self, file_db: &FileDB, ast_template: &AstTemplateDef) { - let template_id = ast_template.syntax().token_id(); - - if let Some(statements) = ast_template.statements() { - for signal in statements.find_children::() { - if let Some(name) = signal.name() { - self.insert( - file_db.file_id, - SemanticInfo::TemplateData(( - template_id, - TemplateDataInfo::Signal(( - name.syntax().token_id(), - file_db.range(signal.syntax()), - )), - )), - ); - } - } - for signal in statements.find_children::() { - if let Some(name) = signal.name() { - self.insert( - file_db.file_id, - SemanticInfo::TemplateData(( - template_id, - TemplateDataInfo::Signal(( - name.syntax().token_id(), - file_db.range(signal.syntax()), - )), - )), - ); - } - } - - for signal in statements.find_children::() { - if let Some(name) = signal.name() { - self.insert( - file_db.file_id, - SemanticInfo::TemplateData(( - template_id, - TemplateDataInfo::Signal(( - name.syntax().token_id(), - file_db.range(signal.syntax()), - )), - )), - ); - } - } - - for var in statements.find_children::() { - if let Some(name) = var.name() { - self.insert( - file_db.file_id, - SemanticInfo::TemplateData(( - template_id, - TemplateDataInfo::Variable(( - name.syntax().token_id(), - file_db.range(var.syntax()), - )), - )), - ); - } - } - - for component in statements.find_children::() { - if let Some(component_var) = component.component_identifier() { - if let Some(name) = component_var.name() { - self.insert( - file_db.file_id, - SemanticInfo::TemplateData(( - template_id, - TemplateDataInfo::Component(( - name.syntax().token_id(), - file_db.range(component.syntax()), - )), - )), - ); - } - } - } - } - } -} - -impl SemanticData { - pub fn lookup_signal(&self, template_id: Id, signal: &SyntaxToken) -> Option<&Vec> { - if let Some(semantic_template) = self.template_data_semantic.get(&template_id) { - return semantic_template.signal.0.get(&signal.token_id()); - } - None - } - - // TODO: remove duplicate code here. - pub fn lookup_variable(&self, template_id: Id, variable: &SyntaxToken) -> Option<&Vec> { - if let Some(semantic_template) = self.template_data_semantic.get(&template_id) { - return semantic_template.variable.0.get(&variable.token_id()); - } - None - } - - pub fn lookup_component( - &self, - template_id: Id, - component: &SyntaxToken, - ) -> Option<&Vec> { - if let Some(semantic_template) = self.template_data_semantic.get(&template_id) { - return semantic_template.component.0.get(&component.token_id()); - } - None - } -} - -#[cfg(test)] -mod tests { - - use std::path::Path; - - use ::syntax::{abstract_syntax_tree::AstCircomProgram, syntax::SyntaxTreeBuilder}; - use lsp_types::{Position, Url}; - - use rowan::ast::AstNode; - - use crate::database::{FileDB, FileId}; - - use super::TokenId; - - #[test] - fn file_id_test() { - let file_1 = FileDB::create("a", Url::from_file_path(Path::new("/a/../a/c")).unwrap()); - let file_2 = FileDB::create("a", Url::from_file_path(Path::new("/a/c")).unwrap()); - - assert_eq!(file_1.file_id, file_2.file_id); - } - #[test] - fn token_id_hash_test() { - let source: String = r#"pragma circom 2.0.0; - - - template Multiplier2 () {} - template Multiplier2 () {} - "# - .to_string(); - - let syntax = SyntaxTreeBuilder::syntax_tree(&source); - - if let Some(ast) = AstCircomProgram::cast(syntax) { - let templates = ast.template_list(); - let first_id = templates[0].syntax().token_id(); - let second_id = templates[1].syntax().token_id(); - - assert_eq!(first_id, second_id); - } - } - #[test] - fn off_set_test() { - let str = r#" -one -two -three - "#; - - let file_utils = FileDB::new( - FileId(1), - str, - Url::from_file_path(Path::new("/tmp.txt")).unwrap(), - ); - - let position = Position::new(0, 1); - - assert_eq!(file_utils.off_set(position), 1.into()); - - let position = Position::new(1, 1); - - assert_eq!(file_utils.off_set(position), 2.into()); - } - - #[test] - fn position_test() { - let str = r#" - one - two - three - "#; - - // 0, 4, 8 - let file_utils = FileDB::new( - FileId(1), - str, - Url::from_file_path(Path::new("/tmp.txt")).unwrap(), - ); - assert_eq!(Position::new(1, 1), file_utils.position(2.into())); - assert_eq!(Position::new(0, 0), file_utils.position(0.into())); - } -} +use std::{ + collections::HashMap, + hash::{Hash, Hasher}, + path::PathBuf, +}; + +use std::collections::hash_map::DefaultHasher; + +use lsp_types::{Position, Range, Url}; + +use rowan::{ast::AstNode, TextSize}; +use syntax::{ + abstract_syntax_tree::{ + AstCircomProgram, AstComponentDecl, AstInputSignalDecl, AstOutputSignalDecl, AstSignalDecl, + AstTemplateDef, AstVarDecl, + }, + syntax_node::{SyntaxNode, SyntaxToken}, +}; + +/** +* We will store +* Open data -> Parse -> output -> Syntax -> analyzer -> db{ + FileID { + Template { + signal, + + } + } + + value + Template map: { Hash(FileID, token) -> Template} + Vars map: {Hash(FileID, template, token)} -> Var} + Component map {Hash(FileID, template, token)} -> ComponentInfo + Signals map {Hash(FileID, template, token)} -> Signal + + + +} +*/ + +#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)] +pub struct FileId(pub u64); + +#[derive(Clone)] +pub struct FileDB { + pub file_id: FileId, + pub file_path: Url, + pub end_line_vec: Vec, +} + +use path_absolutize::*; + +impl FileDB { + pub fn create(content: &str, file_path: Url) -> Self { + let mut hasher = DefaultHasher::new(); + file_path + .to_file_path() + .unwrap() + .absolutize() + .unwrap() + .hash(&mut hasher); + Self::new(FileId(hasher.finish()), content, file_path) + } + + pub(super) fn new(file_id: FileId, content: &str, file_path: Url) -> Self { + let mut file_utils = Self { + file_id, + file_path, + end_line_vec: Vec::new(), + }; + + for (id, c) in content.chars().enumerate() { + if c == '\n' { + file_utils.end_line_vec.push(id as u32); + } + } + + file_utils + } + + pub fn get_path(&self) -> PathBuf { + let p = self.file_path.path(); + PathBuf::from(p) + } + + pub fn off_set(&self, position: Position) -> TextSize { + if position.line == 0 { + return position.character.into(); + } + (self.end_line_vec[position.line as usize - 1] + position.character + 1).into() + } + + pub fn position(&self, off_set: TextSize) -> Position { + let line = match self.end_line_vec.binary_search(&(off_set.into())) { + Ok(l) => l, + Err(l) => l, + }; + + Position::new( + line as u32, + if line > 0 { + (u32::from(off_set)) - self.end_line_vec[line - 1] - 1 + } else { + off_set.into() + }, + ) + } + + pub fn range(&self, syntax: &SyntaxNode) -> Range { + let syntax_range = syntax.text_range(); + Range { + start: self.position(syntax_range.start()), + end: self.position(syntax_range.end()), + } + } +} + +#[derive(Clone, Copy, Hash, PartialEq, Eq, Debug)] +pub struct Id(pub u64); + +pub trait TokenId { + fn token_id(&self) -> Id; +} + +impl TokenId for SyntaxNode { + fn token_id(&self) -> Id { + let mut hasher = DefaultHasher::new(); + self.to_string().hash(&mut hasher); + Id(hasher.finish()) + } +} + +impl TokenId for SyntaxToken { + fn token_id(&self) -> Id { + let mut hasher = DefaultHasher::new(); + self.to_string().hash(&mut hasher); + Id(hasher.finish()) + } +} + +#[derive(Debug, Clone)] +pub struct SemanticLocations(pub HashMap>); + +impl Default for SemanticLocations { + fn default() -> Self { + Self::new() + } +} + +impl SemanticLocations { + pub fn insert(&mut self, token_id: Id, range: Range) { + if let Some(locations) = self.0.get_mut(&token_id) { + locations.push(range); + } else { + self.0.insert(token_id, vec![range]); + } + } + pub fn new() -> Self { + Self(HashMap::new()) + } +} + +#[derive(Debug, Clone)] +pub struct TemplateDataSemantic { + pub signal: SemanticLocations, + pub variable: SemanticLocations, + pub component: SemanticLocations, +} + +impl TemplateDataSemantic { + fn new() -> Self { + Self { + signal: SemanticLocations::new(), + variable: SemanticLocations::new(), + component: SemanticLocations::new(), + } + } +} + +#[derive(Debug, Clone)] +pub struct SemanticData { + pub template: SemanticLocations, + pub template_data_semantic: HashMap, +} + +pub enum TemplateDataInfo { + Signal((Id, Range)), + Variable((Id, Range)), + Component((Id, Range)), +} +pub enum SemanticInfo { + Template((Id, Range)), + TemplateData((Id, TemplateDataInfo)), +} + +#[derive(Debug, Clone)] +pub struct SemanticDB { + pub semantic: HashMap, +} + +impl Default for SemanticDB { + fn default() -> Self { + Self::new() + } +} + +impl SemanticDB { + pub fn new() -> Self { + Self { + semantic: HashMap::new(), + } + } + + pub fn insert(&mut self, file_id: FileId, semantic_info: SemanticInfo) { + let semantic = self.semantic.entry(file_id).or_insert(SemanticData { + template: SemanticLocations::new(), + template_data_semantic: HashMap::new(), + }); + + match semantic_info { + SemanticInfo::Template((id, range)) => { + semantic.template.insert(id, range); + } + SemanticInfo::TemplateData((template_id, template_data_info)) => { + let template_semantic = semantic + .template_data_semantic + .entry(template_id) + .or_insert(TemplateDataSemantic::new()); + + match template_data_info { + TemplateDataInfo::Component((id, r)) => { + template_semantic.component.insert(id, r) + } + TemplateDataInfo::Variable((id, r)) => template_semantic.variable.insert(id, r), + TemplateDataInfo::Signal((id, r)) => template_semantic.signal.insert(id, r), + } + } + } + } + + pub fn circom_program_semantic( + &mut self, + file_db: &FileDB, + abstract_syntax_tree: &AstCircomProgram, + ) { + for template in abstract_syntax_tree.template_list() { + if let Some(name) = template.name() { + let template_id = name.syntax().token_id(); + self.insert( + file_db.file_id, + SemanticInfo::Template((template_id, file_db.range(template.syntax()))), + ); + self.template_semantic(file_db, &template); + } + } + } + + pub fn template_semantic(&mut self, file_db: &FileDB, ast_template: &AstTemplateDef) { + let template_id = ast_template.syntax().token_id(); + + if let Some(statements) = ast_template.statements() { + for signal in statements.find_children::() { + if let Some(name) = signal.signal_identifier().unwrap().name() { + self.insert( + file_db.file_id, + SemanticInfo::TemplateData(( + template_id, + TemplateDataInfo::Signal(( + name.syntax().token_id(), + file_db.range(signal.syntax()), + )), + )), + ); + } + } + for signal in statements.find_children::() { + if let Some(name) = signal.signal_identifier().unwrap().name() { + self.insert( + file_db.file_id, + SemanticInfo::TemplateData(( + template_id, + TemplateDataInfo::Signal(( + name.syntax().token_id(), + file_db.range(signal.syntax()), + )), + )), + ); + } + } + + for signal in statements.find_children::() { + if let Some(name) = signal.signal_identifier().unwrap().name() { + self.insert( + file_db.file_id, + SemanticInfo::TemplateData(( + template_id, + TemplateDataInfo::Signal(( + name.syntax().token_id(), + file_db.range(signal.syntax()), + )), + )), + ); + } + } + + for var in statements.find_children::() { + if let Some(name) = var.var_identifier().unwrap().name() { + self.insert( + file_db.file_id, + SemanticInfo::TemplateData(( + template_id, + TemplateDataInfo::Variable(( + name.syntax().token_id(), + file_db.range(var.syntax()), + )), + )), + ); + } + } + + for component in statements.find_children::() { + if let Some(component_var) = component.component_identifier() { + if let Some(name) = component_var.name() { + self.insert( + file_db.file_id, + SemanticInfo::TemplateData(( + template_id, + TemplateDataInfo::Component(( + name.syntax().token_id(), + file_db.range(component.syntax()), + )), + )), + ); + } + } + } + } + } +} + +impl SemanticData { + pub fn lookup_signal(&self, template_id: Id, signal: &SyntaxToken) -> Option<&Vec> { + if let Some(semantic_template) = self.template_data_semantic.get(&template_id) { + return semantic_template.signal.0.get(&signal.token_id()); + } + None + } + + // TODO: remove duplicate code here. + pub fn lookup_variable(&self, template_id: Id, variable: &SyntaxToken) -> Option<&Vec> { + if let Some(semantic_template) = self.template_data_semantic.get(&template_id) { + return semantic_template.variable.0.get(&variable.token_id()); + } + None + } + + pub fn lookup_component( + &self, + template_id: Id, + component: &SyntaxToken, + ) -> Option<&Vec> { + if let Some(semantic_template) = self.template_data_semantic.get(&template_id) { + return semantic_template.component.0.get(&component.token_id()); + } + None + } +} + +#[cfg(test)] +mod tests { + + use std::path::Path; + + use ::syntax::{abstract_syntax_tree::AstCircomProgram, syntax::SyntaxTreeBuilder}; + use lsp_types::{Position, Url}; + + use rowan::ast::AstNode; + + use crate::database::{FileDB, FileId}; + + use super::TokenId; + + #[test] + fn file_id_test() { + let file_1 = FileDB::create("a", Url::from_file_path(Path::new("/a/../a/c")).unwrap()); + let file_2 = FileDB::create("a", Url::from_file_path(Path::new("/a/c")).unwrap()); + + assert_eq!(file_1.file_id, file_2.file_id); + } + #[test] + fn token_id_hash_test() { + let source: String = r#"pragma circom 2.0.0; + + + template Multiplier2 () {} + template Multiplier2 () {} + "# + .to_string(); + + let syntax = SyntaxTreeBuilder::syntax_tree(&source); + + if let Some(ast) = AstCircomProgram::cast(syntax) { + let templates = ast.template_list(); + let first_id = templates[0].syntax().token_id(); + let second_id = templates[1].syntax().token_id(); + + assert_eq!(first_id, second_id); + } + } + #[test] + fn off_set_test() { + let str = r#" +one +two +three + "#; + + let file_utils = FileDB::new( + FileId(1), + str, + Url::from_file_path(Path::new("/tmp.txt")).unwrap(), + ); + + let position = Position::new(0, 1); + + assert_eq!(file_utils.off_set(position), 1.into()); + + let position = Position::new(1, 1); + + assert_eq!(file_utils.off_set(position), 2.into()); + } + + #[test] + fn position_test() { + let str = r#" + one + two + three + "#; + + // 0, 4, 8 + let file_utils = FileDB::new( + FileId(1), + str, + Url::from_file_path(Path::new("/tmp.txt")).unwrap(), + ); + assert_eq!(Position::new(1, 1), file_utils.position(2.into())); + assert_eq!(Position::new(0, 0), file_utils.position(0.into())); + } +} diff --git a/crates/lsp/src/global_state.rs b/crates/lsp/src/global_state.rs index 40ecb64..c8f6bf4 100644 --- a/crates/lsp/src/global_state.rs +++ b/crates/lsp/src/global_state.rs @@ -1,171 +1,171 @@ -use std::{fs, path::PathBuf}; - -use crate::{ - database::{FileDB, SemanticDB}, - handler::goto_definition::lookup_node_wrap_token, -}; -use anyhow::Result; -use dashmap::DashMap; -use lsp_server::{RequestId, Response}; -use lsp_types::{ - DidChangeTextDocumentParams, DidOpenTextDocumentParams, GotoDefinitionParams, - GotoDefinitionResponse, Location, Url, -}; - -use parser::token_kind::TokenKind; -use rowan::ast::AstNode; -use syntax::abstract_syntax_tree::AstCircomProgram; -use syntax::syntax::SyntaxTreeBuilder; -use syntax::syntax_node::SyntaxToken; - -use crate::handler::goto_definition::{lookup_definition, lookup_token_at_postion}; - -#[derive(Debug)] -pub struct TextDocument { - text: String, - uri: Url, -} - -impl From for TextDocument { - fn from(value: DidOpenTextDocumentParams) -> Self { - Self { - text: value.text_document.text, - uri: value.text_document.uri, - } - } -} - -impl From for TextDocument { - fn from(value: DidChangeTextDocumentParams) -> Self { - Self { - text: value.content_changes[0].text.to_string(), - uri: value.text_document.uri, - } - } -} - -pub struct GlobalState { - pub ast_map: DashMap, - pub file_map: DashMap, - pub db: SemanticDB, -} - -impl Default for GlobalState { - fn default() -> Self { - Self::new() - } -} - -impl GlobalState { - pub fn new() -> Self { - Self { - ast_map: DashMap::new(), - file_map: DashMap::new(), - db: SemanticDB::new(), - } - } - - pub fn lookup_definition( - &self, - root: &FileDB, - ast: &AstCircomProgram, - token: &SyntaxToken, - ) -> Vec { - let semantic_data = self.db.semantic.get(&root.file_id).unwrap(); - let mut result = lookup_definition(root, ast, semantic_data, token); - - if token.kind() == TokenKind::CircomString { - return result; - } - - let p = root.get_path(); - - if lookup_node_wrap_token(TokenKind::ComponentDecl, token).is_some() - || lookup_node_wrap_token(TokenKind::ComponentCall, token).is_some() - { - for lib in ast.libs() { - let lib_abs_path = PathBuf::from(lib.lib().unwrap().value()); - let lib_path = p.parent().unwrap().join(lib_abs_path).clone(); - let lib_url = Url::from_file_path(lib_path.clone()).unwrap(); - - if let Some(file_lib) = self.file_map.get(&lib_url.to_string()) { - let ast_lib = self.ast_map.get(&lib_url.to_string()).unwrap(); - if let Some(semantic_data_lib) = self.db.semantic.get(&file_lib.file_id) { - let lib_result = - lookup_definition(&file_lib, &ast_lib, semantic_data_lib, token); - result.extend(lib_result); - } - } - } - } - result - } - - pub fn goto_definition_handler(&self, id: RequestId, params: GotoDefinitionParams) -> Response { - let uri = params.text_document_position_params.text_document.uri; - - let ast = self.ast_map.get(&uri.to_string()).unwrap(); - let file = self.file_map.get(&uri.to_string()).unwrap(); - - let mut locations = Vec::new(); - - if let Some(token) = - lookup_token_at_postion(&file, &ast, params.text_document_position_params.position) - { - locations = self.lookup_definition(&file, &ast, &token); - }; - - let result: Option = Some(GotoDefinitionResponse::Array(locations)); - - let result = serde_json::to_value(result).unwrap(); - - Response { - id, - result: Some(result), - error: None, - } - } - - pub fn handle_update(&mut self, text_document: &TextDocument) -> Result<()> { - let text = &text_document.text; - let url = &text_document.uri.to_string(); - - let syntax = SyntaxTreeBuilder::syntax_tree(text); - let file_db = FileDB::create(text, text_document.uri.clone()); - let file_id = file_db.file_id; - - let p: PathBuf = file_db.get_path(); - if let Some(ast) = AstCircomProgram::cast(syntax) { - self.db.semantic.remove(&file_id); - self.db.circom_program_semantic(&file_db, &ast); - - for lib in ast.libs() { - if let Some(lib_abs_path) = lib.lib() { - let lib_path = p.parent().unwrap().join(lib_abs_path.value()).clone(); - let lib_url = Url::from_file_path(lib_path.clone()).unwrap(); - if let Ok(src) = fs::read_to_string(lib_path) { - let text_doc = TextDocument { - text: src, - uri: lib_url.clone(), - }; - let lib_file = FileDB::create(&text_doc.text, lib_url.clone()); - let syntax = SyntaxTreeBuilder::syntax_tree(&text_doc.text); - - if let Some(lib_ast) = AstCircomProgram::cast(syntax) { - self.db.semantic.remove(&lib_file.file_id); - self.db.circom_program_semantic(&lib_file, &lib_ast); - self.ast_map.insert(lib_url.to_string(), lib_ast); - } - - self.file_map.insert(lib_url.to_string(), lib_file); - } - } - } - self.ast_map.insert(url.to_string(), ast); - } - - self.file_map.insert(url.to_string(), file_db); - - Ok(()) - } -} +use std::{fs, path::PathBuf}; + +use crate::{ + database::{FileDB, SemanticDB}, + handler::goto_definition::lookup_node_wrap_token, +}; +use anyhow::Result; +use dashmap::DashMap; +use lsp_server::{RequestId, Response}; +use lsp_types::{ + DidChangeTextDocumentParams, DidOpenTextDocumentParams, GotoDefinitionParams, + GotoDefinitionResponse, Location, Url, +}; + +use parser::token_kind::TokenKind; +use rowan::ast::AstNode; +use syntax::abstract_syntax_tree::AstCircomProgram; +use syntax::syntax::SyntaxTreeBuilder; +use syntax::syntax_node::SyntaxToken; + +use crate::handler::goto_definition::{lookup_definition, lookup_token_at_postion}; + +#[derive(Debug)] +pub struct TextDocument { + text: String, + uri: Url, +} + +impl From for TextDocument { + fn from(value: DidOpenTextDocumentParams) -> Self { + Self { + text: value.text_document.text, + uri: value.text_document.uri, + } + } +} + +impl From for TextDocument { + fn from(value: DidChangeTextDocumentParams) -> Self { + Self { + text: value.content_changes[0].text.to_string(), + uri: value.text_document.uri, + } + } +} + +pub struct GlobalState { + pub ast_map: DashMap, + pub file_map: DashMap, + pub db: SemanticDB, +} + +impl Default for GlobalState { + fn default() -> Self { + Self::new() + } +} + +impl GlobalState { + pub fn new() -> Self { + Self { + ast_map: DashMap::new(), + file_map: DashMap::new(), + db: SemanticDB::new(), + } + } + + pub fn lookup_definition( + &self, + root: &FileDB, + ast: &AstCircomProgram, + token: &SyntaxToken, + ) -> Vec { + let semantic_data = self.db.semantic.get(&root.file_id).unwrap(); + let mut result = lookup_definition(root, ast, semantic_data, token); + + if token.kind() == TokenKind::CircomString { + return result; + } + + let p = root.get_path(); + + if lookup_node_wrap_token(TokenKind::ComponentDecl, token).is_some() + || lookup_node_wrap_token(TokenKind::ComponentCall, token).is_some() + { + for lib in ast.libs() { + let lib_abs_path = PathBuf::from(lib.lib().unwrap().value()); + let lib_path = p.parent().unwrap().join(lib_abs_path).clone(); + let lib_url = Url::from_file_path(lib_path.clone()).unwrap(); + + if let Some(file_lib) = self.file_map.get(&lib_url.to_string()) { + let ast_lib = self.ast_map.get(&lib_url.to_string()).unwrap(); + if let Some(semantic_data_lib) = self.db.semantic.get(&file_lib.file_id) { + let lib_result = + lookup_definition(&file_lib, &ast_lib, semantic_data_lib, token); + result.extend(lib_result); + } + } + } + } + result + } + + pub fn goto_definition_handler(&self, id: RequestId, params: GotoDefinitionParams) -> Response { + let uri = params.text_document_position_params.text_document.uri; + + let ast = self.ast_map.get(&uri.to_string()).unwrap(); + let file = self.file_map.get(&uri.to_string()).unwrap(); + + let mut locations = Vec::new(); + + if let Some(token) = + lookup_token_at_postion(&file, &ast, params.text_document_position_params.position) + { + locations = self.lookup_definition(&file, &ast, &token); + }; + + let result: Option = Some(GotoDefinitionResponse::Array(locations)); + + let result = serde_json::to_value(result).unwrap(); + + Response { + id, + result: Some(result), + error: None, + } + } + + pub fn handle_update(&mut self, text_document: &TextDocument) -> Result<()> { + let text = &text_document.text; + let url = &text_document.uri.to_string(); + + let syntax = SyntaxTreeBuilder::syntax_tree(text); + let file_db = FileDB::create(text, text_document.uri.clone()); + let file_id = file_db.file_id; + + let p: PathBuf = file_db.get_path(); + if let Some(ast) = AstCircomProgram::cast(syntax) { + self.db.semantic.remove(&file_id); + self.db.circom_program_semantic(&file_db, &ast); + + for lib in ast.libs() { + if let Some(lib_abs_path) = lib.lib() { + let lib_path = p.parent().unwrap().join(lib_abs_path.value()).clone(); + let lib_url = Url::from_file_path(lib_path.clone()).unwrap(); + if let Ok(src) = fs::read_to_string(lib_path) { + let text_doc = TextDocument { + text: src, + uri: lib_url.clone(), + }; + let lib_file = FileDB::create(&text_doc.text, lib_url.clone()); + let syntax = SyntaxTreeBuilder::syntax_tree(&text_doc.text); + + if let Some(lib_ast) = AstCircomProgram::cast(syntax) { + self.db.semantic.remove(&lib_file.file_id); + self.db.circom_program_semantic(&lib_file, &lib_ast); + self.ast_map.insert(lib_url.to_string(), lib_ast); + } + + self.file_map.insert(lib_url.to_string(), lib_file); + } + } + } + self.ast_map.insert(url.to_string(), ast); + } + + self.file_map.insert(url.to_string(), file_db); + + Ok(()) + } +} diff --git a/crates/lsp/src/handler/goto_definition.rs b/crates/lsp/src/handler/goto_definition.rs index 4cba681..feb8302 100644 --- a/crates/lsp/src/handler/goto_definition.rs +++ b/crates/lsp/src/handler/goto_definition.rs @@ -1,263 +1,236 @@ -use lsp_types::Location; -use lsp_types::Position; -use lsp_types::Range; -use lsp_types::Url; -use parser::token_kind::TokenKind; -use rowan::ast::AstNode; -use rowan::SyntaxText; - -use syntax::abstract_syntax_tree::AstComponentCall; -use syntax::abstract_syntax_tree::AstInclude; -use syntax::abstract_syntax_tree::AstTemplateDef; -use syntax::abstract_syntax_tree::AstTemplateName; -use syntax::abstract_syntax_tree::{AstCircomProgram, AstComponentDecl}; -use syntax::syntax_node::SyntaxNode; -use syntax::syntax_node::SyntaxToken; - -use crate::database::{FileDB, SemanticData, TokenId}; - -pub fn lookup_node_wrap_token(ast_type: TokenKind, token: &SyntaxToken) -> Option { - let mut p = token.parent(); - while let Some(t) = p { - if t.kind() == ast_type { - return Some(t); - } - p = t.parent(); - } - None -} - -pub fn lookup_token_at_postion( - file: &FileDB, - ast: &AstCircomProgram, - position: Position, -) -> Option { - let off_set = file.off_set(position); - ast.syntax().token_at_offset(off_set).find_map(|token| { - let kind = token.kind(); - - if kind == TokenKind::Identifier { - return Some(token); - } - - if kind == TokenKind::CircomString { - return Some(token); - } - None - }) -} - -pub fn lookup_component(template: &AstTemplateDef, text: SyntaxText) -> Option { - if let Some(statements) = template.statements() { - for component in statements.find_children::() { - if let Some(iden) = component.component_identifier() { - if iden.name().unwrap().syntax().text() == text { - return component.template(); - } - } - } - } - None -} - -pub fn jump_to_lib(file: &FileDB, token: &SyntaxToken) -> Vec { - if let Some(include_lib) = lookup_node_wrap_token(TokenKind::IncludeKw, token) { - if let Some(ast_include) = AstInclude::cast(include_lib) { - if let Some(abs_lib_ans) = ast_include.lib() { - let lib_path = file - .get_path() - .parent() - .unwrap() - .join(abs_lib_ans.value()) - .clone(); - let lib_url = Url::from_file_path(lib_path.clone()).unwrap(); - return vec![Location::new(lib_url, Range::default())]; - } - } - } - - Vec::new() -} - -pub fn lookup_definition( - file: &FileDB, - ast: &AstCircomProgram, - semantic_data: &SemanticData, - token: &SyntaxToken, -) -> Vec { - let template_list = ast.template_list(); - - let mut res = Vec::new(); - - if token.kind() == TokenKind::CircomString { - return jump_to_lib(file, token); - } - - let mut signal_outside = false; - - if let Some(component_call) = lookup_node_wrap_token(TokenKind::ComponentCall, token) { - // find template called. - if let Some(ast_component_call) = AstComponentCall::cast(component_call) { - if let Some(signal) = ast_component_call.signal() { - if signal.syntax().text() == token.text() { - signal_outside = true; - // lookup template of componenet - if let Some(current_template) = - lookup_node_wrap_token(TokenKind::TemplateDef, token) - { - if let Some(ast_template_name) = lookup_component( - &AstTemplateDef::cast(current_template).unwrap(), - ast_component_call.component_name().unwrap().syntax().text(), - ) { - if let Some(other_template) = - ast.get_template_by_name(&ast_template_name) - { - let template_id = other_template.syntax().token_id(); - if let Some(semantic) = - semantic_data.template_data_semantic.get(&template_id) - { - if let Some(tmp) = - semantic.signal.0.get(&signal.syntax().token_id()) - { - res.extend(tmp) - } - } - } - } - } - } - } - } - } - - if !signal_outside { - for template in template_list { - let template_name = template.name().unwrap(); - if template_name.name().unwrap().syntax().text() == token.text() { - let range = file.range(template.syntax()); - res.push(range); - } - - if !template - .syntax() - .text_range() - .contains_range(token.text_range()) - { - continue; - } - - let template_id = template.syntax().token_id(); - - if let Some(data) = semantic_data.lookup_signal(template_id, token) { - res.extend(data); - } - - if let Some(data) = semantic_data.lookup_variable(template_id, token) { - res.extend(data); - } - - if let Some(component_decl) = semantic_data.lookup_component(template_id, token) { - res.extend(component_decl); - } - } - } - - res.into_iter() - .map(|range| Location::new(file.file_path.clone(), range)) - .collect() -} - -#[cfg(test)] -mod tests { - use std::path::Path; - - use lsp_types::Url; - use parser::token_kind::TokenKind; - use rowan::ast::AstNode; - use syntax::{ - abstract_syntax_tree::{AstCircomProgram, AstInputSignalDecl}, - syntax::SyntaxTreeBuilder, - }; - - use crate::{database::FileDB, handler::goto_definition::lookup_node_wrap_token}; - - use super::lookup_token_at_postion; - - #[test] - fn goto_decl_test() { - let source = r#" - pragma circom 2.0.0; - - template X() { - signal x = 10; - signal input x = 10; - component x = Multiplier2(); - component y = X(); - component y = Multiplier2(); - component z = Multiplier2(); - - } -template M() { - component h = X(); - component k = Multiplier2(); - test - } -template Multiplier2 () { - template m = M(); - // hello world - signal input a; - signal input b; - signal output c; - component y = X(); - - mintlkrekerjke; - component e = Y(); - component z = Y(); - component h = Y(); - signal output d; - c <== a * b; - } -template Y() { - component y = X(); - component a = X(); - - } - "# - .to_string(); - - let file = FileDB::create(&source, Url::from_file_path(Path::new("/tmp")).unwrap()); - - let syntax_node = SyntaxTreeBuilder::syntax_tree(&source); - - if let Some(program_ast) = AstCircomProgram::cast(syntax_node) { - for template in program_ast.template_list() { - println!("{template:?}"); - } - - let inputs = program_ast.template_list()[0] - .func_body() - .unwrap() - .statement_list() - .unwrap() - .find_children::(); - let signal_name = inputs[0].name().unwrap(); - - let tmp = signal_name.syntax().text_range().start(); - - if let Some(token) = lookup_token_at_postion(&file, &program_ast, file.position(tmp)) { - println!( - "{:#?}", - lookup_node_wrap_token(TokenKind::TemplateDef, &token) - ); - } - } - } - - #[test] - fn url_test() { - let url = Url::from_file_path(Path::new("/hello/abc.tx")); - let binding = url.unwrap(); - let p = binding.path(); - println!("{:?}", Path::new(p).parent()); - } -} +use lsp_types::Location; +use lsp_types::Position; +use lsp_types::Range; +use lsp_types::Url; +use parser::token_kind::TokenKind; +use rowan::ast::AstNode; +use rowan::SyntaxText; + +use syntax::abstract_syntax_tree::AstComponentCall; +use syntax::abstract_syntax_tree::AstInclude; +use syntax::abstract_syntax_tree::AstTemplateDef; +use syntax::abstract_syntax_tree::AstTemplateName; +use syntax::abstract_syntax_tree::{AstCircomProgram, AstComponentDecl}; +use syntax::syntax_node::SyntaxNode; +use syntax::syntax_node::SyntaxToken; + +use crate::database::{FileDB, SemanticData, TokenId}; + +pub fn lookup_node_wrap_token(ast_type: TokenKind, token: &SyntaxToken) -> Option { + let mut p = token.parent(); + while let Some(t) = p { + if t.kind() == ast_type { + return Some(t); + } + p = t.parent(); + } + None +} + +pub fn lookup_token_at_postion( + file: &FileDB, + ast: &AstCircomProgram, + position: Position, +) -> Option { + let off_set = file.off_set(position); + ast.syntax().token_at_offset(off_set).find_map(|token| { + let kind = token.kind(); + + if kind == TokenKind::Identifier { + return Some(token); + } + + if kind == TokenKind::CircomString { + return Some(token); + } + None + }) +} + +pub fn lookup_component(template: &AstTemplateDef, text: SyntaxText) -> Option { + if let Some(statements) = template.statements() { + for component in statements.find_children::() { + if let Some(iden) = component.component_identifier() { + if iden.name().unwrap().syntax().text() == text { + return component.template(); + } + } + } + } + None +} + +pub fn jump_to_lib(file: &FileDB, token: &SyntaxToken) -> Vec { + if let Some(include_lib) = lookup_node_wrap_token(TokenKind::IncludeKw, token) { + if let Some(ast_include) = AstInclude::cast(include_lib) { + if let Some(abs_lib_ans) = ast_include.lib() { + let lib_path = file + .get_path() + .parent() + .unwrap() + .join(abs_lib_ans.value()) + .clone(); + let lib_url = Url::from_file_path(lib_path.clone()).unwrap(); + return vec![Location::new(lib_url, Range::default())]; + } + } + } + + Vec::new() +} + +pub fn lookup_definition( + file: &FileDB, + ast: &AstCircomProgram, + semantic_data: &SemanticData, + token: &SyntaxToken, +) -> Vec { + let template_list = ast.template_list(); + + let mut res = Vec::new(); + + if token.kind() == TokenKind::CircomString { + return jump_to_lib(file, token); + } + + let mut signal_outside = false; + + if let Some(component_call) = lookup_node_wrap_token(TokenKind::ComponentCall, token) { + // find template called. + if let Some(ast_component_call) = AstComponentCall::cast(component_call) { + if let Some(signal) = ast_component_call.signal() { + if signal.syntax().text() == token.text() { + signal_outside = true; + // lookup template of componenet + if let Some(current_template) = + lookup_node_wrap_token(TokenKind::TemplateDef, token) + { + if let Some(ast_template_name) = lookup_component( + &AstTemplateDef::cast(current_template).unwrap(), + ast_component_call.component_name().unwrap().syntax().text(), + ) { + if let Some(other_template) = + ast.get_template_by_name(&ast_template_name) + { + let template_id = other_template.syntax().token_id(); + if let Some(semantic) = + semantic_data.template_data_semantic.get(&template_id) + { + if let Some(tmp) = + semantic.signal.0.get(&signal.syntax().token_id()) + { + res.extend(tmp) + } + } + } + } + } + } + } + } + } + + if !signal_outside { + for template in template_list { + let template_name = template.name().unwrap(); + if template_name.name().unwrap().syntax().text() == token.text() { + let range = file.range(template.syntax()); + res.push(range); + } + + if !template + .syntax() + .text_range() + .contains_range(token.text_range()) + { + continue; + } + + let template_id = template.syntax().token_id(); + + if let Some(data) = semantic_data.lookup_signal(template_id, token) { + res.extend(data); + } + + if let Some(data) = semantic_data.lookup_variable(template_id, token) { + res.extend(data); + } + + if let Some(component_decl) = semantic_data.lookup_component(template_id, token) { + res.extend(component_decl); + } + } + } + + res.into_iter() + .map(|range| Location::new(file.file_path.clone(), range)) + .collect() +} + +#[cfg(test)] +mod tests { + use std::path::Path; + + use lsp_types::Url; + use parser::token_kind::TokenKind; + use rowan::ast::AstNode; + use syntax::{ + abstract_syntax_tree::{AstCircomProgram, AstInputSignalDecl}, + syntax::SyntaxTreeBuilder, + }; + + use crate::{database::FileDB, handler::goto_definition::lookup_node_wrap_token}; + + use super::lookup_token_at_postion; + + fn get_source_from_path(file_path: &str) -> String { + let crate_path = std::env::var("CARGO_MANIFEST_DIR").unwrap(); + let full_path = format!("{}{}", crate_path, file_path); + let source = std::fs::read_to_string(&full_path).expect(&full_path); + + source + } + + #[test] + fn goto_decl_test() { + let file_path = "/src/test_files/handler/templates.circom"; + let source = get_source_from_path(file_path); + + let file = FileDB::create(&source, Url::from_file_path(Path::new("/tmp")).unwrap()); + + let syntax_node = SyntaxTreeBuilder::syntax_tree(&source); + + if let Some(program_ast) = AstCircomProgram::cast(syntax_node) { + let inputs = program_ast.template_list()[0] + .func_body() + .unwrap() + .statement_list() + .unwrap() + .find_children::(); + let signal_name = inputs[0].signal_identifier().unwrap().name().unwrap(); + + let tmp = signal_name.syntax().text_range().start(); + + if let Some(token) = lookup_token_at_postion(&file, &program_ast, file.position(tmp)) { + let wrap_token = lookup_node_wrap_token(TokenKind::TemplateDef, &token); + + let string_syntax_node = match wrap_token { + None => "None".to_string(), + Some(syntax_node) => format!("{}", syntax_node), + }; + + insta::assert_snapshot!("test_lookup_node_wrap_token", string_syntax_node); + } + } + } + + #[test] + fn url_test() { + let url = Url::from_file_path(Path::new("/hello/abc.tx")); + let binding = url.unwrap(); + let path = binding.path(); + let parent = Path::new(path).parent().unwrap().to_str().unwrap(); + + assert_eq!("/hello", parent); + } +} diff --git a/crates/lsp/src/handler/snapshots/ccls__handler__goto_definition__tests__test_lookup_node_wrap_token.snap b/crates/lsp/src/handler/snapshots/ccls__handler__goto_definition__tests__test_lookup_node_wrap_token.snap new file mode 100644 index 0000000..22acca3 --- /dev/null +++ b/crates/lsp/src/handler/snapshots/ccls__handler__goto_definition__tests__test_lookup_node_wrap_token.snap @@ -0,0 +1,13 @@ +--- +source: crates/lsp/src/handler/goto_definition.rs +expression: string_syntax_node +--- +template X() { + signal x[100]; + signal input x expect Semicolon but got Assign= expect Semicolon but got Number10; + component x = Multiplier2(); + component y = X(); + component y = Multiplier2(); + component z = Multiplier2(); + + } diff --git a/crates/lsp/src/test_files/handler/templates.circom b/crates/lsp/src/test_files/handler/templates.circom new file mode 100644 index 0000000..f47a902 --- /dev/null +++ b/crates/lsp/src/test_files/handler/templates.circom @@ -0,0 +1,36 @@ +pragma circom 2.0.0; + + template X() { + signal x[100]; + signal input x = 10; + component x = Multiplier2(); + component y = X(); + component y = Multiplier2(); + component z = Multiplier2(); + + } +template M() { + component h = X(); + component k = Multiplier2(); + test + } +template Multiplier2 () { + template m = M(); + // hello world + signal input a; + signal input b; + signal output c; + component y = X(); + + mintlkrekerjke; + component e = Y(); + component z = Y(); + component h = Y(); + signal output d; + c <== a * b; + } +template Y() { + component y = X(); + component a = X(); + + } \ No newline at end of file diff --git a/crates/parser/src/grammar.rs b/crates/parser/src/grammar.rs index a0c9f53..3b759dc 100644 --- a/crates/parser/src/grammar.rs +++ b/crates/parser/src/grammar.rs @@ -1,67 +1,67 @@ -use crate::parser::Parser; -use crate::token_kind::TokenKind::*; - -mod block; -mod declaration; -mod expression; -mod function; -mod include; -mod list_identity; -mod main_component; -mod pragma; -mod statement; -mod template; - -/** - * parse circom program - */ - -pub mod entry { - - use crate::token_kind::TokenKind; - - use super::*; - - pub fn circom_program(p: &mut Parser) { - let m = p.open(); - - while p.at_any(&[ - TokenKind::BlockComment, - TokenKind::CommentLine, - TokenKind::EndLine, - TokenKind::WhiteSpace, - ]) { - p.skip(); - } - - while !p.eof() { - match p.current() { - Pragma => pragma::pragma(p), - TemplateKw => template::template(p), - IncludeKw => include::include(p), - ComponentKw => main_component::main_component(p), - FunctionKw => function::function_parse(p), - _ => p.advance_with_error("invalid token"), - } - } - p.close(m, CircomProgram); - } - - pub enum Scope { - Block, - CircomProgram, - Pragma, - Template, - } - - impl Scope { - pub fn parse(self, p: &mut Parser) { - match self { - Self::Block => block::block(p), - Self::CircomProgram => circom_program(p), - Self::Pragma => pragma::pragma(p), - Self::Template => template::template(p), - } - } - } -} +use crate::parser::Parser; +use crate::token_kind::TokenKind::*; + +mod block; +mod declaration; +mod expression; +mod function; +mod include; +mod list_identity; +mod main_component; +mod pragma; +mod statement; +mod template; + +/** + * parse circom program + */ + +pub mod entry { + + use crate::token_kind::TokenKind; + + use super::*; + + pub fn circom_program(p: &mut Parser) { + let m = p.open(); + + while p.at_any(&[ + TokenKind::BlockComment, + TokenKind::CommentLine, + TokenKind::EndLine, + TokenKind::WhiteSpace, + ]) { + p.skip(); + } + + while !p.eof() { + match p.current() { + PragmaKw => pragma::pragma(p), + TemplateKw => template::template(p), + IncludeKw => include::include(p), + ComponentKw => main_component::main_component(p), + FunctionKw => function::function_parse(p), + _ => p.advance_with_error("invalid token"), + } + } + p.close(m, CircomProgram); + } + + pub enum Scope { + Block, + CircomProgram, + Pragma, + Template, + } + + impl Scope { + pub fn parse(self, p: &mut Parser) { + match self { + Self::Block => block::block(p), + Self::CircomProgram => circom_program(p), + Self::Pragma => pragma::pragma(p), + Self::Template => template::template(p), + } + } + } +} diff --git a/crates/parser/src/grammar/block.rs b/crates/parser/src/grammar/block.rs index c6317d5..8932bf0 100644 --- a/crates/parser/src/grammar/block.rs +++ b/crates/parser/src/grammar/block.rs @@ -1,47 +1,49 @@ -use super::*; - -/* -{ - / - / - .... - / -} -*/ -pub fn block(p: &mut Parser) { - p.inc_rcurly(); - - if !p.at(LCurly) { - p.advance_with_error("Miss {"); - } else { - let m = p.open(); - p.expect(LCurly); - let stmt_marker = p.open(); - while !p.at(RCurly) && !p.eof() { - let kind = p.current(); - match kind { - SignalKw => { - declaration::signal_declaration(p); - p.expect(Semicolon); - } - VarKw => { - declaration::var_declaration(p); - p.expect(Semicolon); - } - ComponentKw => { - declaration::component_declaration(p); - p.expect(Semicolon); - } - _ => statement::statement(p), - } - } - - p.close(stmt_marker, StatementList); - - p.expect(RCurly); - - p.close(m, Block); - - p.dec_rcurly(); - } -} +use super::*; + +/* +{ + / + / + .... + / +} +*/ +pub fn block(p: &mut Parser) { + p.inc_rcurly(); + + // TODO: why do not use expect for { and } + if !p.at(LCurly) { + p.advance_with_error("Miss {"); + } else { + let m = p.open(); + p.expect(LCurly); + + let stmt_marker = p.open(); + while !p.at(RCurly) && !p.eof() { + let kind = p.current(); + match kind { + SignalKw => { + declaration::signal_declaration(p); + p.expect(Semicolon); + } + VarKw => { + declaration::var_declaration(p); + p.expect(Semicolon); + } + ComponentKw => { + declaration::component_declaration(p); + p.expect(Semicolon); + } + _ => statement::statement(p), + } + } + + p.close(stmt_marker, StatementList); + + p.expect(RCurly); + + p.close(m, Block); + + p.dec_rcurly(); + } +} diff --git a/crates/parser/src/grammar/declaration.rs b/crates/parser/src/grammar/declaration.rs index c5dd125..f9f809a 100644 --- a/crates/parser/src/grammar/declaration.rs +++ b/crates/parser/src/grammar/declaration.rs @@ -1,66 +1,125 @@ use super::{ - expression::{tuple, tuple_init}, + expression::{expression, tuple, tuple_init}, *, }; -// "signal" --> None -// "signal input" --> Some(true) -// "signal output" --> Some(false) +// [N][M-1] +fn array(p: &mut Parser) -> bool { + let is_array = p.at(LBracket); + + while p.at(LBracket) { + p.expect(LBracket); + expression(p); + p.expect(RBracket); + } + + is_array +} + +/* +"signal" --> None +"signal input" --> Some(true) +"signal output" --> Some(false) +*/ fn signal_header(p: &mut Parser) -> Option { - let mut res = None; let m = p.open(); p.expect(SignalKw); - if p.at_any(&[InputKw, OutputKw]) { - if p.at(InputKw) { - res = Some(true); - } else { - res = Some(false); - } + + let res = if p.at(InputKw) { + Some(true) + } else if p.at(OutputKw) { + Some(false) + } else { + None + }; + + if res.is_some() { p.advance(); + } - if p.at(LCurly) { - p.expect(Identifier); - p.expect(RCurly); - } + // signal tags + // {tag1, tag2, tag2} + // TODO: support list of tags + if p.at(LCurly) { + p.expect(Identifier); + p.expect(RCurly); } + p.close(m, SignalHeader); res } +pub(crate) fn var_init(p: &mut Parser) { + let var_identifier_open_marker = p.open(); + + // name of variable + p.expect(Identifier); + // eg: [N - 1][M] + array(p); + + p.close(var_identifier_open_marker, VarIdentifier); + + // assign for variable + // eg: = 10 + if p.at_var_assign() { + p.advance(); + expression(p); + } +} + +// eg: in[N - 1] <== c.in; +pub(crate) fn signal_init(p: &mut Parser, assign_able: bool) { + let signal_identifier_open_marker = p.open(); + // name of signal + p.expect(Identifier); + // eg: [N][M-1] + array(p); + p.close(signal_identifier_open_marker, SignalIdentifier); + + // assign for intermediate and outputs signals + // eg: <== Multiplier2().out + if assign_able && p.at_inline_assign_signal() { + p.advance(); + expression(p); + } +} + /** * Declaration := "var" (SimpleSymbol, ..., SimpleSymbol) TupleInitialization | - * - * + * "var" iden1 = init1, iden2 = init2, iden3 */ pub(super) fn var_declaration(p: &mut Parser) { let m = p.open(); p.expect(VarKw); + // tuple of variables + // eg: var (in1, in2, in3) = (1, 2, 3); if p.at(LParen) { tuple(p); - if p.at(Assign) { + if p.at_var_assign() { tuple_init(p); } } else { - p.expect(Identifier); - if p.at(Assign) { - p.expect(Assign); - expression::expression(p); - } - // list of var + // list of variables + // var in1[N], in2 = 5; + var_init(p); while p.at(Comma) && !p.eof() { - p.expect(Comma); - p.expect(Identifier); - if p.at(Assign) { - p.expect(Assign); - expression::expression(p); - } + p.skip(); + var_init(p); } } + p.close(m, VarDecl); } +/* +* signal are immutable (can not modify after init value) +* can not initialize value for input signal +* since circom 2.0.4, it is also allowed to initialize +intermediate and outputs signals right after their declaration +*/ pub(super) fn signal_declaration(p: &mut Parser) { + // TODO: can we remove that? if !p.at(SignalKw) { p.advance_with_error("Signal error"); return; @@ -68,54 +127,65 @@ pub(super) fn signal_declaration(p: &mut Parser) { let m = p.open(); let io_signal = signal_header(p); + let assign_able = io_signal != Some(true); + // tuple of signal + // eg: signal (in1, in2, in3) <== tuple_value; if p.at(LParen) { tuple(p); - if p.at_any(&[Assign, RAssignSignal, RAssignConstraintSignal]) { + // can not assign for input signal + if assign_able && p.at_inline_assign_signal() { tuple_init(p); } } else { - p.expect(Identifier); - // list of var + // list of signals + // signal in1[N], in2 <== signal_value; + signal_init(p, assign_able); while p.at(Comma) && !p.eof() { p.skip(); - p.expect(Identifier); + signal_init(p, assign_able); } } - if let Some(is_input) = io_signal { - if is_input { - p.close(m, InputSignalDecl); - } else { - p.close(m, OutputSignalDecl); - } - } else { - p.close(m, SignalDecl); - } + let close_kind = match io_signal { + Some(true) => InputSignalDecl, + Some(false) => OutputSignalDecl, + None => SignalDecl, + }; + + p.close(m, close_kind); } +/* +* initialization in the definition of arrays of components is not allowed +*/ pub(super) fn component_declaration(p: &mut Parser) { let m = p.open(); p.expect(ComponentKw); + let m_c = p.open(); p.expect(Identifier); + + // support array component + // eg: comp[N - 1][10] + let is_array = array(p); p.close(m_c, ComponentIdentifier); - p.expect(Assign); - let m_c = p.open(); - p.expect(Identifier); - p.close(m_c, TemplateName); - p.expect(LParen); - - if p.at(Identifier) { - expression::expression(p); - while !p.at(RParen) && !p.eof() { - p.expect(Comma); - expression::expression(p); - } - } + // do not assign for array components + if !is_array && p.at(Assign) { + p.expect(Assign); - p.expect(RParen); + // TODO: support `parallel` tag + // eg: component comp = parallel NameTemplate(...){...} + + // template name + let m_c = p.open(); + p.expect(Identifier); + p.close(m_c, TemplateName); + + // template params + tuple(p); + } p.close(m, ComponentDecl); } diff --git a/crates/parser/src/grammar/expression.rs b/crates/parser/src/grammar/expression.rs index 4604da4..c53c09c 100644 --- a/crates/parser/src/grammar/expression.rs +++ b/crates/parser/src/grammar/expression.rs @@ -1,158 +1,175 @@ -use crate::parser::Marker; - -use super::*; - -pub(super) fn expression(p: &mut Parser) { - let m = p.open(); - circom_expression(p); - p.close(m, Expression); -} - -/** - * grammar: "(Symbol_1, Symbol_2,..., Symbol_n)" - */ -pub(super) fn tuple(p: &mut Parser) { - let m = p.open(); - p.expect(LParen); - p.expect(Identifier); - while p.at(Comma) && !p.eof() { - p.expect(Comma); - p.expect(Identifier); - } - p.expect(RParen); - p.close(m, Tuple); -} - -/** - * grammar: - * "= | <== | <--" expression - */ -pub(super) fn tuple_init(p: &mut Parser) { - let m = p.open(); - p.expect_any(&[Assign, RAssignSignal, RAssignConstraintSignal]); - expression(p); - p.close(m, TupleInit); -} - -fn expression_atom(p: &mut Parser) -> Option { - let m_close: Marker; - match p.current() { - Number => { - let m = p.open(); - p.advance(); - m_close = p.close(m, Number); - Some(m_close) - } - Identifier => { - let m = p.open(); - p.advance(); - m_close = p.close(m, Identifier); - Some(m_close) - } - LParen => { - let m = p.open(); - p.expect(LParen); - expression_rec(p, 0); - p.expect(RParen); - m_close = p.close(m, Tuple); - Some(m_close) - } - _ => { - p.advance_with_error("Invalid Token"); - None - } - } -} - -/** - * return marker which bound the expression - */ -pub fn expression_rec(p: &mut Parser, pb: u16) -> Option { - let parse_able: Option = if let Some(pp) = p.current().prefix() { - let kind = p.current(); - let m = p.open(); - p.advance(); - expression_rec(p, pp); - Some(p.close(m, kind)) - } else { - expression_atom(p) - }; - - parse_able?; - - let mut lhs = parse_able.unwrap(); - - // TODO: function call - if p.at(LParen) { - let m = p.open_before(lhs); - tuple(p); - lhs = p.close(m, Call); - } - - while !p.eof() { - let current_kind = p.current(); - if let Some((lp, rp)) = current_kind.infix() { - if rp <= pb { - return None; - } - - let m = p.open_before(lhs); - p.advance(); - expression_rec(p, lp); - lhs = p.close(m, current_kind); - - continue; - } - if let Some(pp) = current_kind.postfix() { - if pp <= pb { - return None; - } - let m = p.open_before(lhs); - p.advance(); - if matches!(current_kind, LBracket) { - expression_rec(p, 0); - p.expect(RBracket); - } else { - p.expect(Identifier); - } - lhs = if matches!(current_kind, Dot) { - p.close(m, ComponentCall) - } else { - p.close(m, ArrayQuery) - }; - - continue; - } - break; - } - Some(lhs) -} - -/** - * circom_expression = expr ? expr: expr | - * expr - */ -fn circom_expression(p: &mut Parser) { - if let Some(mut lhs) = expression_rec(p, 0) { - let current_kind = p.current(); - if matches!(current_kind, MarkQuestion) { - let m = p.open_before(lhs); - lhs = p.close(m, Condition); - - let m = p.open_before(lhs); - p.advance(); - - let first_expression = p.open(); - expression_rec(p, 0); - p.close(first_expression, Expression); - - p.expect(Colon); - - let last_expression = p.open(); - expression_rec(p, 0); - p.close(last_expression, Expression); - - p.close(m, TenaryConditional); - } - } -} +use crate::parser::Marker; + +use super::*; + +pub(super) fn expression(p: &mut Parser) { + let m = p.open(); + circom_expression(p); + p.close(m, Expression); +} + +/** + * grammar: "(param1, param2,..., paramn)" + * can be an empty () + */ +pub(super) fn function_params(p: &mut Parser) { + let m = p.open(); + p.expect(LParen); + + while !p.at(RParen) && !p.eof() { + expression(p); + if p.at(Comma) { + p.expect(Comma) + } else { + break; + } + } + + p.expect(RParen); + // TODO: what kind of it? + p.close(m, Tuple); +} + +/** + * grammar: "(Symbol_1, Symbol_2,..., Symbol_n)" + * can be an empty tuple (for function cal: Mul()) + */ +pub(super) fn tuple(p: &mut Parser) { + let m = p.open(); + p.expect(LParen); + + // iden1, iden2, iden3 + list_identity::parse(p); + + p.expect(RParen); + p.close(m, Tuple); +} + +/** + * grammar: + * "= | <== | <--" expression + */ +pub(super) fn tuple_init(p: &mut Parser) { + let m = p.open(); + p.expect_any(&[Assign, RAssignSignal, RAssignConstraintSignal]); + expression(p); + p.close(m, TupleInit); +} + +fn expression_atom(p: &mut Parser) -> Option { + let m_close: Marker; + match p.current() { + Number | Identifier => { + let m = p.open(); + p.advance(); + m_close = p.close(m, ExpressionAtom); + Some(m_close) + } + LParen => { + let m = p.open(); + p.expect(LParen); + expression_rec(p, 0); + p.expect(RParen); + m_close = p.close(m, Tuple); + Some(m_close) + } + _ => { + p.advance_with_error("Invalid Token"); + None + } + } +} + +/** + * return marker which bound the expression + */ +pub fn expression_rec(p: &mut Parser, pb: u16) -> Option { + let parse_able: Option = if let Some(pp) = p.current().prefix() { + let kind = p.current(); + let m = p.open(); + p.advance(); + expression_rec(p, pp); + Some(p.close(m, kind)) + } else { + expression_atom(p) + }; + + parse_able?; + + let mut lhs = parse_able.unwrap(); + + // TODO: function call + if p.at(LParen) { + let m = p.open_before(lhs); + // tuple(p); + function_params(p); + lhs = p.close(m, Call); + } + + while !p.eof() { + let current_kind = p.current(); + if let Some((lp, rp)) = current_kind.infix() { + if rp <= pb { + return None; + } + + let m = p.open_before(lhs); + p.advance(); + expression_rec(p, lp); + lhs = p.close(m, current_kind); + + continue; + } + if let Some(pp) = current_kind.postfix() { + if pp <= pb { + return None; + } + let m = p.open_before(lhs); + p.advance(); + if matches!(current_kind, LBracket) { + expression_rec(p, 0); + p.expect(RBracket); + } else { + p.expect(Identifier); + } + lhs = if matches!(current_kind, Dot) { + p.close(m, ComponentCall) + } else { + p.close(m, ArrayQuery) + }; + + continue; + } + break; + } + Some(lhs) +} + +/** + * circom_expression = expr ? expr: expr | + * expr + */ +fn circom_expression(p: &mut Parser) { + if let Some(mut lhs) = expression_rec(p, 0) { + let current_kind = p.current(); + if matches!(current_kind, MarkQuestion) { + let m = p.open_before(lhs); + lhs = p.close(m, Condition); + + let m = p.open_before(lhs); + p.advance(); + + let first_expression = p.open(); + expression_rec(p, 0); + p.close(first_expression, Expression); + + p.expect(Colon); + + let last_expression = p.open(); + expression_rec(p, 0); + p.close(last_expression, Expression); + + p.close(m, TenaryConditional); + } + } +} diff --git a/crates/parser/src/grammar/function.rs b/crates/parser/src/grammar/function.rs index 4da6276..249259b 100644 --- a/crates/parser/src/grammar/function.rs +++ b/crates/parser/src/grammar/function.rs @@ -1,22 +1,22 @@ -use crate::grammar::*; - -// fucntion name() -pub fn function_parse(p: &mut Parser) { - let m = p.open(); - - p.expect(FunctionKw); - - let fn_name_marker = p.open(); - p.expect(Identifier); - p.close(fn_name_marker, FunctionName); - - p.expect(LParen); - let arg_marker = p.open(); - list_identity::parse(p); - p.close(arg_marker, ParameterList); - p.expect(RParen); - - block::block(p); - - p.close(m, FunctionDef); -} +use crate::grammar::*; + +// fucntion name() +pub fn function_parse(p: &mut Parser) { + let m = p.open(); + + p.expect(FunctionKw); + + let fn_name_marker = p.open(); + p.expect(Identifier); + p.close(fn_name_marker, FunctionName); + + p.expect(LParen); + let arg_marker = p.open(); + list_identity::parse(p); + p.close(arg_marker, ParameterList); + p.expect(RParen); + + block::block(p); + + p.close(m, FunctionDef); +} diff --git a/crates/parser/src/grammar/list_identity.rs b/crates/parser/src/grammar/list_identity.rs index 73f85c9..ca3214c 100644 --- a/crates/parser/src/grammar/list_identity.rs +++ b/crates/parser/src/grammar/list_identity.rs @@ -1,13 +1,13 @@ -use super::*; - -// a, b, c, d -pub fn parse(p: &mut Parser) { - while p.at(Identifier) && !p.eof() { - p.expect(Identifier); - if p.at(Comma) { - p.expect(Comma) - } else { - break; - } - } -} +use super::*; + +// a, b, c, d +pub fn parse(p: &mut Parser) { + while p.at(Identifier) && !p.eof() { + p.expect(Identifier); + if p.at(Comma) { + p.expect(Comma) + } else { + break; + } + } +} diff --git a/crates/parser/src/grammar/main_component.rs b/crates/parser/src/grammar/main_component.rs index 5129310..fc804f4 100644 --- a/crates/parser/src/grammar/main_component.rs +++ b/crates/parser/src/grammar/main_component.rs @@ -1,22 +1,22 @@ -use super::*; - -/* -component main {public [signal_list]} = tempid(v1,...,vn); - -{public [signal_list]} is optional -*/ -pub fn main_component(p: &mut Parser) { - p.expect(ComponentKw); - p.expect(MainKw); - - if p.at(LCurly) { - p.expect(LCurly); - p.expect(PublicKw); - p.expect(LBracket); - list_identity::parse(p); - p.expect(RBracket); - } - - p.expect(Assign); - expression::expression(p); -} +use super::*; + +/* +component main {public [signal_list]} = tempid(v1,...,vn); + +{public [signal_list]} is optional +*/ +pub fn main_component(p: &mut Parser) { + p.expect(ComponentKw); + p.expect(MainKw); + + if p.at(LCurly) { + p.expect(LCurly); + p.expect(PublicKw); + p.expect(LBracket); + list_identity::parse(p); + p.expect(RBracket); + } + + p.expect(Assign); + expression::expression(p); +} diff --git a/crates/parser/src/grammar/pragma.rs b/crates/parser/src/grammar/pragma.rs index 9ce3eaf..7eb8fe0 100644 --- a/crates/parser/src/grammar/pragma.rs +++ b/crates/parser/src/grammar/pragma.rs @@ -1,16 +1,16 @@ -use super::*; - -/** - * parse pragma in circom language - * grammar: - * pragma circom ; - */ - -pub fn pragma(p: &mut Parser) { - let m = p.open(); - p.expect(Pragma); - p.expect(Circom); - p.expect(Version); - p.expect(Semicolon); - p.close(m, Pragma); -} +use super::*; + +/** + * parse pragma in circom language + * grammar: + * pragma circom ; + */ + +pub fn pragma(p: &mut Parser) { + let m = p.open(); + p.expect(PragmaKw); + p.expect(Circom); + p.expect(Version); + p.expect(Semicolon); + p.close(m, Pragma); +} diff --git a/crates/parser/src/grammar/statement.rs b/crates/parser/src/grammar/statement.rs index 84ca0a6..e2b1a1b 100644 --- a/crates/parser/src/grammar/statement.rs +++ b/crates/parser/src/grammar/statement.rs @@ -1,184 +1,200 @@ -use super::{block::block, expression::expression, *}; - -pub(super) fn statement(p: &mut Parser) { - let m = p.open(); - match p.current() { - IfKw => if_statement(p), - _ => statement_no_condition(p), - } - p.close(m, Statement); -} - -/* -if (expr) - -else - -*/ -fn if_statement(p: &mut Parser) { - let m = p.open(); - p.expect(IfKw); - p.expect(LParen); - expression::expression(p); - p.expect(RParen); - statement(p); - if p.at(ElseKw) { - p.expect(ElseKw); - statement(p); - } - p.close(m, IfKw); -} - -/** - * no if condition here. - * for/while/return/assert... - */ -fn statement_no_condition(p: &mut Parser) { - match p.current() { - ForKw => for_statement(p), - WhileKw => while_statement(p), - ReturnKw => { - return_statement(p); - p.expect(Semicolon); - } - LCurly => block(p), - LogKw => { - log_statement(p); - p.expect(Semicolon); - } - AssertKw => { - assert_statement(p); - p.expect(Semicolon); - } - _ => { - assignment_statement(p); - p.expect(Semicolon); - } - } -} - -/* -for (/; ; ) - -*/ -fn for_statement(p: &mut Parser) { - let m = p.open(); - p.expect(ForKw); - p.expect(LParen); - if p.current().is_declaration_kw() { - declaration::declaration(p); - } else { - assignment_statement(p); - } - p.expect(Semicolon); - expression::expression(p); - p.expect(Semicolon); - - assignment_statement(p); - p.expect(RParen); - - statement_no_condition(p); - p.close(m, ForLoop); -} - -/* -while () - -*/ -fn while_statement(p: &mut Parser) { - p.expect(WhileKw); - p.expect(LParen); - expression(p); - p.expect(RParen); - statement(p); -} - -/* -assert() -*/ -fn assert_statement(p: &mut Parser) { - let m = p.open(); - p.expect(AssertKw); - p.expect(LParen); - expression(p); - p.expect(RParen); - p.close(m, AssertKw); -} - -/* -log() -*/ -fn log_statement(p: &mut Parser) { - let m = p.open(); - p.expect(LogKw); - p.expect(LParen); - while !p.eof() { - if p.at(RParen) { - break; - } - match p.current() { - CircomString => p.advance(), - _ => expression(p), - } - if !p.at(Comma) { - break; - } else { - p.advance(); - } - } - p.expect(RParen); - p.close(m, LogKw); -} - -/* -return -*/ -fn return_statement(p: &mut Parser) { - let m = p.open(); - p.expect(ReturnKw); - expression(p); - p.close(m, ReturnKw); -} - -/* - -*/ -fn assignment_statement(p: &mut Parser) { - let m = p.open(); - - if p.at(Identifier) { - let m_id = p.open(); - let m_name = p.open(); - p.expect(Identifier); - p.close(m_name, ComponentIdentifier); - if p.at(LBracket) { - p.expect(LBracket); - expression(p); - p.expect(RBracket); - } - if p.at(Dot) { - p.expect(Dot); - p.expect(Identifier); - p.close(m_id, ComponentCall); - } else { - p.close(m_id, Expression); - } - } else { - expression(p); - } - - if p.at_any(&[ - Assign, - RAssignSignal, - RAssignConstraintSignal, - LAssignContraintSignal, - LAssignSignal, - EqualSignal, - ]) { - p.advance(); - expression(p); - p.close(m, AssignStatement); - } else { - p.close(m, Error); - } -} +use crate::token_kind::TokenKind; + +use super::{block::block, expression::expression, *}; + +pub(super) fn statement(p: &mut Parser) { + let m = p.open(); + match p.current() { + IfKw => if_statement(p), + _ => statement_no_condition(p), + } + p.close(m, Statement); +} + +/* +if (expr) + +else + +*/ +fn if_statement(p: &mut Parser) { + let m = p.open(); + p.expect(IfKw); + p.expect(LParen); + expression::expression(p); + p.expect(RParen); + statement(p); + if p.at(ElseKw) { + p.expect(ElseKw); + statement(p); + } + p.close(m, IfKw); +} + +/** + * no if condition here. + * for/while/return/assert... + */ +fn statement_no_condition(p: &mut Parser) { + match p.current() { + ForKw => for_statement(p), + WhileKw => while_statement(p), + ReturnKw => { + return_statement(p); + p.expect(Semicolon); + } + LCurly => block(p), + LogKw => { + log_statement(p); + p.expect(Semicolon); + } + AssertKw => { + assert_statement(p); + p.expect(Semicolon); + } + _ => { + assignment_statement(p); + p.expect(Semicolon); + } + } +} + +/* +for (/; ; ) + +*/ +fn for_statement(p: &mut Parser) { + let m = p.open(); + + // for ( + p.expect(ForKw); + p.expect(LParen); + + if p.current().is_declaration_kw() { + // for (var i = 1 + declaration::declaration(p); + } else { + // for (i = 1 + assignment_statement(p); + } + p.expect(Semicolon); + + // for (i = 1; i < N; + expression::expression(p); + p.expect(Semicolon); + + // for (i = 1; i < N; i++) + assignment_statement(p); + p.expect(RParen); + + // for (i = 1; i < N; i++) { } + statement(p); + // statement_no_condition(p); + p.close(m, ForLoop); +} + +/* +while () + +*/ +fn while_statement(p: &mut Parser) { + p.expect(WhileKw); + p.expect(LParen); + expression(p); + p.expect(RParen); + statement(p); +} + +/* +assert() +*/ +fn assert_statement(p: &mut Parser) { + let m = p.open(); + p.expect(AssertKw); + p.expect(LParen); + expression(p); + p.expect(RParen); + p.close(m, AssertKw); +} + +/* +log() +*/ +fn log_statement(p: &mut Parser) { + let m = p.open(); + p.expect(LogKw); + p.expect(LParen); + while !p.eof() { + if p.at(RParen) { + break; + } + match p.current() { + CircomString => p.advance(), + _ => expression(p), + } + if !p.at(Comma) { + break; + } else { + p.advance(); + } + } + p.expect(RParen); + p.close(m, LogKw); +} + +/* +return +*/ +fn return_statement(p: &mut Parser) { + let m = p.open(); + p.expect(ReturnKw); + expression(p); + p.close(m, ReturnKw); +} + +/* + +*/ +fn assignment_statement(p: &mut Parser) { + let m = p.open(); + + if p.at(Identifier) { + let m_id = p.open(); + // abc + let m_name = p.open(); + p.expect(Identifier); + p.close(m_name, ComponentIdentifier); + + // abc[N - 1] + if p.at(LBracket) { + p.expect(LBracket); + expression(p); + p.expect(RBracket); + } + + if p.at(Dot) { + // abc[N - 1].def OR abc.def --> component call + p.expect(Dot); + p.expect(Identifier); + p.close(m_id, ComponentCall); + } else { + // abc[N - 1] OR abc --> expression + p.close(m_id, Expression); + } + } else { + // assignment without identifier + expression(p); + } + + // assign part + if p.at_assign_token() { + let is_self_assign = p.at_any(&[TokenKind::UnitDec, TokenKind::UnitInc]); + p.advance(); + if is_self_assign == false { + expression(p); + } + p.close(m, AssignStatement); + } else { + p.close(m, Error); + } +} diff --git a/crates/parser/src/grammar/template.rs b/crates/parser/src/grammar/template.rs index a502365..9cfa7cb 100644 --- a/crates/parser/src/grammar/template.rs +++ b/crates/parser/src/grammar/template.rs @@ -1,25 +1,25 @@ -use crate::grammar::*; -/** - * template Identifier() {content} - * template Identifier( param_1, ... , param_n ) { content } - */ -pub fn template(p: &mut Parser) { - // assert!(p.at(TemplateKw)); - let m = p.open(); - - p.expect(TemplateKw); - - let name_marker = p.open(); - p.expect(Identifier); - p.close(name_marker, TemplateName); - - p.expect(LParen); - let arg_marker = p.open(); - list_identity::parse(p); - p.close(arg_marker, ParameterList); - p.expect(RParen); - - block::block(p); - - p.close(m, TemplateDef); -} +use crate::grammar::*; +/** + * template Identifier() {content} + * template Identifier( param_1, ... , param_n ) { content } + */ +pub fn template(p: &mut Parser) { + // assert!(p.at(TemplateKw)); + let m = p.open(); + + p.expect(TemplateKw); + + let name_marker = p.open(); + p.expect(Identifier); + p.close(name_marker, TemplateName); + + p.expect(LParen); + let arg_marker = p.open(); + list_identity::parse(p); + p.close(arg_marker, ParameterList); + p.expect(RParen); + + block::block(p); + + p.close(m, TemplateDef); +} diff --git a/crates/parser/src/lib.rs b/crates/parser/src/lib.rs index 53879ac..f279245 100644 --- a/crates/parser/src/lib.rs +++ b/crates/parser/src/lib.rs @@ -1,9 +1,9 @@ -pub mod event; -pub mod grammar; -pub mod parser; -pub mod token_kind; - -pub use logos::Lexer; - -pub mod input; -pub mod output; +pub mod event; +pub mod grammar; +pub mod parser; +pub mod token_kind; + +pub use logos::Lexer; + +pub mod input; +pub mod output; diff --git a/crates/parser/src/output.rs b/crates/parser/src/output.rs index b594a3e..43ed428 100644 --- a/crates/parser/src/output.rs +++ b/crates/parser/src/output.rs @@ -1,75 +1,75 @@ -use crate::{event::Event, token_kind::TokenKind}; - -#[derive(Debug)] -pub enum Child { - Token(usize), // position of token, - Error(String), - Tree(Tree), -} - -#[derive(Debug)] -pub struct Tree { - kind: TokenKind, - children: Vec, -} - -pub type Output = Tree; - -impl Output { - fn empty() -> Self { - Tree { - kind: TokenKind::ParserError, - children: Vec::new(), - } - } - - pub fn kind(&self) -> TokenKind { - self.kind - } - - pub fn children(&self) -> &Vec { - &self.children - } -} - -impl From> for Output { - fn from(events: Vec) -> Self { - let mut stack = Vec::new(); - if let Some((last, elements)) = events.split_last() { - if !matches!(*last, Event::Close) { - return Output::empty(); - } - for event in elements { - match event { - Event::Open { kind } => { - stack.push(Tree { - kind: *kind, - children: Vec::new(), - }); - } - Event::Close => { - let tree = stack.pop().unwrap(); - - stack.last_mut().unwrap().children.push(Child::Tree(tree)); - } - Event::TokenPosition(token) => { - stack - .last_mut() - .unwrap() - .children - .push(Child::Token(*token)); - } - Event::ErrorReport(error) => { - stack - .last_mut() - .unwrap() - .children - .push(Child::Error(error.clone())); - } - } - } - } - // TODO: Make it more safe - stack.pop().unwrap() - } -} +use crate::{event::Event, token_kind::TokenKind}; + +#[derive(Debug)] +pub enum Child { + Token(usize), // position of token, + Error(String), + Tree(Tree), +} + +#[derive(Debug)] +pub struct Tree { + kind: TokenKind, + children: Vec, +} + +pub type Output = Tree; + +impl Output { + fn empty() -> Self { + Tree { + kind: TokenKind::ParserError, + children: Vec::new(), + } + } + + pub fn kind(&self) -> TokenKind { + self.kind + } + + pub fn children(&self) -> &Vec { + &self.children + } +} + +impl From> for Output { + fn from(events: Vec) -> Self { + let mut stack = Vec::new(); + if let Some((last, elements)) = events.split_last() { + if !matches!(*last, Event::Close) { + return Output::empty(); + } + for event in elements { + match event { + Event::Open { kind } => { + stack.push(Tree { + kind: *kind, + children: Vec::new(), + }); + } + Event::Close => { + let tree = stack.pop().unwrap(); + + stack.last_mut().unwrap().children.push(Child::Tree(tree)); + } + Event::TokenPosition(token) => { + stack + .last_mut() + .unwrap() + .children + .push(Child::Token(*token)); + } + Event::ErrorReport(error) => { + stack + .last_mut() + .unwrap() + .children + .push(Child::Error(error.clone())); + } + } + } + } + // TODO: Make it more safe + stack.pop().unwrap() + } +} diff --git a/crates/parser/src/parser.rs b/crates/parser/src/parser.rs index 34a2f64..20b3091 100644 --- a/crates/parser/src/parser.rs +++ b/crates/parser/src/parser.rs @@ -1,223 +1,234 @@ -use std::cell::Cell; - -use crate::{ - event::Event, grammar::entry::Scope, input::Input, output::Output, token_kind::TokenKind, -}; - -pub struct Context { - pub r_curly_count: i32, -} - -pub struct Parser<'a> { - pub(crate) input: &'a Input<'a>, - pub context: Context, - pos: usize, - fuel: Cell, - pub(crate) events: Vec, -} - -#[derive(Clone, Copy, Debug)] -pub enum Marker { - Open(usize), - Close(usize), -} - -#[derive(Debug)] -pub enum ParserError { - InvalidEvents, -} - -impl<'a> Parser<'a> { - pub fn wrap_trivial_tokens(&mut self) -> TokenKind { - loop { - let kind = self.input.kind_of(self.pos); - - if kind.is_trivial() == false { - return kind; - } - - self.events.push(Event::Open { kind }); - - self.fuel.set(256); - self.events.push(Event::TokenPosition(self.pos)); - self.skip(); - - self.events.push(Event::Close); - } - } - - pub fn open(&mut self) -> Marker { - if self.events.len() > 0 { - self.wrap_trivial_tokens(); - } - - let marker = Marker::Open(self.events.len()); - self.events.push(Event::Open { - kind: TokenKind::Error, - }); - marker - } - - pub fn open_before(&mut self, marker_closed: Marker) -> Marker { - match marker_closed { - Marker::Close(index) => { - let marker_opened = Marker::Open(index); - self.events.insert( - index, - Event::Open { - kind: TokenKind::EOF, - }, - ); - marker_opened - } - _ => unreachable!(), - } - } - - pub fn close(&mut self, marker_open: Marker, kind: TokenKind) -> Marker { - match marker_open { - Marker::Open(index) => { - self.events[index] = Event::Open { kind }; - self.events.push(Event::Close); - Marker::Close(index) - } - _ => unreachable!(), - } - } - - pub fn advance(&mut self) { - // assert!(!self.eof()); - self.fuel.set(256); - let token = Event::TokenPosition(self.pos); - self.events.push(token); - self.skip(); - } - - pub fn advance_with_token(&mut self, index: usize) { - // assert!(token.kind != TokenKind::EOF); - if self.input.kind_of(index) != TokenKind::EOF { - self.fuel.set(256); - let token = Event::TokenPosition(index); - self.events.push(token); - } - } - - pub fn advance_with_error(&mut self, _error: &str) { - let m = self.open(); - // TODO: Error reporting. - if !self.eof() { - self.advance(); - } - self.close(m, TokenKind::Error); - } - - pub fn error_report(&mut self, error: String) { - let m = self.open(); - - let token = Event::ErrorReport(error); - self.events.push(token); - - self.close(m, TokenKind::Error); - } -} - -impl<'a> Parser<'a> { - pub fn new(input: &'a Input) -> Self { - Self { - input, - pos: 0, - context: Context { r_curly_count: 0 }, - fuel: Cell::new(256), - events: Vec::new(), - } - } - - pub fn inc_rcurly(&mut self) { - self.context.r_curly_count += 1; - } - - pub fn dec_rcurly(&mut self) { - self.context.r_curly_count += 1; - } - - pub fn current(&mut self) -> TokenKind { - self.wrap_trivial_tokens() - } - - pub fn next(&mut self) -> TokenKind { - if self.fuel.get() == 0 { - panic!("parser is stuck"); - } - self.fuel.set(self.fuel.get() - 1); - if self.pos < self.input.size() { - self.pos += 1; - return self.input.kind_of(self.pos); - } - - TokenKind::EOF - } - - pub fn at(&mut self, kind: TokenKind) -> bool { - self.current() == kind - } - - pub fn at_any(&mut self, kinds: &[TokenKind]) -> bool { - let current_kind = self.current(); - kinds.contains(¤t_kind) - } - - pub fn skip(&mut self) { - self.next(); - } - - pub fn skip_if(&mut self, kinds: &[TokenKind]) { - if self.at_any(kinds) { - self.skip(); - } - } - - pub fn eat(&mut self, kind: TokenKind) -> bool { - if self.at(kind) { - self.advance(); - return true; - } - - false - } - - pub fn expect_any(&mut self, kinds: &[TokenKind]) { - let kind = self.current(); - if kinds.contains(&kind) { - self.advance(); - } else { - let error = format!("expect {:?} but got {:?}", kinds, kind); - self.error_report(error); - } - } - - pub fn expect(&mut self, kind: TokenKind) { - if self.at(kind) { - self.advance(); - } else { - let error = format!("expect {:?} but got {:?}", kind, self.current()); - self.error_report(error); - } - } - - pub fn eof(&mut self) -> bool { - self.current() == TokenKind::EOF - } -} - -impl Parser<'_> { - pub fn parsing_with_scope(input: &Input, scope: Scope) -> Output { - let mut p = Parser::new(input); - scope.parse(&mut p); - Output::from(p.events) - } - - pub fn parsing(input: &Input) -> Output { - let c = Scope::CircomProgram; - Parser::parsing_with_scope(input, c) - } -} +use std::cell::Cell; + +use crate::{ + event::Event, grammar::entry::Scope, input::Input, output::Output, token_kind::TokenKind, +}; + +pub struct Context { + pub r_curly_count: i32, +} + +pub struct Parser<'a> { + pub(crate) input: &'a Input<'a>, + pub context: Context, + pos: usize, + fuel: Cell, + pub(crate) events: Vec, +} + +#[derive(Clone, Copy, Debug)] +pub enum Marker { + Open(usize), + Close(usize), +} + +#[derive(Debug)] +pub enum ParserError { + InvalidEvents, +} + +impl<'a> Parser<'a> { + pub fn wrap_trivial_tokens(&mut self) -> TokenKind { + loop { + let kind = self.input.kind_of(self.pos); + + if kind.is_trivial() == false { + return kind; + } + + self.fuel.set(256); + self.events.push(Event::TokenPosition(self.pos)); + self.skip(); + } + } + + pub fn open(&mut self) -> Marker { + if self.events.len() > 0 { + self.wrap_trivial_tokens(); + } + + let marker = Marker::Open(self.events.len()); + self.events.push(Event::Open { + kind: TokenKind::Error, + }); + marker + } + + pub fn open_before(&mut self, marker_closed: Marker) -> Marker { + match marker_closed { + Marker::Close(index) => { + let marker_opened = Marker::Open(index); + self.events.insert( + index, + Event::Open { + kind: TokenKind::EOF, + }, + ); + marker_opened + } + _ => unreachable!(), + } + } + + pub fn close(&mut self, marker_open: Marker, kind: TokenKind) -> Marker { + match marker_open { + Marker::Open(index) => { + self.events[index] = Event::Open { kind }; + self.events.push(Event::Close); + Marker::Close(index) + } + _ => unreachable!(), + } + } + + pub fn advance(&mut self) { + // assert!(!self.eof()); + self.fuel.set(256); + let token = Event::TokenPosition(self.pos); + self.events.push(token); + self.skip(); + } + + pub fn advance_with_token(&mut self, index: usize) { + // assert!(token.kind != TokenKind::EOF); + if self.input.kind_of(index) != TokenKind::EOF { + self.fuel.set(256); + let token = Event::TokenPosition(index); + self.events.push(token); + } + } + + pub fn advance_with_error(&mut self, _error: &str) { + let m = self.open(); + // TODO: Error reporting. + if !self.eof() { + self.advance(); + } + self.close(m, TokenKind::Error); + } + + pub fn error_report(&mut self, error: String) { + let m = self.open(); + + let token = Event::ErrorReport(error); + self.events.push(token); + + self.close(m, TokenKind::Error); + } +} + +impl<'a> Parser<'a> { + pub fn new(input: &'a Input) -> Self { + Self { + input, + pos: 0, + context: Context { r_curly_count: 0 }, + fuel: Cell::new(256), + events: Vec::new(), + } + } + + pub fn inc_rcurly(&mut self) { + self.context.r_curly_count += 1; + } + + pub fn dec_rcurly(&mut self) { + self.context.r_curly_count -= 1; + } + + pub fn current(&mut self) -> TokenKind { + self.wrap_trivial_tokens() + } + + pub fn next(&mut self) -> TokenKind { + if self.fuel.get() == 0 { + panic!("parser is stuck"); + } + self.fuel.set(self.fuel.get() - 1); + if self.pos < self.input.size() { + self.pos += 1; + return self.input.kind_of(self.pos); + } + + TokenKind::EOF + } + + pub fn at(&mut self, kind: TokenKind) -> bool { + self.current() == kind + } + + pub fn at_any(&mut self, kinds: &[TokenKind]) -> bool { + let current_kind = self.current(); + kinds.contains(¤t_kind) + } + + pub fn at_assign_token(&mut self) -> bool { + let current_kind = self.current(); + current_kind.is_assign_token() + } + + pub fn at_inline_assign_signal(&mut self) -> bool { + let current_kind = self.current(); + current_kind.is_inline_assign_signal() + } + + pub fn at_var_assign(&mut self) -> bool { + let current_kind = self.current(); + current_kind.is_var_assign() + } + + pub fn skip(&mut self) { + self.next(); + } + + pub fn skip_if(&mut self, kinds: &[TokenKind]) { + if self.at_any(kinds) { + self.skip(); + } + } + + pub fn eat(&mut self, kind: TokenKind) -> bool { + if self.at(kind) { + self.advance(); + return true; + } + + false + } + + pub fn expect_any(&mut self, kinds: &[TokenKind]) { + let kind = self.current(); + if kinds.contains(&kind) { + self.advance(); + } else { + let error = format!("expect {:?} but got {:?}", kinds, kind); + self.error_report(error); + } + } + + pub fn expect(&mut self, kind: TokenKind) { + if self.at(kind) { + self.advance(); + } else { + let error = format!("expect {:?} but got {:?}", kind, self.current()); + self.error_report(error); + } + } + + pub fn eof(&mut self) -> bool { + self.current() == TokenKind::EOF + } +} + +impl Parser<'_> { + pub fn parsing_with_scope(input: &Input, scope: Scope) -> Output { + let mut p = Parser::new(input); + scope.parse(&mut p); + Output::from(p.events) + } + + pub fn parsing(input: &Input) -> Output { + let c = Scope::CircomProgram; + Parser::parsing_with_scope(input, c) + } +} diff --git a/crates/parser/src/snapshots/parser__input__tests__test_comment_error.snap b/crates/parser/src/snapshots/parser__input__tests__test_comment_error.snap index f8307a5..5ddaf83 100644 --- a/crates/parser/src/snapshots/parser__input__tests__test_comment_error.snap +++ b/crates/parser/src/snapshots/parser__input__tests__test_comment_error.snap @@ -5,7 +5,7 @@ expression: input kind: - EndLine - WhiteSpace - - Pragma + - PragmaKw - WhiteSpace - Version - Semicolon diff --git a/crates/parser/src/snapshots/parser__input__tests__test_pragma.snap b/crates/parser/src/snapshots/parser__input__tests__test_pragma.snap index 48b3f54..c85ae09 100644 --- a/crates/parser/src/snapshots/parser__input__tests__test_pragma.snap +++ b/crates/parser/src/snapshots/parser__input__tests__test_pragma.snap @@ -9,7 +9,7 @@ kind: - EndLine - EndLine - WhiteSpace - - Pragma + - PragmaKw - WhiteSpace - Circom - WhiteSpace diff --git a/crates/parser/src/token_kind.rs b/crates/parser/src/token_kind.rs index 2101ef9..3a8621e 100644 --- a/crates/parser/src/token_kind.rs +++ b/crates/parser/src/token_kind.rs @@ -9,7 +9,7 @@ pub enum TokenKind { #[error] Error = 0, // Comments - #[regex(r"//[^\n]*")] + #[regex(r"//[^\r\n]*")] CommentLine, #[token("/*")] CommentBlockOpen, @@ -18,11 +18,12 @@ pub enum TokenKind { // Trivial #[regex("[ \t]+")] WhiteSpace, - #[regex("[\n]")] + #[regex(r"\r?\n")] EndLine, - // Circom - #[token("pragma")] + // Pragma Pragma, + #[token("pragma")] + PragmaKw, #[token("circom")] Circom, #[regex("2.[0-9].[0-9]")] @@ -48,7 +49,6 @@ pub enum TokenKind { #[token("]")] RBracket, // Punctuation - // Punctuation #[token(";")] Semicolon, #[token(",")] @@ -123,7 +123,6 @@ pub enum TokenKind { #[token("<<")] ShiftL, // Combined bitwise assignments - // Combined bitwise assignments #[token("&=")] BitAndAssign, #[token("|=")] @@ -202,6 +201,7 @@ pub enum TokenKind { Call, TenaryConditional, Condition, + ExpressionAtom, Expression, FunctionDef, Statement, @@ -212,6 +212,7 @@ pub enum TokenKind { FunctionName, ParameterList, SignalDecl, + VarIdentifier, VarDecl, InputSignalDecl, OutputSignalDecl, @@ -293,6 +294,12 @@ impl TokenKind { // associativity: right to left [ a = b = c --> a = (b = c) ] // assignment operators Self::Assign + // signal assigment operators + | Self::EqualSignal + | Self::LAssignSignal + | Self::LAssignContraintSignal + | Self::RAssignSignal + | Self::RAssignConstraintSignal // bitwise asignment operators | Self::BitOrAssign | Self::BitXorAssign @@ -346,6 +353,47 @@ impl TokenKind { matches!(self, Self::VarKw | Self::ComponentKw | Self::SignalKw) } + pub fn is_assign_token(self) -> bool { + matches!( + self, + Self::Assign + // signal assigment operators + | Self::EqualSignal + | Self::LAssignSignal + | Self::LAssignContraintSignal + | Self::RAssignSignal + | Self::RAssignConstraintSignal + // bitwise asignment operators + | Self::BitOrAssign + | Self::BitXorAssign + | Self::BitAndAssign + | Self::ShiftLAssign + | Self::ShiftRAssign + // arithmetic asignament operators + | Self::AddAssign + | Self::SubAssign + | Self::MulAssign + | Self::DivAssign + | Self::IntDivAssign + | Self::ModAssign + | Self::PowerAssign + // unit inc/dec + | Self::UnitInc + | Self::UnitDec + ) + } + + pub fn is_inline_assign_signal(self) -> bool { + matches!( + self, + Self::Assign | Self::RAssignSignal | Self::RAssignConstraintSignal + ) + } + + pub fn is_var_assign(self) -> bool { + matches!(self, Self::Assign) + } + pub fn is_trivial(self) -> bool { matches!( self, diff --git a/crates/syntax/src/abstract_syntax_tree/ast.rs b/crates/syntax/src/abstract_syntax_tree/ast.rs index 9d8c282..7682d18 100644 --- a/crates/syntax/src/abstract_syntax_tree/ast.rs +++ b/crates/syntax/src/abstract_syntax_tree/ast.rs @@ -1,192 +1,201 @@ -use parser::token_kind::TokenKind::*; -use rowan::ast::AstChildren; -use rowan::SyntaxText; - -use crate::syntax_node::CircomLanguage; -use crate::syntax_node::SyntaxNode; -use parser::token_kind::TokenKind; -use rowan::ast::{support, AstNode}; - -use super::template::AstTemplateDef; -use super::template::AstTemplateName; - -ast_node!(AstSignalHeader, SignalHeader); -ast_node!(AstInputSignalDecl, InputSignalDecl); -ast_node!(AstOutputSignalDecl, OutputSignalDecl); -ast_node!(AstSignalDecl, SignalDecl); - -impl AstInputSignalDecl { - pub fn name(&self) -> Option { - support::child(self.syntax()) - } - - pub fn same_name(&self, other: &SyntaxText) -> bool { - if let Some(name) = self.name() { - return name.equal(other); - } - false - } -} - -impl AstOutputSignalDecl { - pub fn name(&self) -> Option { - support::child(self.syntax()) - } -} -impl AstSignalDecl { - pub fn name(&self) -> Option { - support::child(self.syntax()) - } -} -ast_node!(AstVarDecl, VarDecl); - -impl AstVarDecl { - pub fn name(&self) -> Option { - support::child(self.syntax()) - } -} - -ast_node!(AstComponentDecl, ComponentDecl); - -impl AstComponentDecl { - pub fn template(&self) -> Option { - support::child(self.syntax()) - } - pub fn component_identifier(&self) -> Option { - support::child(self.syntax()) - } -} - -ast_node!(AstStatement, Statement); - -ast_node!(AstStatementList, StatementList); - -impl AstStatementList { - pub fn statement_list(&self) -> AstChildren { - support::children(self.syntax()) - } - - pub fn find_children>(&self) -> Vec { - self.syntax().children().filter_map(N::cast).collect() - } -} - -ast_node!(AstBlock, Block); -impl AstBlock { - pub fn statement_list(&self) -> Option { - support::child::(self.syntax()) - } -} - -ast_node!(AstVersion, Version); -ast_node!(AstPragma, Pragma); - -impl AstPragma { - pub fn version(&self) -> Option { - support::child(self.syntax()) - } -} -ast_node!(AstParameterList, TokenKind::ParameterList); - -ast_node!(AstIdentifier, Identifier); - -impl AstIdentifier { - pub fn equal(&self, other: &SyntaxText) -> bool { - self.syntax().text() == *other - } -} - -ast_node!(AstFunctionName, FunctionName); - -ast_node!(AstFunctionDef, FunctionDef); - -impl AstFunctionDef { - pub fn body(&self) -> Option { - self.syntax().children().find_map(AstBlock::cast) - } - - pub fn function_name(&self) -> Option { - self.syntax().children().find_map(AstFunctionName::cast) - } - - pub fn argument_list(&self) -> Option { - self.syntax().children().find_map(AstParameterList::cast) - } -} - -ast_node!(AstCircomProgram, CircomProgram); - -impl AstCircomProgram { - pub fn pragma(&self) -> Option { - self.syntax().children().find_map(AstPragma::cast) - } - pub fn libs(&self) -> Vec { - self.syntax() - .children() - .filter_map(AstInclude::cast) - .collect() - } - - pub fn template_list(&self) -> Vec { - self.syntax() - .children() - .filter_map(AstTemplateDef::cast) - .collect() - } - - pub fn function_list(&self) -> Vec { - self.syntax() - .children() - .filter_map(AstFunctionDef::cast) - .collect() - } - - pub fn get_template_by_name( - &self, - ast_template_name: &AstTemplateName, - ) -> Option { - for template in self.template_list() { - if let Some(template_name) = template.name() { - if template_name.same_name(ast_template_name) { - return Some(template); - } - } - } - None - } -} - -ast_node!(AstComponentCall, ComponentCall); - -impl AstComponentCall { - pub fn component_name(&self) -> Option { - support::child(self.syntax()) - } - pub fn signal(&self) -> Option { - support::child(self.syntax()) - } -} - -ast_node!(AstComponentIdentifier, ComponentIdentifier); - -impl AstComponentIdentifier { - pub fn name(&self) -> Option { - support::child(self.syntax()) - } -} - -ast_node!(AstCircomString, CircomString); -impl AstCircomString { - pub fn value(&self) -> String { - let text = &self.syntax().text().to_string(); - text[1..text.len() - 1].to_string() - } -} - -ast_node!(AstInclude, IncludeKw); - -impl AstInclude { - pub fn lib(&self) -> Option { - support::child(self.syntax()) - } -} +use parser::token_kind::TokenKind::*; +use rowan::ast::AstChildren; +use rowan::SyntaxText; + +use crate::syntax_node::CircomLanguage; +use crate::syntax_node::SyntaxNode; +use parser::token_kind::TokenKind; +use rowan::ast::{support, AstNode}; + +use super::template::AstTemplateDef; +use super::template::AstTemplateName; + +ast_node!(AstSignalHeader, SignalHeader); +ast_node!(AstInputSignalDecl, InputSignalDecl); +ast_node!(AstOutputSignalDecl, OutputSignalDecl); +ast_node!(AstSignalDecl, SignalDecl); +ast_node!(AstSignalIdentifier, SignalIdentifier); + +impl AstInputSignalDecl { + pub fn signal_identifier(&self) -> Option { + support::child(self.syntax()) + } +} + +impl AstOutputSignalDecl { + pub fn signal_identifier(&self) -> Option { + support::child(self.syntax()) + } +} + +impl AstSignalDecl { + pub fn signal_identifier(&self) -> Option { + support::child(self.syntax()) + } +} + +impl AstSignalIdentifier { + pub fn name(&self) -> Option { + support::child(self.syntax()) + } +} + +ast_node!(AstVarDecl, VarDecl); +ast_node!(AstVarIdentifier, VarIdentifier); + +impl AstVarDecl { + pub fn var_identifier(&self) -> Option { + support::child(self.syntax()) + } +} + +impl AstVarIdentifier { + pub fn name(&self) -> Option { + support::child(self.syntax()) + } +} + +ast_node!(AstComponentDecl, ComponentDecl); + +impl AstComponentDecl { + pub fn template(&self) -> Option { + support::child(self.syntax()) + } + pub fn component_identifier(&self) -> Option { + support::child(self.syntax()) + } +} + +ast_node!(AstStatement, Statement); + +ast_node!(AstStatementList, StatementList); + +impl AstStatementList { + pub fn statement_list(&self) -> AstChildren { + support::children(self.syntax()) + } + + pub fn find_children>(&self) -> Vec { + self.syntax().children().filter_map(N::cast).collect() + } +} + +ast_node!(AstBlock, Block); +impl AstBlock { + pub fn statement_list(&self) -> Option { + support::child::(self.syntax()) + } +} + +ast_node!(AstVersion, Version); +ast_node!(AstPragma, Pragma); + +impl AstPragma { + pub fn version(&self) -> Option { + support::child(self.syntax()) + } +} +ast_node!(AstParameterList, TokenKind::ParameterList); + +ast_node!(AstIdentifier, Identifier); + +impl AstIdentifier { + pub fn equal(&self, other: &SyntaxText) -> bool { + self.syntax().text() == *other + } +} + +ast_node!(AstFunctionName, FunctionName); + +ast_node!(AstFunctionDef, FunctionDef); + +impl AstFunctionDef { + pub fn body(&self) -> Option { + self.syntax().children().find_map(AstBlock::cast) + } + + pub fn function_name(&self) -> Option { + self.syntax().children().find_map(AstFunctionName::cast) + } + + pub fn argument_list(&self) -> Option { + self.syntax().children().find_map(AstParameterList::cast) + } +} + +ast_node!(AstCircomProgram, CircomProgram); + +impl AstCircomProgram { + pub fn pragma(&self) -> Option { + self.syntax().children().find_map(AstPragma::cast) + } + pub fn libs(&self) -> Vec { + self.syntax() + .children() + .filter_map(AstInclude::cast) + .collect() + } + + pub fn template_list(&self) -> Vec { + self.syntax() + .children() + .filter_map(AstTemplateDef::cast) + .collect() + } + + pub fn function_list(&self) -> Vec { + self.syntax() + .children() + .filter_map(AstFunctionDef::cast) + .collect() + } + + pub fn get_template_by_name( + &self, + ast_template_name: &AstTemplateName, + ) -> Option { + for template in self.template_list() { + if let Some(template_name) = template.name() { + if template_name.same_name(ast_template_name) { + return Some(template); + } + } + } + None + } +} + +ast_node!(AstComponentCall, ComponentCall); + +impl AstComponentCall { + pub fn component_name(&self) -> Option { + support::child(self.syntax()) + } + pub fn signal(&self) -> Option { + support::child(self.syntax()) + } +} + +ast_node!(AstComponentIdentifier, ComponentIdentifier); + +impl AstComponentIdentifier { + pub fn name(&self) -> Option { + support::child(self.syntax()) + } +} + +ast_node!(AstCircomString, CircomString); +impl AstCircomString { + pub fn value(&self) -> String { + let text = &self.syntax().text().to_string(); + text[1..text.len() - 1].to_string() + } +} + +ast_node!(AstInclude, IncludeKw); + +impl AstInclude { + pub fn lib(&self) -> Option { + support::child(self.syntax()) + } +} diff --git a/crates/syntax/src/abstract_syntax_tree/template.rs b/crates/syntax/src/abstract_syntax_tree/template.rs index 7253b12..3ff1e73 100644 --- a/crates/syntax/src/abstract_syntax_tree/template.rs +++ b/crates/syntax/src/abstract_syntax_tree/template.rs @@ -1,100 +1,100 @@ -use parser::token_kind::TokenKind::*; - -use crate::syntax_node::CircomLanguage; -use crate::syntax_node::SyntaxNode; -use parser::token_kind::TokenKind; -use rowan::ast::AstNode; - -use super::ast::AstBlock; -use super::ast::AstComponentDecl; -use super::ast::AstIdentifier; -use super::ast::AstInputSignalDecl; -use super::ast::AstOutputSignalDecl; -use super::ast::AstParameterList; -use super::ast::AstSignalDecl; -use super::ast::AstStatementList; - -ast_node!(AstTemplateName, TemplateName); - -ast_node!(AstTemplateDef, TemplateDef); - -impl AstTemplateName { - pub fn name(&self) -> Option { - self.syntax().children().find_map(AstIdentifier::cast) - } - pub fn same_name>(&self, other: &M) -> bool { - self.syntax().text() == other.syntax().text() - } -} - -impl AstTemplateDef { - pub fn name(&self) -> Option { - self.syntax.children().find_map(AstTemplateName::cast) - } - pub fn func_body(&self) -> Option { - self.syntax.children().find_map(AstBlock::cast) - } - pub fn parameter_list(&self) -> Option { - self.syntax().children().find_map(AstParameterList::cast) - } - pub fn statements(&self) -> Option { - if let Some(body) = self.func_body() { - return body.statement_list(); - } - None - } - - pub fn find_input_signal(&self, name: &str) -> Option { - if let Some(statements) = self.statements() { - for input_signal in statements.find_children::() { - if let Some(signal_name) = input_signal.name() { - if signal_name.syntax().text() == name { - return Some(input_signal); - } - } - } - } - None - } - - pub fn find_output_signal(&self, name: &str) -> Option { - if let Some(statements) = self.statements() { - for input_signal in statements.find_children::() { - if let Some(signal_name) = input_signal.name() { - if signal_name.syntax().text() == name { - return Some(input_signal); - } - } - } - } - None - } - - pub fn find_internal_signal(&self, name: &str) -> Option { - if let Some(statements) = self.statements() { - for signal in statements.find_children::() { - if let Some(signal_name) = signal.name() { - if signal_name.syntax().text() == name { - return Some(signal); - } - } - } - } - None - } - - pub fn find_component(&self, name: &str) -> Option { - if let Some(statements) = self.statements() { - for component in statements.find_children::() { - if let Some(signal_name) = component.component_identifier() { - if let Some(component_name) = signal_name.name() { - if component_name.syntax().text() == name { - return Some(component); - } - } - } - } - } - None - } -} +use parser::token_kind::TokenKind::*; + +use crate::syntax_node::CircomLanguage; +use crate::syntax_node::SyntaxNode; +use parser::token_kind::TokenKind; +use rowan::ast::AstNode; + +use super::ast::AstBlock; +use super::ast::AstComponentDecl; +use super::ast::AstIdentifier; +use super::ast::AstInputSignalDecl; +use super::ast::AstOutputSignalDecl; +use super::ast::AstParameterList; +use super::ast::AstSignalDecl; +use super::ast::AstStatementList; + +ast_node!(AstTemplateName, TemplateName); + +ast_node!(AstTemplateDef, TemplateDef); + +impl AstTemplateName { + pub fn name(&self) -> Option { + self.syntax().children().find_map(AstIdentifier::cast) + } + pub fn same_name>(&self, other: &M) -> bool { + self.syntax().text() == other.syntax().text() + } +} + +impl AstTemplateDef { + pub fn name(&self) -> Option { + self.syntax.children().find_map(AstTemplateName::cast) + } + pub fn func_body(&self) -> Option { + self.syntax.children().find_map(AstBlock::cast) + } + pub fn parameter_list(&self) -> Option { + self.syntax().children().find_map(AstParameterList::cast) + } + pub fn statements(&self) -> Option { + if let Some(body) = self.func_body() { + return body.statement_list(); + } + None + } + + pub fn find_input_signal(&self, name: &str) -> Option { + if let Some(statements) = self.statements() { + for input_signal in statements.find_children::() { + if let Some(signal_name) = input_signal.signal_identifier().unwrap().name() { + if signal_name.syntax().text() == name { + return Some(input_signal); + } + } + } + } + None + } + + pub fn find_output_signal(&self, name: &str) -> Option { + if let Some(statements) = self.statements() { + for input_signal in statements.find_children::() { + if let Some(signal_name) = input_signal.signal_identifier().unwrap().name() { + if signal_name.syntax().text() == name { + return Some(input_signal); + } + } + } + } + None + } + + pub fn find_internal_signal(&self, name: &str) -> Option { + if let Some(statements) = self.statements() { + for signal in statements.find_children::() { + if let Some(signal_name) = signal.signal_identifier().unwrap().name() { + if signal_name.syntax().text() == name { + return Some(signal); + } + } + } + } + None + } + + pub fn find_component(&self, name: &str) -> Option { + if let Some(statements) = self.statements() { + for component in statements.find_children::() { + if let Some(component_identifier) = component.component_identifier() { + if let Some(component_name) = component_identifier.name() { + if component_name.syntax().text() == name { + return Some(component); + } + } + } + } + } + None + } +} diff --git a/crates/syntax/src/lib.rs b/crates/syntax/src/lib.rs index e746fe1..81704de 100644 --- a/crates/syntax/src/lib.rs +++ b/crates/syntax/src/lib.rs @@ -1,5 +1,5 @@ -pub mod abstract_syntax_tree; -pub mod syntax; -pub mod syntax_node; -mod utils; -mod view_syntax; +pub mod abstract_syntax_tree; +pub mod syntax; +pub mod syntax_node; +mod utils; +mod view_syntax; diff --git a/crates/syntax/src/snapshots/syntax__syntax__grammar_tests____src__test_files__happy__block.circom.snap b/crates/syntax/src/snapshots/syntax__syntax__grammar_tests____src__test_files__happy__block.circom.snap deleted file mode 100644 index beaf281..0000000 --- a/crates/syntax/src/snapshots/syntax__syntax__grammar_tests____src__test_files__happy__block.circom.snap +++ /dev/null @@ -1,670 +0,0 @@ ---- -source: crates/syntax/src/syntax.rs -expression: "crate::view_syntax::view_ast(&syntax)" ---- - Block 0..1021 -| LCurly 0..1 -| | LCurly 0..1 "{" -| EndLine 1..2 -| | EndLine 1..2 -| | | EndLine 1..2 "\n" -| WhiteSpace 2..3 -| | WhiteSpace 2..3 -| | | WhiteSpace 2..3 " " -| CommentLine 3..28 -| | CommentLine 3..28 -| | | CommentLine 3..28 "//Declaration of signals." -| EndLine 28..29 -| | EndLine 28..29 -| | | EndLine 28..29 "\n" -| WhiteSpace 29..41 -| | WhiteSpace 29..41 -| | | WhiteSpace 29..41 " " -| StatementList 41..1020 -| | InputSignalDecl 41..56 -| | | SignalHeader 41..54 -| | | | SignalKw 41..47 -| | | | | SignalKw 41..47 "signal" -| | | | WhiteSpace 47..48 -| | | | | WhiteSpace 47..48 -| | | | | | WhiteSpace 47..48 " " -| | | | InputKw 48..53 -| | | | | InputKw 48..53 "input" -| | | | WhiteSpace 53..54 -| | | | | WhiteSpace 53..54 -| | | | | | WhiteSpace 53..54 " " -| | | Identifier 54..56 -| | | | Identifier 54..56 "in" -| | Error 56..89 -| | | Error 56..89 -| | | | Error 56..89 "expect Semicolon but got LBracket" -| | Statement 89..125 -| | | Error 89..90 -| | | | Expression 89..90 -| | | | | Error 89..90 -| | | | | | LBracket 89..90 -| | | | | | | LBracket 89..90 "[" -| | | Error 90..125 -| | | | Error 90..125 -| | | | | Error 90..125 "expect Semicolon but got Identifier" -| | Statement 125..159 -| | | Error 125..126 -| | | | Expression 125..126 -| | | | | ComponentIdentifier 125..126 -| | | | | | Identifier 125..126 -| | | | | | | Identifier 125..126 "N" -| | | Error 126..159 -| | | | Error 126..159 -| | | | | Error 126..159 "expect Semicolon but got RBracket" -| | Statement 159..161 -| | | Error 159..160 -| | | | Expression 159..160 -| | | | | Error 159..160 -| | | | | | RBracket 159..160 -| | | | | | | RBracket 159..160 "]" -| | | Semicolon 160..161 -| | | | Semicolon 160..161 ";" -| | EndLine 161..162 -| | | EndLine 161..162 -| | | | EndLine 161..162 "\n" -| | WhiteSpace 162..174 -| | | WhiteSpace 162..174 -| | | | WhiteSpace 162..174 " " -| | OutputSignalDecl 174..191 -| | | SignalHeader 174..188 -| | | | SignalKw 174..180 -| | | | | SignalKw 174..180 "signal" -| | | | WhiteSpace 180..181 -| | | | | WhiteSpace 180..181 -| | | | | | WhiteSpace 180..181 " " -| | | | OutputKw 181..187 -| | | | | OutputKw 181..187 "output" -| | | | WhiteSpace 187..188 -| | | | | WhiteSpace 187..188 -| | | | | | WhiteSpace 187..188 " " -| | | Identifier 188..191 -| | | | Identifier 188..191 "out" -| | Semicolon 191..192 -| | | Semicolon 191..192 ";" -| | EndLine 192..193 -| | | EndLine 192..193 -| | | | EndLine 192..193 "\n" -| | WhiteSpace 193..205 -| | | WhiteSpace 193..205 -| | | | WhiteSpace 193..205 " " -| | ComponentDecl 205..343 -| | | ComponentKw 205..214 -| | | | ComponentKw 205..214 "component" -| | | WhiteSpace 214..215 -| | | | WhiteSpace 214..215 -| | | | | WhiteSpace 214..215 " " -| | | ComponentIdentifier 215..219 -| | | | Identifier 215..219 -| | | | | Identifier 215..219 "comp" -| | | Error 219..249 -| | | | Error 219..249 -| | | | | Error 219..249 "expect Assign but got LBracket" -| | | TemplateName 249..283 -| | | | Error 249..283 -| | | | | Error 249..283 -| | | | | | Error 249..283 "expect Identifier but got LBracket" -| | | Error 283..313 -| | | | Error 283..313 -| | | | | Error 283..313 "expect LParen but got LBracket" -| | | Error 313..343 -| | | | Error 313..343 -| | | | | Error 313..343 "expect RParen but got LBracket" -| | Error 343..376 -| | | Error 343..376 -| | | | Error 343..376 "expect Semicolon but got LBracket" -| | Statement 376..412 -| | | Error 376..377 -| | | | Expression 376..377 -| | | | | Error 376..377 -| | | | | | LBracket 376..377 -| | | | | | | LBracket 376..377 "[" -| | | Error 377..412 -| | | | Error 377..412 -| | | | | Error 377..412 "expect Semicolon but got Identifier" -| | Statement 412..441 -| | | Error 412..413 -| | | | Expression 412..413 -| | | | | ComponentIdentifier 412..413 -| | | | | | Identifier 412..413 -| | | | | | | Identifier 412..413 "N" -| | | Error 413..441 -| | | | Error 413..441 -| | | | | Error 413..441 "expect Semicolon but got Sub" -| | Statement 441..476 -| | | Error 441..443 -| | | | Expression 441..443 -| | | | | Sub 441..443 -| | | | | | Sub 441..442 -| | | | | | | Sub 441..442 "-" -| | | | | | Number 442..443 -| | | | | | | Number 442..443 -| | | | | | | | Number 442..443 "1" -| | | Error 443..476 -| | | | Error 443..476 -| | | | | Error 443..476 "expect Semicolon but got RBracket" -| | Statement 476..478 -| | | Error 476..477 -| | | | Expression 476..477 -| | | | | Error 476..477 -| | | | | | RBracket 476..477 -| | | | | | | RBracket 476..477 "]" -| | | Semicolon 477..478 -| | | | Semicolon 477..478 ";" -| | EndLine 478..479 -| | | EndLine 478..479 -| | | | EndLine 478..479 "\n" -| | EndLine 479..480 -| | | EndLine 479..480 -| | | | EndLine 479..480 "\n" -| | WhiteSpace 480..492 -| | | WhiteSpace 480..492 -| | | | WhiteSpace 480..492 " " -| | CommentLine 492..505 -| | | CommentLine 492..505 -| | | | CommentLine 492..505 "//Statements." -| | EndLine 505..506 -| | | EndLine 505..506 -| | | | EndLine 505..506 "\n" -| | WhiteSpace 506..518 -| | | WhiteSpace 506..518 -| | | | WhiteSpace 506..518 " " -| | Statement 518..606 -| | | ForLoop 518..606 -| | | | ForKw 518..521 -| | | | | ForKw 518..521 "for" -| | | | LParen 521..522 -| | | | | LParen 521..522 "(" -| | | | VarDecl 522..531 -| | | | | VarKw 522..525 -| | | | | | VarKw 522..525 "var" -| | | | | WhiteSpace 525..526 -| | | | | | WhiteSpace 525..526 -| | | | | | | WhiteSpace 525..526 " " -| | | | | Identifier 526..527 -| | | | | | Identifier 526..527 "i" -| | | | | WhiteSpace 527..528 -| | | | | | WhiteSpace 527..528 -| | | | | | | WhiteSpace 527..528 " " -| | | | | Assign 528..529 -| | | | | | Assign 528..529 "=" -| | | | | WhiteSpace 529..530 -| | | | | | WhiteSpace 529..530 -| | | | | | | WhiteSpace 529..530 " " -| | | | | Expression 530..531 -| | | | | | Number 530..531 -| | | | | | | Number 530..531 -| | | | | | | | Number 530..531 "0" -| | | | Semicolon 531..532 -| | | | | Semicolon 531..532 ";" -| | | | WhiteSpace 532..533 -| | | | | WhiteSpace 532..533 -| | | | | | WhiteSpace 532..533 " " -| | | | Expression 533..540 -| | | | | LessThan 533..540 -| | | | | | Identifier 533..534 -| | | | | | | Identifier 533..534 -| | | | | | | | Identifier 533..534 "i" -| | | | | | WhiteSpace 534..535 -| | | | | | | WhiteSpace 534..535 -| | | | | | | | WhiteSpace 534..535 " " -| | | | | | LessThan 535..536 -| | | | | | | LessThan 535..536 "<" -| | | | | | WhiteSpace 536..537 -| | | | | | | WhiteSpace 536..537 -| | | | | | | | WhiteSpace 536..537 " " -| | | | | | Sub 537..540 -| | | | | | | Identifier 537..538 -| | | | | | | | Identifier 537..538 -| | | | | | | | | Identifier 537..538 "N" -| | | | | | | Sub 538..539 -| | | | | | | | Sub 538..539 "-" -| | | | | | | Number 539..540 -| | | | | | | | Number 539..540 -| | | | | | | | | Number 539..540 "1" -| | | | Semicolon 540..541 -| | | | | Semicolon 540..541 ";" -| | | | WhiteSpace 541..542 -| | | | | WhiteSpace 541..542 -| | | | | | WhiteSpace 541..542 " " -| | | | Error 542..543 -| | | | | Expression 542..543 -| | | | | | ComponentIdentifier 542..543 -| | | | | | | Identifier 542..543 -| | | | | | | | Identifier 542..543 "i" -| | | | Error 543..572 -| | | | | Error 543..572 -| | | | | | Error 543..572 "expect RParen but got UnitInc" -| | | | Error 572..575 -| | | | | Expression 572..575 -| | | | | | UnitInc 572..575 -| | | | | | | UnitInc 572..574 -| | | | | | | | UnitInc 572..574 "++" -| | | | | | | Error 574..575 -| | | | | | | | RParen 574..575 -| | | | | | | | | RParen 574..575 ")" -| | | | Error 575..606 -| | | | | Error 575..606 -| | | | | | Error 575..606 "expect Semicolon but got LCurly" -| | Statement 606..694 -| | | Block 606..694 -| | | | LCurly 606..607 -| | | | | LCurly 606..607 "{" -| | | | EndLine 607..608 -| | | | | EndLine 607..608 -| | | | | | EndLine 607..608 "\n" -| | | | WhiteSpace 608..624 -| | | | | WhiteSpace 608..624 -| | | | | | WhiteSpace 608..624 " " -| | | | StatementList 624..693 -| | | | | Statement 624..680 -| | | | | | AssignStatement 624..679 -| | | | | | | Expression 624..632 -| | | | | | | | ComponentIdentifier 624..628 -| | | | | | | | | Identifier 624..628 -| | | | | | | | | | Identifier 624..628 "comp" -| | | | | | | | LBracket 628..629 -| | | | | | | | | LBracket 628..629 "[" -| | | | | | | | Expression 629..630 -| | | | | | | | | Identifier 629..630 -| | | | | | | | | | Identifier 629..630 -| | | | | | | | | | | Identifier 629..630 "i" -| | | | | | | | RBracket 630..631 -| | | | | | | | | RBracket 630..631 "]" -| | | | | | | | WhiteSpace 631..632 -| | | | | | | | | WhiteSpace 631..632 -| | | | | | | | | | WhiteSpace 631..632 " " -| | | | | | | Assign 632..633 -| | | | | | | | Assign 632..633 "=" -| | | | | | | WhiteSpace 633..634 -| | | | | | | | WhiteSpace 633..634 -| | | | | | | | | WhiteSpace 633..634 " " -| | | | | | | Expression 634..679 -| | | | | | | | Call 634..679 -| | | | | | | | | Identifier 634..645 -| | | | | | | | | | Identifier 634..645 -| | | | | | | | | | | Identifier 634..645 "Multiplier2" -| | | | | | | | | Tuple 645..679 -| | | | | | | | | | LParen 645..646 -| | | | | | | | | | | LParen 645..646 "(" -| | | | | | | | | | Error 646..678 -| | | | | | | | | | | Error 646..678 -| | | | | | | | | | | | Error 646..678 "expect Identifier but got RParen" -| | | | | | | | | | RParen 678..679 -| | | | | | | | | | | RParen 678..679 ")" -| | | | | | Semicolon 679..680 -| | | | | | | Semicolon 679..680 ";" -| | | | | EndLine 680..681 -| | | | | | EndLine 680..681 -| | | | | | | EndLine 680..681 "\n" -| | | | | WhiteSpace 681..693 -| | | | | | WhiteSpace 681..693 -| | | | | | | WhiteSpace 681..693 " " -| | | | RCurly 693..694 -| | | | | RCurly 693..694 "}" -| | EndLine 694..695 -| | | EndLine 694..695 -| | | | EndLine 694..695 "\n" -| | WhiteSpace 695..707 -| | | WhiteSpace 695..707 -| | | | WhiteSpace 695..707 " " -| | Statement 707..729 -| | | AssignStatement 707..728 -| | | | ComponentCall 707..718 -| | | | | ComponentIdentifier 707..711 -| | | | | | Identifier 707..711 -| | | | | | | Identifier 707..711 "comp" -| | | | | LBracket 711..712 -| | | | | | LBracket 711..712 "[" -| | | | | Expression 712..713 -| | | | | | Number 712..713 -| | | | | | | Number 712..713 -| | | | | | | | Number 712..713 "0" -| | | | | RBracket 713..714 -| | | | | | RBracket 713..714 "]" -| | | | | Dot 714..715 -| | | | | | Dot 714..715 "." -| | | | | Identifier 715..718 -| | | | | | Identifier 715..718 "in1" -| | | | WhiteSpace 718..719 -| | | | | WhiteSpace 718..719 -| | | | | | WhiteSpace 718..719 " " -| | | | RAssignConstraintSignal 719..722 -| | | | | RAssignConstraintSignal 719..722 "<==" -| | | | WhiteSpace 722..723 -| | | | | WhiteSpace 722..723 -| | | | | | WhiteSpace 722..723 " " -| | | | Expression 723..728 -| | | | | ArrayQuery 723..728 -| | | | | | Identifier 723..725 -| | | | | | | Identifier 723..725 -| | | | | | | | Identifier 723..725 "in" -| | | | | | LBracket 725..726 -| | | | | | | LBracket 725..726 "[" -| | | | | | Number 726..727 -| | | | | | | Number 726..727 -| | | | | | | | Number 726..727 "0" -| | | | | | RBracket 727..728 -| | | | | | | RBracket 727..728 "]" -| | | Semicolon 728..729 -| | | | Semicolon 728..729 ";" -| | EndLine 729..730 -| | | EndLine 729..730 -| | | | EndLine 729..730 "\n" -| | WhiteSpace 730..742 -| | | WhiteSpace 730..742 -| | | | WhiteSpace 730..742 " " -| | Statement 742..764 -| | | AssignStatement 742..763 -| | | | ComponentCall 742..753 -| | | | | ComponentIdentifier 742..746 -| | | | | | Identifier 742..746 -| | | | | | | Identifier 742..746 "comp" -| | | | | LBracket 746..747 -| | | | | | LBracket 746..747 "[" -| | | | | Expression 747..748 -| | | | | | Number 747..748 -| | | | | | | Number 747..748 -| | | | | | | | Number 747..748 "0" -| | | | | RBracket 748..749 -| | | | | | RBracket 748..749 "]" -| | | | | Dot 749..750 -| | | | | | Dot 749..750 "." -| | | | | Identifier 750..753 -| | | | | | Identifier 750..753 "in2" -| | | | WhiteSpace 753..754 -| | | | | WhiteSpace 753..754 -| | | | | | WhiteSpace 753..754 " " -| | | | RAssignConstraintSignal 754..757 -| | | | | RAssignConstraintSignal 754..757 "<==" -| | | | WhiteSpace 757..758 -| | | | | WhiteSpace 757..758 -| | | | | | WhiteSpace 757..758 " " -| | | | Expression 758..763 -| | | | | ArrayQuery 758..763 -| | | | | | Identifier 758..760 -| | | | | | | Identifier 758..760 -| | | | | | | | Identifier 758..760 "in" -| | | | | | LBracket 760..761 -| | | | | | | LBracket 760..761 "[" -| | | | | | Number 761..762 -| | | | | | | Number 761..762 -| | | | | | | | Number 761..762 "1" -| | | | | | RBracket 762..763 -| | | | | | | RBracket 762..763 "]" -| | | Semicolon 763..764 -| | | | Semicolon 763..764 ";" -| | EndLine 764..765 -| | | EndLine 764..765 -| | | | EndLine 764..765 "\n" -| | WhiteSpace 765..777 -| | | WhiteSpace 765..777 -| | | | WhiteSpace 765..777 " " -| | Statement 777..865 -| | | ForLoop 777..865 -| | | | ForKw 777..780 -| | | | | ForKw 777..780 "for" -| | | | LParen 780..781 -| | | | | LParen 780..781 "(" -| | | | VarDecl 781..790 -| | | | | VarKw 781..784 -| | | | | | VarKw 781..784 "var" -| | | | | WhiteSpace 784..785 -| | | | | | WhiteSpace 784..785 -| | | | | | | WhiteSpace 784..785 " " -| | | | | Identifier 785..786 -| | | | | | Identifier 785..786 "i" -| | | | | WhiteSpace 786..787 -| | | | | | WhiteSpace 786..787 -| | | | | | | WhiteSpace 786..787 " " -| | | | | Assign 787..788 -| | | | | | Assign 787..788 "=" -| | | | | WhiteSpace 788..789 -| | | | | | WhiteSpace 788..789 -| | | | | | | WhiteSpace 788..789 " " -| | | | | Expression 789..790 -| | | | | | Number 789..790 -| | | | | | | Number 789..790 -| | | | | | | | Number 789..790 "0" -| | | | Semicolon 790..791 -| | | | | Semicolon 790..791 ";" -| | | | WhiteSpace 791..792 -| | | | | WhiteSpace 791..792 -| | | | | | WhiteSpace 791..792 " " -| | | | Expression 792..799 -| | | | | LessThan 792..799 -| | | | | | Identifier 792..793 -| | | | | | | Identifier 792..793 -| | | | | | | | Identifier 792..793 "i" -| | | | | | WhiteSpace 793..794 -| | | | | | | WhiteSpace 793..794 -| | | | | | | | WhiteSpace 793..794 " " -| | | | | | LessThan 794..795 -| | | | | | | LessThan 794..795 "<" -| | | | | | WhiteSpace 795..796 -| | | | | | | WhiteSpace 795..796 -| | | | | | | | WhiteSpace 795..796 " " -| | | | | | Sub 796..799 -| | | | | | | Identifier 796..797 -| | | | | | | | Identifier 796..797 -| | | | | | | | | Identifier 796..797 "N" -| | | | | | | Sub 797..798 -| | | | | | | | Sub 797..798 "-" -| | | | | | | Number 798..799 -| | | | | | | | Number 798..799 -| | | | | | | | | Number 798..799 "2" -| | | | Semicolon 799..800 -| | | | | Semicolon 799..800 ";" -| | | | WhiteSpace 800..801 -| | | | | WhiteSpace 800..801 -| | | | | | WhiteSpace 800..801 " " -| | | | Error 801..802 -| | | | | Expression 801..802 -| | | | | | ComponentIdentifier 801..802 -| | | | | | | Identifier 801..802 -| | | | | | | | Identifier 801..802 "i" -| | | | Error 802..831 -| | | | | Error 802..831 -| | | | | | Error 802..831 "expect RParen but got UnitInc" -| | | | Error 831..834 -| | | | | Expression 831..834 -| | | | | | UnitInc 831..834 -| | | | | | | UnitInc 831..833 -| | | | | | | | UnitInc 831..833 "++" -| | | | | | | Error 833..834 -| | | | | | | | RParen 833..834 -| | | | | | | | | RParen 833..834 ")" -| | | | Error 834..865 -| | | | | Error 834..865 -| | | | | | Error 834..865 "expect Semicolon but got LCurly" -| | Statement 865..971 -| | | Block 865..971 -| | | | LCurly 865..866 -| | | | | LCurly 865..866 "{" -| | | | EndLine 866..867 -| | | | | EndLine 866..867 -| | | | | | EndLine 866..867 "\n" -| | | | WhiteSpace 867..883 -| | | | | WhiteSpace 867..883 -| | | | | | WhiteSpace 867..883 " " -| | | | StatementList 883..970 -| | | | | Statement 883..913 -| | | | | | AssignStatement 883..912 -| | | | | | | ComponentCall 883..896 -| | | | | | | | ComponentIdentifier 883..887 -| | | | | | | | | Identifier 883..887 -| | | | | | | | | | Identifier 883..887 "comp" -| | | | | | | | LBracket 887..888 -| | | | | | | | | LBracket 887..888 "[" -| | | | | | | | Expression 888..891 -| | | | | | | | | Add 888..891 -| | | | | | | | | | Identifier 888..889 -| | | | | | | | | | | Identifier 888..889 -| | | | | | | | | | | | Identifier 888..889 "i" -| | | | | | | | | | Add 889..890 -| | | | | | | | | | | Add 889..890 "+" -| | | | | | | | | | Number 890..891 -| | | | | | | | | | | Number 890..891 -| | | | | | | | | | | | Number 890..891 "1" -| | | | | | | | RBracket 891..892 -| | | | | | | | | RBracket 891..892 "]" -| | | | | | | | Dot 892..893 -| | | | | | | | | Dot 892..893 "." -| | | | | | | | Identifier 893..896 -| | | | | | | | | Identifier 893..896 "in1" -| | | | | | | WhiteSpace 896..897 -| | | | | | | | WhiteSpace 896..897 -| | | | | | | | | WhiteSpace 896..897 " " -| | | | | | | RAssignConstraintSignal 897..900 -| | | | | | | | RAssignConstraintSignal 897..900 "<==" -| | | | | | | WhiteSpace 900..901 -| | | | | | | | WhiteSpace 900..901 -| | | | | | | | | WhiteSpace 900..901 " " -| | | | | | | Expression 901..912 -| | | | | | | | ComponentCall 901..912 -| | | | | | | | | ArrayQuery 901..908 -| | | | | | | | | | Identifier 901..905 -| | | | | | | | | | | Identifier 901..905 -| | | | | | | | | | | | Identifier 901..905 "comp" -| | | | | | | | | | LBracket 905..906 -| | | | | | | | | | | LBracket 905..906 "[" -| | | | | | | | | | Identifier 906..907 -| | | | | | | | | | | Identifier 906..907 -| | | | | | | | | | | | Identifier 906..907 "i" -| | | | | | | | | | RBracket 907..908 -| | | | | | | | | | | RBracket 907..908 "]" -| | | | | | | | | Dot 908..909 -| | | | | | | | | | Dot 908..909 "." -| | | | | | | | | Identifier 909..912 -| | | | | | | | | | Identifier 909..912 "out" -| | | | | | Semicolon 912..913 -| | | | | | | Semicolon 912..913 ";" -| | | | | EndLine 913..914 -| | | | | | EndLine 913..914 -| | | | | | | EndLine 913..914 "\n" -| | | | | WhiteSpace 914..930 -| | | | | | WhiteSpace 914..930 -| | | | | | | WhiteSpace 914..930 " " -| | | | | Statement 930..956 -| | | | | | AssignStatement 930..955 -| | | | | | | ComponentCall 930..943 -| | | | | | | | ComponentIdentifier 930..934 -| | | | | | | | | Identifier 930..934 -| | | | | | | | | | Identifier 930..934 "comp" -| | | | | | | | LBracket 934..935 -| | | | | | | | | LBracket 934..935 "[" -| | | | | | | | Expression 935..938 -| | | | | | | | | Add 935..938 -| | | | | | | | | | Identifier 935..936 -| | | | | | | | | | | Identifier 935..936 -| | | | | | | | | | | | Identifier 935..936 "i" -| | | | | | | | | | Add 936..937 -| | | | | | | | | | | Add 936..937 "+" -| | | | | | | | | | Number 937..938 -| | | | | | | | | | | Number 937..938 -| | | | | | | | | | | | Number 937..938 "1" -| | | | | | | | RBracket 938..939 -| | | | | | | | | RBracket 938..939 "]" -| | | | | | | | Dot 939..940 -| | | | | | | | | Dot 939..940 "." -| | | | | | | | Identifier 940..943 -| | | | | | | | | Identifier 940..943 "in2" -| | | | | | | WhiteSpace 943..944 -| | | | | | | | WhiteSpace 943..944 -| | | | | | | | | WhiteSpace 943..944 " " -| | | | | | | RAssignConstraintSignal 944..947 -| | | | | | | | RAssignConstraintSignal 944..947 "<==" -| | | | | | | WhiteSpace 947..948 -| | | | | | | | WhiteSpace 947..948 -| | | | | | | | | WhiteSpace 947..948 " " -| | | | | | | Expression 948..955 -| | | | | | | | ArrayQuery 948..955 -| | | | | | | | | Identifier 948..950 -| | | | | | | | | | Identifier 948..950 -| | | | | | | | | | | Identifier 948..950 "in" -| | | | | | | | | LBracket 950..951 -| | | | | | | | | | LBracket 950..951 "[" -| | | | | | | | | Add 951..954 -| | | | | | | | | | Identifier 951..952 -| | | | | | | | | | | Identifier 951..952 -| | | | | | | | | | | | Identifier 951..952 "i" -| | | | | | | | | | Add 952..953 -| | | | | | | | | | | Add 952..953 "+" -| | | | | | | | | | Number 953..954 -| | | | | | | | | | | Number 953..954 -| | | | | | | | | | | | Number 953..954 "2" -| | | | | | | | | RBracket 954..955 -| | | | | | | | | | RBracket 954..955 "]" -| | | | | | Semicolon 955..956 -| | | | | | | Semicolon 955..956 ";" -| | | | | EndLine 956..957 -| | | | | | EndLine 956..957 -| | | | | | | EndLine 956..957 "\n" -| | | | | EndLine 957..958 -| | | | | | EndLine 957..958 -| | | | | | | EndLine 957..958 "\n" -| | | | | WhiteSpace 958..970 -| | | | | | WhiteSpace 958..970 -| | | | | | | WhiteSpace 958..970 " " -| | | | RCurly 970..971 -| | | | | RCurly 970..971 "}" -| | EndLine 971..972 -| | | EndLine 971..972 -| | | | EndLine 971..972 "\n" -| | WhiteSpace 972..984 -| | | WhiteSpace 972..984 -| | | | WhiteSpace 972..984 " " -| | Statement 984..1006 -| | | AssignStatement 984..1005 -| | | | Expression 984..988 -| | | | | ComponentIdentifier 984..987 -| | | | | | Identifier 984..987 -| | | | | | | Identifier 984..987 "out" -| | | | | WhiteSpace 987..988 -| | | | | | WhiteSpace 987..988 -| | | | | | | WhiteSpace 987..988 " " -| | | | RAssignConstraintSignal 988..991 -| | | | | RAssignConstraintSignal 988..991 "<==" -| | | | WhiteSpace 991..992 -| | | | | WhiteSpace 991..992 -| | | | | | WhiteSpace 991..992 " " -| | | | Expression 992..1005 -| | | | | ComponentCall 992..1005 -| | | | | | ArrayQuery 992..1001 -| | | | | | | Identifier 992..996 -| | | | | | | | Identifier 992..996 -| | | | | | | | | Identifier 992..996 "comp" -| | | | | | | LBracket 996..997 -| | | | | | | | LBracket 996..997 "[" -| | | | | | | Sub 997..1000 -| | | | | | | | Identifier 997..998 -| | | | | | | | | Identifier 997..998 -| | | | | | | | | | Identifier 997..998 "N" -| | | | | | | | Sub 998..999 -| | | | | | | | | Sub 998..999 "-" -| | | | | | | | Number 999..1000 -| | | | | | | | | Number 999..1000 -| | | | | | | | | | Number 999..1000 "2" -| | | | | | | RBracket 1000..1001 -| | | | | | | | RBracket 1000..1001 "]" -| | | | | | Dot 1001..1002 -| | | | | | | Dot 1001..1002 "." -| | | | | | Identifier 1002..1005 -| | | | | | | Identifier 1002..1005 "out" -| | | Semicolon 1005..1006 -| | | | Semicolon 1005..1006 ";" -| | WhiteSpace 1006..1007 -| | | WhiteSpace 1006..1007 -| | | | WhiteSpace 1006..1007 " " -| | EndLine 1007..1008 -| | | EndLine 1007..1008 -| | | | EndLine 1007..1008 "\n" -| | WhiteSpace 1008..1020 -| | | WhiteSpace 1008..1020 -| | | | WhiteSpace 1008..1020 " " -| RCurly 1020..1021 -| | RCurly 1020..1021 "}" diff --git a/crates/syntax/src/snapshots/syntax__syntax__grammar_tests____src__test_files__happy__pragma.circom.snap b/crates/syntax/src/snapshots/syntax__syntax__grammar_tests____src__test_files__happy__pragma.circom.snap deleted file mode 100644 index f84ef6f..0000000 --- a/crates/syntax/src/snapshots/syntax__syntax__grammar_tests____src__test_files__happy__pragma.circom.snap +++ /dev/null @@ -1,19 +0,0 @@ ---- -source: crates/syntax/src/syntax.rs -expression: "crate::view_syntax::view_ast(&syntax)" ---- - Pragma 0..20 -| Pragma 0..6 -| | Pragma 0..6 "pragma" -| WhiteSpace 6..7 -| | WhiteSpace 6..7 -| | | WhiteSpace 6..7 " " -| Circom 7..13 -| | Circom 7..13 "circom" -| WhiteSpace 13..14 -| | WhiteSpace 13..14 -| | | WhiteSpace 13..14 " " -| Version 14..19 -| | Version 14..19 "2.0.0" -| Semicolon 19..20 -| | Semicolon 19..20 ";" diff --git a/crates/syntax/src/snapshots/syntax__syntax__grammar_tests____src__test_files__happy__template.circom.snap b/crates/syntax/src/snapshots/syntax__syntax__grammar_tests____src__test_files__happy__template.circom.snap deleted file mode 100644 index 6d1a073..0000000 --- a/crates/syntax/src/snapshots/syntax__syntax__grammar_tests____src__test_files__happy__template.circom.snap +++ /dev/null @@ -1,358 +0,0 @@ ---- -source: crates/syntax/src/syntax.rs -expression: "crate::view_syntax::view_ast(&syntax)" ---- - TemplateDef 0..784 -| TemplateKw 0..8 -| | TemplateKw 0..8 "template" -| WhiteSpace 8..9 -| | WhiteSpace 8..9 -| | | WhiteSpace 8..9 " " -| TemplateName 9..20 -| | Identifier 9..20 -| | | Identifier 9..20 "MultiplierN" -| WhiteSpace 20..21 -| | WhiteSpace 20..21 -| | | WhiteSpace 20..21 " " -| LParen 21..22 -| | LParen 21..22 "(" -| ParameterList 22..30 -| | Identifier 22..23 -| | | Identifier 22..23 "N" -| | Comma 23..24 -| | | Comma 23..24 "," -| | WhiteSpace 24..25 -| | | WhiteSpace 24..25 -| | | | WhiteSpace 24..25 " " -| | Identifier 25..26 -| | | Identifier 25..26 "P" -| | Comma 26..27 -| | | Comma 26..27 "," -| | WhiteSpace 27..28 -| | | WhiteSpace 27..28 -| | | | WhiteSpace 27..28 " " -| | Identifier 28..30 -| | | Identifier 28..30 "QQ" -| RParen 30..31 -| | RParen 30..31 ")" -| WhiteSpace 31..32 -| | WhiteSpace 31..32 -| | | WhiteSpace 31..32 " " -| Block 32..784 -| | LCurly 32..33 -| | | LCurly 32..33 "{" -| | EndLine 33..34 -| | | EndLine 33..34 -| | | | EndLine 33..34 "\n" -| | WhiteSpace 34..46 -| | | WhiteSpace 34..46 -| | | | WhiteSpace 34..46 " " -| | CommentLine 46..86 -| | | CommentLine 46..86 -| | | | CommentLine 46..86 "//Declaration of signals and components." -| | EndLine 86..87 -| | | EndLine 86..87 -| | | | EndLine 86..87 "\n" -| | WhiteSpace 87..99 -| | | WhiteSpace 87..99 -| | | | WhiteSpace 87..99 " " -| | StatementList 99..783 -| | | InputSignalDecl 99..114 -| | | | SignalHeader 99..112 -| | | | | SignalKw 99..105 -| | | | | | SignalKw 99..105 "signal" -| | | | | WhiteSpace 105..106 -| | | | | | WhiteSpace 105..106 -| | | | | | | WhiteSpace 105..106 " " -| | | | | InputKw 106..111 -| | | | | | InputKw 106..111 "input" -| | | | | WhiteSpace 111..112 -| | | | | | WhiteSpace 111..112 -| | | | | | | WhiteSpace 111..112 " " -| | | | Identifier 112..114 -| | | | | Identifier 112..114 "in" -| | | Error 114..147 -| | | | Error 114..147 -| | | | | Error 114..147 "expect Semicolon but got LBracket" -| | | Statement 147..183 -| | | | Error 147..148 -| | | | | Expression 147..148 -| | | | | | Error 147..148 -| | | | | | | LBracket 147..148 -| | | | | | | | LBracket 147..148 "[" -| | | | Error 148..183 -| | | | | Error 148..183 -| | | | | | Error 148..183 "expect Semicolon but got Identifier" -| | | Statement 183..217 -| | | | Error 183..184 -| | | | | Expression 183..184 -| | | | | | ComponentIdentifier 183..184 -| | | | | | | Identifier 183..184 -| | | | | | | | Identifier 183..184 "N" -| | | | Error 184..217 -| | | | | Error 184..217 -| | | | | | Error 184..217 "expect Semicolon but got RBracket" -| | | Statement 217..219 -| | | | Error 217..218 -| | | | | Expression 217..218 -| | | | | | Error 217..218 -| | | | | | | RBracket 217..218 -| | | | | | | | RBracket 217..218 "]" -| | | | Semicolon 218..219 -| | | | | Semicolon 218..219 ";" -| | | EndLine 219..220 -| | | | EndLine 219..220 -| | | | | EndLine 219..220 "\n" -| | | WhiteSpace 220..232 -| | | | WhiteSpace 220..232 -| | | | | WhiteSpace 220..232 " " -| | | OutputSignalDecl 232..249 -| | | | SignalHeader 232..246 -| | | | | SignalKw 232..238 -| | | | | | SignalKw 232..238 "signal" -| | | | | WhiteSpace 238..239 -| | | | | | WhiteSpace 238..239 -| | | | | | | WhiteSpace 238..239 " " -| | | | | OutputKw 239..245 -| | | | | | OutputKw 239..245 "output" -| | | | | WhiteSpace 245..246 -| | | | | | WhiteSpace 245..246 -| | | | | | | WhiteSpace 245..246 " " -| | | | Identifier 246..249 -| | | | | Identifier 246..249 "out" -| | | Semicolon 249..250 -| | | | Semicolon 249..250 ";" -| | | EndLine 250..251 -| | | | EndLine 250..251 -| | | | | EndLine 250..251 "\n" -| | | WhiteSpace 251..263 -| | | | WhiteSpace 251..263 -| | | | | WhiteSpace 251..263 " " -| | | ComponentDecl 263..401 -| | | | ComponentKw 263..272 -| | | | | ComponentKw 263..272 "component" -| | | | WhiteSpace 272..273 -| | | | | WhiteSpace 272..273 -| | | | | | WhiteSpace 272..273 " " -| | | | ComponentIdentifier 273..277 -| | | | | Identifier 273..277 -| | | | | | Identifier 273..277 "comp" -| | | | Error 277..307 -| | | | | Error 277..307 -| | | | | | Error 277..307 "expect Assign but got LBracket" -| | | | TemplateName 307..341 -| | | | | Error 307..341 -| | | | | | Error 307..341 -| | | | | | | Error 307..341 "expect Identifier but got LBracket" -| | | | Error 341..371 -| | | | | Error 341..371 -| | | | | | Error 341..371 "expect LParen but got LBracket" -| | | | Error 371..401 -| | | | | Error 371..401 -| | | | | | Error 371..401 "expect RParen but got LBracket" -| | | Error 401..434 -| | | | Error 401..434 -| | | | | Error 401..434 "expect Semicolon but got LBracket" -| | | Statement 434..470 -| | | | Error 434..435 -| | | | | Expression 434..435 -| | | | | | Error 434..435 -| | | | | | | LBracket 434..435 -| | | | | | | | LBracket 434..435 "[" -| | | | Error 435..470 -| | | | | Error 435..470 -| | | | | | Error 435..470 "expect Semicolon but got Identifier" -| | | Statement 470..499 -| | | | Error 470..471 -| | | | | Expression 470..471 -| | | | | | ComponentIdentifier 470..471 -| | | | | | | Identifier 470..471 -| | | | | | | | Identifier 470..471 "N" -| | | | Error 471..499 -| | | | | Error 471..499 -| | | | | | Error 471..499 "expect Semicolon but got Sub" -| | | Statement 499..534 -| | | | Error 499..501 -| | | | | Expression 499..501 -| | | | | | Sub 499..501 -| | | | | | | Sub 499..500 -| | | | | | | | Sub 499..500 "-" -| | | | | | | Number 500..501 -| | | | | | | | Number 500..501 -| | | | | | | | | Number 500..501 "1" -| | | | Error 501..534 -| | | | | Error 501..534 -| | | | | | Error 501..534 "expect Semicolon but got RBracket" -| | | Statement 534..536 -| | | | Error 534..535 -| | | | | Expression 534..535 -| | | | | | Error 534..535 -| | | | | | | RBracket 534..535 -| | | | | | | | RBracket 534..535 "]" -| | | | Semicolon 535..536 -| | | | | Semicolon 535..536 ";" -| | | EndLine 536..537 -| | | | EndLine 536..537 -| | | | | EndLine 536..537 "\n" -| | | WhiteSpace 537..550 -| | | | WhiteSpace 537..550 -| | | | | WhiteSpace 537..550 " " -| | | EndLine 550..551 -| | | | EndLine 550..551 -| | | | | EndLine 550..551 "\n" -| | | WhiteSpace 551..563 -| | | | WhiteSpace 551..563 -| | | | | WhiteSpace 551..563 " " -| | | CommentLine 563..576 -| | | | CommentLine 563..576 -| | | | | CommentLine 563..576 "//Statements." -| | | EndLine 576..577 -| | | | EndLine 576..577 -| | | | | EndLine 576..577 "\n" -| | | WhiteSpace 577..589 -| | | | WhiteSpace 577..589 -| | | | | WhiteSpace 577..589 " " -| | | Statement 589..677 -| | | | ForLoop 589..677 -| | | | | ForKw 589..592 -| | | | | | ForKw 589..592 "for" -| | | | | LParen 592..593 -| | | | | | LParen 592..593 "(" -| | | | | VarDecl 593..602 -| | | | | | VarKw 593..596 -| | | | | | | VarKw 593..596 "var" -| | | | | | WhiteSpace 596..597 -| | | | | | | WhiteSpace 596..597 -| | | | | | | | WhiteSpace 596..597 " " -| | | | | | Identifier 597..598 -| | | | | | | Identifier 597..598 "i" -| | | | | | WhiteSpace 598..599 -| | | | | | | WhiteSpace 598..599 -| | | | | | | | WhiteSpace 598..599 " " -| | | | | | Assign 599..600 -| | | | | | | Assign 599..600 "=" -| | | | | | WhiteSpace 600..601 -| | | | | | | WhiteSpace 600..601 -| | | | | | | | WhiteSpace 600..601 " " -| | | | | | Expression 601..602 -| | | | | | | Number 601..602 -| | | | | | | | Number 601..602 -| | | | | | | | | Number 601..602 "0" -| | | | | Semicolon 602..603 -| | | | | | Semicolon 602..603 ";" -| | | | | WhiteSpace 603..604 -| | | | | | WhiteSpace 603..604 -| | | | | | | WhiteSpace 603..604 " " -| | | | | Expression 604..611 -| | | | | | LessThan 604..611 -| | | | | | | Identifier 604..605 -| | | | | | | | Identifier 604..605 -| | | | | | | | | Identifier 604..605 "i" -| | | | | | | WhiteSpace 605..606 -| | | | | | | | WhiteSpace 605..606 -| | | | | | | | | WhiteSpace 605..606 " " -| | | | | | | LessThan 606..607 -| | | | | | | | LessThan 606..607 "<" -| | | | | | | WhiteSpace 607..608 -| | | | | | | | WhiteSpace 607..608 -| | | | | | | | | WhiteSpace 607..608 " " -| | | | | | | Sub 608..611 -| | | | | | | | Identifier 608..609 -| | | | | | | | | Identifier 608..609 -| | | | | | | | | | Identifier 608..609 "N" -| | | | | | | | Sub 609..610 -| | | | | | | | | Sub 609..610 "-" -| | | | | | | | Number 610..611 -| | | | | | | | | Number 610..611 -| | | | | | | | | | Number 610..611 "1" -| | | | | Semicolon 611..612 -| | | | | | Semicolon 611..612 ";" -| | | | | WhiteSpace 612..613 -| | | | | | WhiteSpace 612..613 -| | | | | | | WhiteSpace 612..613 " " -| | | | | Error 613..614 -| | | | | | Expression 613..614 -| | | | | | | ComponentIdentifier 613..614 -| | | | | | | | Identifier 613..614 -| | | | | | | | | Identifier 613..614 "i" -| | | | | Error 614..643 -| | | | | | Error 614..643 -| | | | | | | Error 614..643 "expect RParen but got UnitInc" -| | | | | Error 643..646 -| | | | | | Expression 643..646 -| | | | | | | UnitInc 643..646 -| | | | | | | | UnitInc 643..645 -| | | | | | | | | UnitInc 643..645 "++" -| | | | | | | | Error 645..646 -| | | | | | | | | RParen 645..646 -| | | | | | | | | | RParen 645..646 ")" -| | | | | Error 646..677 -| | | | | | Error 646..677 -| | | | | | | Error 646..677 "expect Semicolon but got LCurly" -| | | Statement 677..765 -| | | | Block 677..765 -| | | | | LCurly 677..678 -| | | | | | LCurly 677..678 "{" -| | | | | EndLine 678..679 -| | | | | | EndLine 678..679 -| | | | | | | EndLine 678..679 "\n" -| | | | | WhiteSpace 679..695 -| | | | | | WhiteSpace 679..695 -| | | | | | | WhiteSpace 679..695 " " -| | | | | StatementList 695..764 -| | | | | | Statement 695..751 -| | | | | | | AssignStatement 695..750 -| | | | | | | | Expression 695..703 -| | | | | | | | | ComponentIdentifier 695..699 -| | | | | | | | | | Identifier 695..699 -| | | | | | | | | | | Identifier 695..699 "comp" -| | | | | | | | | LBracket 699..700 -| | | | | | | | | | LBracket 699..700 "[" -| | | | | | | | | Expression 700..701 -| | | | | | | | | | Identifier 700..701 -| | | | | | | | | | | Identifier 700..701 -| | | | | | | | | | | | Identifier 700..701 "i" -| | | | | | | | | RBracket 701..702 -| | | | | | | | | | RBracket 701..702 "]" -| | | | | | | | | WhiteSpace 702..703 -| | | | | | | | | | WhiteSpace 702..703 -| | | | | | | | | | | WhiteSpace 702..703 " " -| | | | | | | | Assign 703..704 -| | | | | | | | | Assign 703..704 "=" -| | | | | | | | WhiteSpace 704..705 -| | | | | | | | | WhiteSpace 704..705 -| | | | | | | | | | WhiteSpace 704..705 " " -| | | | | | | | Expression 705..750 -| | | | | | | | | Call 705..750 -| | | | | | | | | | Identifier 705..716 -| | | | | | | | | | | Identifier 705..716 -| | | | | | | | | | | | Identifier 705..716 "Multiplier2" -| | | | | | | | | | Tuple 716..750 -| | | | | | | | | | | LParen 716..717 -| | | | | | | | | | | | LParen 716..717 "(" -| | | | | | | | | | | Error 717..749 -| | | | | | | | | | | | Error 717..749 -| | | | | | | | | | | | | Error 717..749 "expect Identifier but got RParen" -| | | | | | | | | | | RParen 749..750 -| | | | | | | | | | | | RParen 749..750 ")" -| | | | | | | Semicolon 750..751 -| | | | | | | | Semicolon 750..751 ";" -| | | | | | EndLine 751..752 -| | | | | | | EndLine 751..752 -| | | | | | | | EndLine 751..752 "\n" -| | | | | | WhiteSpace 752..764 -| | | | | | | WhiteSpace 752..764 -| | | | | | | | WhiteSpace 752..764 " " -| | | | | RCurly 764..765 -| | | | | | RCurly 764..765 "}" -| | | EndLine 765..766 -| | | | EndLine 765..766 -| | | | | EndLine 765..766 "\n" -| | | WhiteSpace 766..782 -| | | | WhiteSpace 766..782 -| | | | | WhiteSpace 766..782 " " -| | | EndLine 782..783 -| | | | EndLine 782..783 -| | | | | EndLine 782..783 "\n" -| | RCurly 783..784 -| | | RCurly 783..784 "}" diff --git a/crates/syntax/src/snapshots/syntax__syntax__grammar_tests____src__test_files__pragma.circom.snap b/crates/syntax/src/snapshots/syntax__syntax__grammar_tests____src__test_files__pragma.circom.snap deleted file mode 100644 index f84ef6f..0000000 --- a/crates/syntax/src/snapshots/syntax__syntax__grammar_tests____src__test_files__pragma.circom.snap +++ /dev/null @@ -1,19 +0,0 @@ ---- -source: crates/syntax/src/syntax.rs -expression: "crate::view_syntax::view_ast(&syntax)" ---- - Pragma 0..20 -| Pragma 0..6 -| | Pragma 0..6 "pragma" -| WhiteSpace 6..7 -| | WhiteSpace 6..7 -| | | WhiteSpace 6..7 " " -| Circom 7..13 -| | Circom 7..13 "circom" -| WhiteSpace 13..14 -| | WhiteSpace 13..14 -| | | WhiteSpace 13..14 " " -| Version 14..19 -| | Version 14..19 "2.0.0" -| Semicolon 19..20 -| | Semicolon 19..20 ";" diff --git a/crates/syntax/src/snapshots/syntax__syntax__grammar_tests__block_happy_test_statements.snap b/crates/syntax/src/snapshots/syntax__syntax__grammar_tests__block_happy_test_statements.snap deleted file mode 100644 index a0e6f49..0000000 --- a/crates/syntax/src/snapshots/syntax__syntax__grammar_tests__block_happy_test_statements.snap +++ /dev/null @@ -1,18 +0,0 @@ ---- -source: crates/syntax/src/syntax.rs -expression: statements ---- -- "[expect Semicolon but got Identifier" -- Nexpect Semicolon but got RBracket -- "];" -- "[expect Semicolon but got Identifier" -- Nexpect Semicolon but got Sub -- "-1expect Semicolon but got RBracket" -- "];" -- for(var i = 0; i < N-1; iexpect RParen but got UnitInc++)expect Semicolon but got LCurly -- "{\n comp[i] = Multiplier2(expect Identifier but got RParen);\n }" -- "comp[0].in1 <== in[0];" -- "comp[0].in2 <== in[1];" -- for(var i = 0; i < N-2; iexpect RParen but got UnitInc++)expect Semicolon but got LCurly -- "{\n comp[i+1].in1 <== comp[i].out;\n comp[i+1].in2 <== in[i+2];\n\n }" -- "out <== comp[N-2].out;" diff --git a/crates/syntax/src/snapshots/syntax__syntax__grammar_tests__template_happy_test_statements.snap b/crates/syntax/src/snapshots/syntax__syntax__grammar_tests__template_happy_test_statements.snap deleted file mode 100644 index 719979d..0000000 --- a/crates/syntax/src/snapshots/syntax__syntax__grammar_tests__template_happy_test_statements.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: crates/syntax/src/syntax.rs -expression: statements ---- -- "[expect Semicolon but got Identifier" -- Nexpect Semicolon but got RBracket -- "];" -- "[expect Semicolon but got Identifier" -- Nexpect Semicolon but got Sub -- "-1expect Semicolon but got RBracket" -- "];" -- for(var i = 0; i < N-1; iexpect RParen but got UnitInc++)expect Semicolon but got LCurly -- "{\n comp[i] = Multiplier2(expect Identifier but got RParen);\n }" diff --git a/crates/syntax/src/snapshots/syntax__syntax__tests____src__test_files__happy__block.circom.snap b/crates/syntax/src/snapshots/syntax__syntax__tests____src__test_files__happy__block.circom.snap index beaf281..1b3d146 100644 --- a/crates/syntax/src/snapshots/syntax__syntax__tests____src__test_files__happy__block.circom.snap +++ b/crates/syntax/src/snapshots/syntax__syntax__tests____src__test_files__happy__block.circom.snap @@ -1,670 +1,526 @@ --- source: crates/syntax/src/syntax.rs -expression: "crate::view_syntax::view_ast(&syntax)" +expression: "crate :: view_syntax :: view_ast(& syntax)" --- - Block 0..1021 + Block 0..533 | LCurly 0..1 | | LCurly 0..1 "{" -| EndLine 1..2 -| | EndLine 1..2 -| | | EndLine 1..2 "\n" -| WhiteSpace 2..3 -| | WhiteSpace 2..3 -| | | WhiteSpace 2..3 " " -| CommentLine 3..28 -| | CommentLine 3..28 -| | | CommentLine 3..28 "//Declaration of signals." -| EndLine 28..29 -| | EndLine 28..29 -| | | EndLine 28..29 "\n" -| WhiteSpace 29..41 -| | WhiteSpace 29..41 -| | | WhiteSpace 29..41 " " -| StatementList 41..1020 -| | InputSignalDecl 41..56 -| | | SignalHeader 41..54 -| | | | SignalKw 41..47 -| | | | | SignalKw 41..47 "signal" -| | | | WhiteSpace 47..48 -| | | | | WhiteSpace 47..48 -| | | | | | WhiteSpace 47..48 " " -| | | | InputKw 48..53 -| | | | | InputKw 48..53 "input" -| | | | WhiteSpace 53..54 -| | | | | WhiteSpace 53..54 -| | | | | | WhiteSpace 53..54 " " -| | | Identifier 54..56 -| | | | Identifier 54..56 "in" -| | Error 56..89 -| | | Error 56..89 -| | | | Error 56..89 "expect Semicolon but got LBracket" -| | Statement 89..125 -| | | Error 89..90 -| | | | Expression 89..90 -| | | | | Error 89..90 -| | | | | | LBracket 89..90 -| | | | | | | LBracket 89..90 "[" -| | | Error 90..125 -| | | | Error 90..125 -| | | | | Error 90..125 "expect Semicolon but got Identifier" -| | Statement 125..159 -| | | Error 125..126 -| | | | Expression 125..126 -| | | | | ComponentIdentifier 125..126 -| | | | | | Identifier 125..126 -| | | | | | | Identifier 125..126 "N" -| | | Error 126..159 -| | | | Error 126..159 -| | | | | Error 126..159 "expect Semicolon but got RBracket" -| | Statement 159..161 -| | | Error 159..160 -| | | | Expression 159..160 -| | | | | Error 159..160 -| | | | | | RBracket 159..160 -| | | | | | | RBracket 159..160 "]" -| | | Semicolon 160..161 -| | | | Semicolon 160..161 ";" -| | EndLine 161..162 -| | | EndLine 161..162 -| | | | EndLine 161..162 "\n" -| | WhiteSpace 162..174 -| | | WhiteSpace 162..174 -| | | | WhiteSpace 162..174 " " -| | OutputSignalDecl 174..191 -| | | SignalHeader 174..188 -| | | | SignalKw 174..180 -| | | | | SignalKw 174..180 "signal" -| | | | WhiteSpace 180..181 -| | | | | WhiteSpace 180..181 -| | | | | | WhiteSpace 180..181 " " -| | | | OutputKw 181..187 -| | | | | OutputKw 181..187 "output" -| | | | WhiteSpace 187..188 -| | | | | WhiteSpace 187..188 -| | | | | | WhiteSpace 187..188 " " -| | | Identifier 188..191 -| | | | Identifier 188..191 "out" -| | Semicolon 191..192 -| | | Semicolon 191..192 ";" -| | EndLine 192..193 -| | | EndLine 192..193 -| | | | EndLine 192..193 "\n" -| | WhiteSpace 193..205 -| | | WhiteSpace 193..205 -| | | | WhiteSpace 193..205 " " -| | ComponentDecl 205..343 -| | | ComponentKw 205..214 -| | | | ComponentKw 205..214 "component" -| | | WhiteSpace 214..215 -| | | | WhiteSpace 214..215 -| | | | | WhiteSpace 214..215 " " -| | | ComponentIdentifier 215..219 -| | | | Identifier 215..219 -| | | | | Identifier 215..219 "comp" -| | | Error 219..249 -| | | | Error 219..249 -| | | | | Error 219..249 "expect Assign but got LBracket" -| | | TemplateName 249..283 -| | | | Error 249..283 -| | | | | Error 249..283 -| | | | | | Error 249..283 "expect Identifier but got LBracket" -| | | Error 283..313 -| | | | Error 283..313 -| | | | | Error 283..313 "expect LParen but got LBracket" -| | | Error 313..343 -| | | | Error 313..343 -| | | | | Error 313..343 "expect RParen but got LBracket" -| | Error 343..376 -| | | Error 343..376 -| | | | Error 343..376 "expect Semicolon but got LBracket" -| | Statement 376..412 -| | | Error 376..377 -| | | | Expression 376..377 -| | | | | Error 376..377 -| | | | | | LBracket 376..377 -| | | | | | | LBracket 376..377 "[" -| | | Error 377..412 -| | | | Error 377..412 -| | | | | Error 377..412 "expect Semicolon but got Identifier" -| | Statement 412..441 -| | | Error 412..413 -| | | | Expression 412..413 -| | | | | ComponentIdentifier 412..413 -| | | | | | Identifier 412..413 -| | | | | | | Identifier 412..413 "N" -| | | Error 413..441 -| | | | Error 413..441 -| | | | | Error 413..441 "expect Semicolon but got Sub" -| | Statement 441..476 -| | | Error 441..443 -| | | | Expression 441..443 -| | | | | Sub 441..443 -| | | | | | Sub 441..442 -| | | | | | | Sub 441..442 "-" -| | | | | | Number 442..443 -| | | | | | | Number 442..443 -| | | | | | | | Number 442..443 "1" -| | | Error 443..476 -| | | | Error 443..476 -| | | | | Error 443..476 "expect Semicolon but got RBracket" -| | Statement 476..478 -| | | Error 476..477 -| | | | Expression 476..477 -| | | | | Error 476..477 -| | | | | | RBracket 476..477 -| | | | | | | RBracket 476..477 "]" -| | | Semicolon 477..478 -| | | | Semicolon 477..478 ";" -| | EndLine 478..479 -| | | EndLine 478..479 -| | | | EndLine 478..479 "\n" -| | EndLine 479..480 -| | | EndLine 479..480 -| | | | EndLine 479..480 "\n" -| | WhiteSpace 480..492 -| | | WhiteSpace 480..492 -| | | | WhiteSpace 480..492 " " -| | CommentLine 492..505 -| | | CommentLine 492..505 -| | | | CommentLine 492..505 "//Statements." -| | EndLine 505..506 -| | | EndLine 505..506 -| | | | EndLine 505..506 "\n" -| | WhiteSpace 506..518 -| | | WhiteSpace 506..518 -| | | | WhiteSpace 506..518 " " -| | Statement 518..606 -| | | ForLoop 518..606 -| | | | ForKw 518..521 -| | | | | ForKw 518..521 "for" -| | | | LParen 521..522 -| | | | | LParen 521..522 "(" -| | | | VarDecl 522..531 -| | | | | VarKw 522..525 -| | | | | | VarKw 522..525 "var" -| | | | | WhiteSpace 525..526 -| | | | | | WhiteSpace 525..526 -| | | | | | | WhiteSpace 525..526 " " -| | | | | Identifier 526..527 -| | | | | | Identifier 526..527 "i" -| | | | | WhiteSpace 527..528 -| | | | | | WhiteSpace 527..528 -| | | | | | | WhiteSpace 527..528 " " -| | | | | Assign 528..529 -| | | | | | Assign 528..529 "=" -| | | | | WhiteSpace 529..530 -| | | | | | WhiteSpace 529..530 -| | | | | | | WhiteSpace 529..530 " " -| | | | | Expression 530..531 -| | | | | | Number 530..531 -| | | | | | | Number 530..531 -| | | | | | | | Number 530..531 "0" -| | | | Semicolon 531..532 -| | | | | Semicolon 531..532 ";" -| | | | WhiteSpace 532..533 -| | | | | WhiteSpace 532..533 -| | | | | | WhiteSpace 532..533 " " -| | | | Expression 533..540 -| | | | | LessThan 533..540 -| | | | | | Identifier 533..534 -| | | | | | | Identifier 533..534 -| | | | | | | | Identifier 533..534 "i" -| | | | | | WhiteSpace 534..535 -| | | | | | | WhiteSpace 534..535 -| | | | | | | | WhiteSpace 534..535 " " -| | | | | | LessThan 535..536 -| | | | | | | LessThan 535..536 "<" -| | | | | | WhiteSpace 536..537 -| | | | | | | WhiteSpace 536..537 -| | | | | | | | WhiteSpace 536..537 " " -| | | | | | Sub 537..540 -| | | | | | | Identifier 537..538 -| | | | | | | | Identifier 537..538 -| | | | | | | | | Identifier 537..538 "N" -| | | | | | | Sub 538..539 -| | | | | | | | Sub 538..539 "-" -| | | | | | | Number 539..540 -| | | | | | | | Number 539..540 -| | | | | | | | | Number 539..540 "1" -| | | | Semicolon 540..541 -| | | | | Semicolon 540..541 ";" -| | | | WhiteSpace 541..542 -| | | | | WhiteSpace 541..542 -| | | | | | WhiteSpace 541..542 " " -| | | | Error 542..543 -| | | | | Expression 542..543 -| | | | | | ComponentIdentifier 542..543 -| | | | | | | Identifier 542..543 -| | | | | | | | Identifier 542..543 "i" -| | | | Error 543..572 -| | | | | Error 543..572 -| | | | | | Error 543..572 "expect RParen but got UnitInc" -| | | | Error 572..575 -| | | | | Expression 572..575 -| | | | | | UnitInc 572..575 -| | | | | | | UnitInc 572..574 -| | | | | | | | UnitInc 572..574 "++" -| | | | | | | Error 574..575 -| | | | | | | | RParen 574..575 -| | | | | | | | | RParen 574..575 ")" -| | | | Error 575..606 -| | | | | Error 575..606 -| | | | | | Error 575..606 "expect Semicolon but got LCurly" -| | Statement 606..694 -| | | Block 606..694 -| | | | LCurly 606..607 -| | | | | LCurly 606..607 "{" -| | | | EndLine 607..608 -| | | | | EndLine 607..608 -| | | | | | EndLine 607..608 "\n" -| | | | WhiteSpace 608..624 -| | | | | WhiteSpace 608..624 -| | | | | | WhiteSpace 608..624 " " -| | | | StatementList 624..693 -| | | | | Statement 624..680 -| | | | | | AssignStatement 624..679 -| | | | | | | Expression 624..632 -| | | | | | | | ComponentIdentifier 624..628 -| | | | | | | | | Identifier 624..628 -| | | | | | | | | | Identifier 624..628 "comp" -| | | | | | | | LBracket 628..629 -| | | | | | | | | LBracket 628..629 "[" -| | | | | | | | Expression 629..630 -| | | | | | | | | Identifier 629..630 -| | | | | | | | | | Identifier 629..630 -| | | | | | | | | | | Identifier 629..630 "i" -| | | | | | | | RBracket 630..631 -| | | | | | | | | RBracket 630..631 "]" -| | | | | | | | WhiteSpace 631..632 -| | | | | | | | | WhiteSpace 631..632 -| | | | | | | | | | WhiteSpace 631..632 " " -| | | | | | | Assign 632..633 -| | | | | | | | Assign 632..633 "=" -| | | | | | | WhiteSpace 633..634 -| | | | | | | | WhiteSpace 633..634 -| | | | | | | | | WhiteSpace 633..634 " " -| | | | | | | Expression 634..679 -| | | | | | | | Call 634..679 -| | | | | | | | | Identifier 634..645 -| | | | | | | | | | Identifier 634..645 -| | | | | | | | | | | Identifier 634..645 "Multiplier2" -| | | | | | | | | Tuple 645..679 -| | | | | | | | | | LParen 645..646 -| | | | | | | | | | | LParen 645..646 "(" -| | | | | | | | | | Error 646..678 -| | | | | | | | | | | Error 646..678 -| | | | | | | | | | | | Error 646..678 "expect Identifier but got RParen" -| | | | | | | | | | RParen 678..679 -| | | | | | | | | | | RParen 678..679 ")" -| | | | | | Semicolon 679..680 -| | | | | | | Semicolon 679..680 ";" -| | | | | EndLine 680..681 -| | | | | | EndLine 680..681 -| | | | | | | EndLine 680..681 "\n" -| | | | | WhiteSpace 681..693 -| | | | | | WhiteSpace 681..693 -| | | | | | | WhiteSpace 681..693 " " -| | | | RCurly 693..694 -| | | | | RCurly 693..694 "}" -| | EndLine 694..695 -| | | EndLine 694..695 -| | | | EndLine 694..695 "\n" -| | WhiteSpace 695..707 -| | | WhiteSpace 695..707 -| | | | WhiteSpace 695..707 " " -| | Statement 707..729 -| | | AssignStatement 707..728 -| | | | ComponentCall 707..718 -| | | | | ComponentIdentifier 707..711 -| | | | | | Identifier 707..711 -| | | | | | | Identifier 707..711 "comp" -| | | | | LBracket 711..712 -| | | | | | LBracket 711..712 "[" -| | | | | Expression 712..713 -| | | | | | Number 712..713 -| | | | | | | Number 712..713 -| | | | | | | | Number 712..713 "0" -| | | | | RBracket 713..714 -| | | | | | RBracket 713..714 "]" -| | | | | Dot 714..715 -| | | | | | Dot 714..715 "." -| | | | | Identifier 715..718 -| | | | | | Identifier 715..718 "in1" -| | | | WhiteSpace 718..719 -| | | | | WhiteSpace 718..719 -| | | | | | WhiteSpace 718..719 " " -| | | | RAssignConstraintSignal 719..722 -| | | | | RAssignConstraintSignal 719..722 "<==" -| | | | WhiteSpace 722..723 -| | | | | WhiteSpace 722..723 -| | | | | | WhiteSpace 722..723 " " -| | | | Expression 723..728 -| | | | | ArrayQuery 723..728 -| | | | | | Identifier 723..725 -| | | | | | | Identifier 723..725 -| | | | | | | | Identifier 723..725 "in" -| | | | | | LBracket 725..726 -| | | | | | | LBracket 725..726 "[" -| | | | | | Number 726..727 -| | | | | | | Number 726..727 -| | | | | | | | Number 726..727 "0" -| | | | | | RBracket 727..728 -| | | | | | | RBracket 727..728 "]" -| | | Semicolon 728..729 -| | | | Semicolon 728..729 ";" -| | EndLine 729..730 -| | | EndLine 729..730 -| | | | EndLine 729..730 "\n" -| | WhiteSpace 730..742 -| | | WhiteSpace 730..742 -| | | | WhiteSpace 730..742 " " -| | Statement 742..764 -| | | AssignStatement 742..763 -| | | | ComponentCall 742..753 -| | | | | ComponentIdentifier 742..746 -| | | | | | Identifier 742..746 -| | | | | | | Identifier 742..746 "comp" -| | | | | LBracket 746..747 -| | | | | | LBracket 746..747 "[" -| | | | | Expression 747..748 -| | | | | | Number 747..748 -| | | | | | | Number 747..748 -| | | | | | | | Number 747..748 "0" -| | | | | RBracket 748..749 -| | | | | | RBracket 748..749 "]" -| | | | | Dot 749..750 -| | | | | | Dot 749..750 "." -| | | | | Identifier 750..753 -| | | | | | Identifier 750..753 "in2" -| | | | WhiteSpace 753..754 -| | | | | WhiteSpace 753..754 -| | | | | | WhiteSpace 753..754 " " -| | | | RAssignConstraintSignal 754..757 -| | | | | RAssignConstraintSignal 754..757 "<==" -| | | | WhiteSpace 757..758 -| | | | | WhiteSpace 757..758 -| | | | | | WhiteSpace 757..758 " " -| | | | Expression 758..763 -| | | | | ArrayQuery 758..763 -| | | | | | Identifier 758..760 -| | | | | | | Identifier 758..760 -| | | | | | | | Identifier 758..760 "in" -| | | | | | LBracket 760..761 -| | | | | | | LBracket 760..761 "[" -| | | | | | Number 761..762 -| | | | | | | Number 761..762 -| | | | | | | | Number 761..762 "1" -| | | | | | RBracket 762..763 -| | | | | | | RBracket 762..763 "]" -| | | Semicolon 763..764 -| | | | Semicolon 763..764 ";" -| | EndLine 764..765 -| | | EndLine 764..765 -| | | | EndLine 764..765 "\n" -| | WhiteSpace 765..777 -| | | WhiteSpace 765..777 -| | | | WhiteSpace 765..777 " " -| | Statement 777..865 -| | | ForLoop 777..865 -| | | | ForKw 777..780 -| | | | | ForKw 777..780 "for" -| | | | LParen 780..781 -| | | | | LParen 780..781 "(" -| | | | VarDecl 781..790 -| | | | | VarKw 781..784 -| | | | | | VarKw 781..784 "var" -| | | | | WhiteSpace 784..785 -| | | | | | WhiteSpace 784..785 -| | | | | | | WhiteSpace 784..785 " " -| | | | | Identifier 785..786 -| | | | | | Identifier 785..786 "i" -| | | | | WhiteSpace 786..787 -| | | | | | WhiteSpace 786..787 -| | | | | | | WhiteSpace 786..787 " " -| | | | | Assign 787..788 -| | | | | | Assign 787..788 "=" -| | | | | WhiteSpace 788..789 -| | | | | | WhiteSpace 788..789 -| | | | | | | WhiteSpace 788..789 " " -| | | | | Expression 789..790 -| | | | | | Number 789..790 -| | | | | | | Number 789..790 -| | | | | | | | Number 789..790 "0" -| | | | Semicolon 790..791 -| | | | | Semicolon 790..791 ";" -| | | | WhiteSpace 791..792 -| | | | | WhiteSpace 791..792 -| | | | | | WhiteSpace 791..792 " " -| | | | Expression 792..799 -| | | | | LessThan 792..799 -| | | | | | Identifier 792..793 -| | | | | | | Identifier 792..793 -| | | | | | | | Identifier 792..793 "i" -| | | | | | WhiteSpace 793..794 -| | | | | | | WhiteSpace 793..794 -| | | | | | | | WhiteSpace 793..794 " " -| | | | | | LessThan 794..795 -| | | | | | | LessThan 794..795 "<" -| | | | | | WhiteSpace 795..796 -| | | | | | | WhiteSpace 795..796 -| | | | | | | | WhiteSpace 795..796 " " -| | | | | | Sub 796..799 -| | | | | | | Identifier 796..797 -| | | | | | | | Identifier 796..797 -| | | | | | | | | Identifier 796..797 "N" -| | | | | | | Sub 797..798 -| | | | | | | | Sub 797..798 "-" -| | | | | | | Number 798..799 -| | | | | | | | Number 798..799 -| | | | | | | | | Number 798..799 "2" -| | | | Semicolon 799..800 -| | | | | Semicolon 799..800 ";" -| | | | WhiteSpace 800..801 -| | | | | WhiteSpace 800..801 -| | | | | | WhiteSpace 800..801 " " -| | | | Error 801..802 -| | | | | Expression 801..802 -| | | | | | ComponentIdentifier 801..802 -| | | | | | | Identifier 801..802 -| | | | | | | | Identifier 801..802 "i" -| | | | Error 802..831 -| | | | | Error 802..831 -| | | | | | Error 802..831 "expect RParen but got UnitInc" -| | | | Error 831..834 -| | | | | Expression 831..834 -| | | | | | UnitInc 831..834 -| | | | | | | UnitInc 831..833 -| | | | | | | | UnitInc 831..833 "++" -| | | | | | | Error 833..834 -| | | | | | | | RParen 833..834 -| | | | | | | | | RParen 833..834 ")" -| | | | Error 834..865 -| | | | | Error 834..865 -| | | | | | Error 834..865 "expect Semicolon but got LCurly" -| | Statement 865..971 -| | | Block 865..971 -| | | | LCurly 865..866 -| | | | | LCurly 865..866 "{" -| | | | EndLine 866..867 -| | | | | EndLine 866..867 -| | | | | | EndLine 866..867 "\n" -| | | | WhiteSpace 867..883 -| | | | | WhiteSpace 867..883 -| | | | | | WhiteSpace 867..883 " " -| | | | StatementList 883..970 -| | | | | Statement 883..913 -| | | | | | AssignStatement 883..912 -| | | | | | | ComponentCall 883..896 -| | | | | | | | ComponentIdentifier 883..887 -| | | | | | | | | Identifier 883..887 -| | | | | | | | | | Identifier 883..887 "comp" -| | | | | | | | LBracket 887..888 -| | | | | | | | | LBracket 887..888 "[" -| | | | | | | | Expression 888..891 -| | | | | | | | | Add 888..891 -| | | | | | | | | | Identifier 888..889 -| | | | | | | | | | | Identifier 888..889 -| | | | | | | | | | | | Identifier 888..889 "i" -| | | | | | | | | | Add 889..890 -| | | | | | | | | | | Add 889..890 "+" -| | | | | | | | | | Number 890..891 -| | | | | | | | | | | Number 890..891 -| | | | | | | | | | | | Number 890..891 "1" -| | | | | | | | RBracket 891..892 -| | | | | | | | | RBracket 891..892 "]" -| | | | | | | | Dot 892..893 -| | | | | | | | | Dot 892..893 "." -| | | | | | | | Identifier 893..896 -| | | | | | | | | Identifier 893..896 "in1" -| | | | | | | WhiteSpace 896..897 -| | | | | | | | WhiteSpace 896..897 -| | | | | | | | | WhiteSpace 896..897 " " -| | | | | | | RAssignConstraintSignal 897..900 -| | | | | | | | RAssignConstraintSignal 897..900 "<==" -| | | | | | | WhiteSpace 900..901 -| | | | | | | | WhiteSpace 900..901 -| | | | | | | | | WhiteSpace 900..901 " " -| | | | | | | Expression 901..912 -| | | | | | | | ComponentCall 901..912 -| | | | | | | | | ArrayQuery 901..908 -| | | | | | | | | | Identifier 901..905 -| | | | | | | | | | | Identifier 901..905 -| | | | | | | | | | | | Identifier 901..905 "comp" -| | | | | | | | | | LBracket 905..906 -| | | | | | | | | | | LBracket 905..906 "[" -| | | | | | | | | | Identifier 906..907 -| | | | | | | | | | | Identifier 906..907 -| | | | | | | | | | | | Identifier 906..907 "i" -| | | | | | | | | | RBracket 907..908 -| | | | | | | | | | | RBracket 907..908 "]" -| | | | | | | | | Dot 908..909 -| | | | | | | | | | Dot 908..909 "." -| | | | | | | | | Identifier 909..912 -| | | | | | | | | | Identifier 909..912 "out" -| | | | | | Semicolon 912..913 -| | | | | | | Semicolon 912..913 ";" -| | | | | EndLine 913..914 -| | | | | | EndLine 913..914 -| | | | | | | EndLine 913..914 "\n" -| | | | | WhiteSpace 914..930 -| | | | | | WhiteSpace 914..930 -| | | | | | | WhiteSpace 914..930 " " -| | | | | Statement 930..956 -| | | | | | AssignStatement 930..955 -| | | | | | | ComponentCall 930..943 -| | | | | | | | ComponentIdentifier 930..934 -| | | | | | | | | Identifier 930..934 -| | | | | | | | | | Identifier 930..934 "comp" -| | | | | | | | LBracket 934..935 -| | | | | | | | | LBracket 934..935 "[" -| | | | | | | | Expression 935..938 -| | | | | | | | | Add 935..938 -| | | | | | | | | | Identifier 935..936 -| | | | | | | | | | | Identifier 935..936 -| | | | | | | | | | | | Identifier 935..936 "i" -| | | | | | | | | | Add 936..937 -| | | | | | | | | | | Add 936..937 "+" -| | | | | | | | | | Number 937..938 -| | | | | | | | | | | Number 937..938 -| | | | | | | | | | | | Number 937..938 "1" -| | | | | | | | RBracket 938..939 -| | | | | | | | | RBracket 938..939 "]" -| | | | | | | | Dot 939..940 -| | | | | | | | | Dot 939..940 "." -| | | | | | | | Identifier 940..943 -| | | | | | | | | Identifier 940..943 "in2" -| | | | | | | WhiteSpace 943..944 -| | | | | | | | WhiteSpace 943..944 -| | | | | | | | | WhiteSpace 943..944 " " -| | | | | | | RAssignConstraintSignal 944..947 -| | | | | | | | RAssignConstraintSignal 944..947 "<==" -| | | | | | | WhiteSpace 947..948 -| | | | | | | | WhiteSpace 947..948 -| | | | | | | | | WhiteSpace 947..948 " " -| | | | | | | Expression 948..955 -| | | | | | | | ArrayQuery 948..955 -| | | | | | | | | Identifier 948..950 -| | | | | | | | | | Identifier 948..950 -| | | | | | | | | | | Identifier 948..950 "in" -| | | | | | | | | LBracket 950..951 -| | | | | | | | | | LBracket 950..951 "[" -| | | | | | | | | Add 951..954 -| | | | | | | | | | Identifier 951..952 -| | | | | | | | | | | Identifier 951..952 -| | | | | | | | | | | | Identifier 951..952 "i" -| | | | | | | | | | Add 952..953 -| | | | | | | | | | | Add 952..953 "+" -| | | | | | | | | | Number 953..954 -| | | | | | | | | | | Number 953..954 -| | | | | | | | | | | | Number 953..954 "2" -| | | | | | | | | RBracket 954..955 -| | | | | | | | | | RBracket 954..955 "]" -| | | | | | Semicolon 955..956 -| | | | | | | Semicolon 955..956 ";" -| | | | | EndLine 956..957 -| | | | | | EndLine 956..957 -| | | | | | | EndLine 956..957 "\n" -| | | | | EndLine 957..958 -| | | | | | EndLine 957..958 -| | | | | | | EndLine 957..958 "\n" -| | | | | WhiteSpace 958..970 -| | | | | | WhiteSpace 958..970 -| | | | | | | WhiteSpace 958..970 " " -| | | | RCurly 970..971 -| | | | | RCurly 970..971 "}" -| | EndLine 971..972 -| | | EndLine 971..972 -| | | | EndLine 971..972 "\n" -| | WhiteSpace 972..984 -| | | WhiteSpace 972..984 -| | | | WhiteSpace 972..984 " " -| | Statement 984..1006 -| | | AssignStatement 984..1005 -| | | | Expression 984..988 -| | | | | ComponentIdentifier 984..987 -| | | | | | Identifier 984..987 -| | | | | | | Identifier 984..987 "out" -| | | | | WhiteSpace 987..988 -| | | | | | WhiteSpace 987..988 -| | | | | | | WhiteSpace 987..988 " " -| | | | RAssignConstraintSignal 988..991 -| | | | | RAssignConstraintSignal 988..991 "<==" -| | | | WhiteSpace 991..992 -| | | | | WhiteSpace 991..992 -| | | | | | WhiteSpace 991..992 " " -| | | | Expression 992..1005 -| | | | | ComponentCall 992..1005 -| | | | | | ArrayQuery 992..1001 -| | | | | | | Identifier 992..996 -| | | | | | | | Identifier 992..996 -| | | | | | | | | Identifier 992..996 "comp" -| | | | | | | LBracket 996..997 -| | | | | | | | LBracket 996..997 "[" -| | | | | | | Sub 997..1000 -| | | | | | | | Identifier 997..998 -| | | | | | | | | Identifier 997..998 -| | | | | | | | | | Identifier 997..998 "N" -| | | | | | | | Sub 998..999 -| | | | | | | | | Sub 998..999 "-" -| | | | | | | | Number 999..1000 -| | | | | | | | | Number 999..1000 -| | | | | | | | | | Number 999..1000 "2" -| | | | | | | RBracket 1000..1001 -| | | | | | | | RBracket 1000..1001 "]" -| | | | | | Dot 1001..1002 -| | | | | | | Dot 1001..1002 "." -| | | | | | Identifier 1002..1005 -| | | | | | | Identifier 1002..1005 "out" -| | | Semicolon 1005..1006 -| | | | Semicolon 1005..1006 ";" -| | WhiteSpace 1006..1007 -| | | WhiteSpace 1006..1007 -| | | | WhiteSpace 1006..1007 " " -| | EndLine 1007..1008 -| | | EndLine 1007..1008 -| | | | EndLine 1007..1008 "\n" -| | WhiteSpace 1008..1020 -| | | WhiteSpace 1008..1020 -| | | | WhiteSpace 1008..1020 " " -| RCurly 1020..1021 -| | RCurly 1020..1021 "}" +| EndLine 1..3 +| | EndLine 1..3 "\r\n" +| WhiteSpace 3..4 +| | WhiteSpace 3..4 " " +| CommentLine 4..29 +| | CommentLine 4..29 "//Declaration of signals." +| EndLine 29..31 +| | EndLine 29..31 "\r\n" +| WhiteSpace 31..43 +| | WhiteSpace 31..43 " " +| StatementList 43..532 +| | InputSignalDecl 43..61 +| | | SignalHeader 43..56 +| | | | SignalKw 43..49 +| | | | | SignalKw 43..49 "signal" +| | | | WhiteSpace 49..50 +| | | | | WhiteSpace 49..50 " " +| | | | InputKw 50..55 +| | | | | InputKw 50..55 "input" +| | | | WhiteSpace 55..56 +| | | | | WhiteSpace 55..56 " " +| | | SignalIdentifier 56..61 +| | | | Identifier 56..58 +| | | | | Identifier 56..58 "in" +| | | | LBracket 58..59 +| | | | | LBracket 58..59 "[" +| | | | Expression 59..60 +| | | | | ExpressionAtom 59..60 +| | | | | | Identifier 59..60 +| | | | | | | Identifier 59..60 "N" +| | | | RBracket 60..61 +| | | | | RBracket 60..61 "]" +| | Semicolon 61..62 +| | | Semicolon 61..62 ";" +| | EndLine 62..64 +| | | EndLine 62..64 "\r\n" +| | WhiteSpace 64..76 +| | | WhiteSpace 64..76 " " +| | OutputSignalDecl 76..93 +| | | SignalHeader 76..90 +| | | | SignalKw 76..82 +| | | | | SignalKw 76..82 "signal" +| | | | WhiteSpace 82..83 +| | | | | WhiteSpace 82..83 " " +| | | | OutputKw 83..89 +| | | | | OutputKw 83..89 "output" +| | | | WhiteSpace 89..90 +| | | | | WhiteSpace 89..90 " " +| | | SignalIdentifier 90..93 +| | | | Identifier 90..93 +| | | | | Identifier 90..93 "out" +| | Semicolon 93..94 +| | | Semicolon 93..94 ";" +| | EndLine 94..96 +| | | EndLine 94..96 "\r\n" +| | WhiteSpace 96..108 +| | | WhiteSpace 96..108 " " +| | ComponentDecl 108..127 +| | | ComponentKw 108..117 +| | | | ComponentKw 108..117 "component" +| | | WhiteSpace 117..118 +| | | | WhiteSpace 117..118 " " +| | | ComponentIdentifier 118..127 +| | | | Identifier 118..122 +| | | | | Identifier 118..122 "comp" +| | | | LBracket 122..123 +| | | | | LBracket 122..123 "[" +| | | | Expression 123..126 +| | | | | Sub 123..126 +| | | | | | ExpressionAtom 123..124 +| | | | | | | Identifier 123..124 +| | | | | | | | Identifier 123..124 "N" +| | | | | | Sub 124..125 +| | | | | | | Sub 124..125 "-" +| | | | | | ExpressionAtom 125..126 +| | | | | | | Number 125..126 +| | | | | | | | Number 125..126 "1" +| | | | RBracket 126..127 +| | | | | RBracket 126..127 "]" +| | Semicolon 127..128 +| | | Semicolon 127..128 ";" +| | EndLine 128..130 +| | | EndLine 128..130 "\r\n" +| | EndLine 130..132 +| | | EndLine 130..132 "\r\n" +| | WhiteSpace 132..144 +| | | WhiteSpace 132..144 " " +| | CommentLine 144..157 +| | | CommentLine 144..157 "//Statements." +| | EndLine 157..159 +| | | EndLine 157..159 "\r\n" +| | WhiteSpace 159..171 +| | | WhiteSpace 159..171 " " +| | Statement 171..257 +| | | ForLoop 171..257 +| | | | ForKw 171..174 +| | | | | ForKw 171..174 "for" +| | | | LParen 174..175 +| | | | | LParen 174..175 "(" +| | | | VarDecl 175..184 +| | | | | VarKw 175..178 +| | | | | | VarKw 175..178 "var" +| | | | | WhiteSpace 178..179 +| | | | | | WhiteSpace 178..179 " " +| | | | | VarIdentifier 179..181 +| | | | | | Identifier 179..180 +| | | | | | | Identifier 179..180 "i" +| | | | | | WhiteSpace 180..181 +| | | | | | | WhiteSpace 180..181 " " +| | | | | Assign 181..182 +| | | | | | Assign 181..182 "=" +| | | | | WhiteSpace 182..183 +| | | | | | WhiteSpace 182..183 " " +| | | | | Expression 183..184 +| | | | | | ExpressionAtom 183..184 +| | | | | | | Number 183..184 +| | | | | | | | Number 183..184 "0" +| | | | Semicolon 184..185 +| | | | | Semicolon 184..185 ";" +| | | | WhiteSpace 185..186 +| | | | | WhiteSpace 185..186 " " +| | | | Expression 186..193 +| | | | | LessThan 186..193 +| | | | | | ExpressionAtom 186..187 +| | | | | | | Identifier 186..187 +| | | | | | | | Identifier 186..187 "i" +| | | | | | WhiteSpace 187..188 +| | | | | | | WhiteSpace 187..188 " " +| | | | | | LessThan 188..189 +| | | | | | | LessThan 188..189 "<" +| | | | | | WhiteSpace 189..190 +| | | | | | | WhiteSpace 189..190 " " +| | | | | | Sub 190..193 +| | | | | | | ExpressionAtom 190..191 +| | | | | | | | Identifier 190..191 +| | | | | | | | | Identifier 190..191 "N" +| | | | | | | Sub 191..192 +| | | | | | | | Sub 191..192 "-" +| | | | | | | ExpressionAtom 192..193 +| | | | | | | | Number 192..193 +| | | | | | | | | Number 192..193 "1" +| | | | Semicolon 193..194 +| | | | | Semicolon 193..194 ";" +| | | | WhiteSpace 194..195 +| | | | | WhiteSpace 194..195 " " +| | | | AssignStatement 195..198 +| | | | | Expression 195..196 +| | | | | | ComponentIdentifier 195..196 +| | | | | | | Identifier 195..196 +| | | | | | | | Identifier 195..196 "i" +| | | | | UnitInc 196..198 +| | | | | | UnitInc 196..198 "++" +| | | | RParen 198..199 +| | | | | RParen 198..199 ")" +| | | | Statement 199..257 +| | | | | Block 199..257 +| | | | | | LCurly 199..200 +| | | | | | | LCurly 199..200 "{" +| | | | | | EndLine 200..202 +| | | | | | | EndLine 200..202 "\r\n" +| | | | | | WhiteSpace 202..218 +| | | | | | | WhiteSpace 202..218 " " +| | | | | | StatementList 218..256 +| | | | | | | Statement 218..242 +| | | | | | | | AssignStatement 218..241 +| | | | | | | | | Expression 218..226 +| | | | | | | | | | ComponentIdentifier 218..222 +| | | | | | | | | | | Identifier 218..222 +| | | | | | | | | | | | Identifier 218..222 "comp" +| | | | | | | | | | LBracket 222..223 +| | | | | | | | | | | LBracket 222..223 "[" +| | | | | | | | | | Expression 223..224 +| | | | | | | | | | | ExpressionAtom 223..224 +| | | | | | | | | | | | Identifier 223..224 +| | | | | | | | | | | | | Identifier 223..224 "i" +| | | | | | | | | | RBracket 224..225 +| | | | | | | | | | | RBracket 224..225 "]" +| | | | | | | | | | WhiteSpace 225..226 +| | | | | | | | | | | WhiteSpace 225..226 " " +| | | | | | | | | Assign 226..227 +| | | | | | | | | | Assign 226..227 "=" +| | | | | | | | | WhiteSpace 227..228 +| | | | | | | | | | WhiteSpace 227..228 " " +| | | | | | | | | Expression 228..241 +| | | | | | | | | | Call 228..241 +| | | | | | | | | | | ExpressionAtom 228..239 +| | | | | | | | | | | | Identifier 228..239 +| | | | | | | | | | | | | Identifier 228..239 "Multiplier2" +| | | | | | | | | | | Tuple 239..241 +| | | | | | | | | | | | LParen 239..240 +| | | | | | | | | | | | | LParen 239..240 "(" +| | | | | | | | | | | | RParen 240..241 +| | | | | | | | | | | | | RParen 240..241 ")" +| | | | | | | | Semicolon 241..242 +| | | | | | | | | Semicolon 241..242 ";" +| | | | | | | EndLine 242..244 +| | | | | | | | EndLine 242..244 "\r\n" +| | | | | | | WhiteSpace 244..256 +| | | | | | | | WhiteSpace 244..256 " " +| | | | | | RCurly 256..257 +| | | | | | | RCurly 256..257 "}" +| | EndLine 257..259 +| | | EndLine 257..259 "\r\n" +| | WhiteSpace 259..271 +| | | WhiteSpace 259..271 " " +| | Statement 271..293 +| | | AssignStatement 271..292 +| | | | ComponentCall 271..282 +| | | | | ComponentIdentifier 271..275 +| | | | | | Identifier 271..275 +| | | | | | | Identifier 271..275 "comp" +| | | | | LBracket 275..276 +| | | | | | LBracket 275..276 "[" +| | | | | Expression 276..277 +| | | | | | ExpressionAtom 276..277 +| | | | | | | Number 276..277 +| | | | | | | | Number 276..277 "0" +| | | | | RBracket 277..278 +| | | | | | RBracket 277..278 "]" +| | | | | Dot 278..279 +| | | | | | Dot 278..279 "." +| | | | | Identifier 279..282 +| | | | | | Identifier 279..282 "in1" +| | | | WhiteSpace 282..283 +| | | | | WhiteSpace 282..283 " " +| | | | RAssignConstraintSignal 283..286 +| | | | | RAssignConstraintSignal 283..286 "<==" +| | | | WhiteSpace 286..287 +| | | | | WhiteSpace 286..287 " " +| | | | Expression 287..292 +| | | | | ArrayQuery 287..292 +| | | | | | ExpressionAtom 287..289 +| | | | | | | Identifier 287..289 +| | | | | | | | Identifier 287..289 "in" +| | | | | | LBracket 289..290 +| | | | | | | LBracket 289..290 "[" +| | | | | | ExpressionAtom 290..291 +| | | | | | | Number 290..291 +| | | | | | | | Number 290..291 "0" +| | | | | | RBracket 291..292 +| | | | | | | RBracket 291..292 "]" +| | | Semicolon 292..293 +| | | | Semicolon 292..293 ";" +| | EndLine 293..295 +| | | EndLine 293..295 "\r\n" +| | WhiteSpace 295..307 +| | | WhiteSpace 295..307 " " +| | Statement 307..329 +| | | AssignStatement 307..328 +| | | | ComponentCall 307..318 +| | | | | ComponentIdentifier 307..311 +| | | | | | Identifier 307..311 +| | | | | | | Identifier 307..311 "comp" +| | | | | LBracket 311..312 +| | | | | | LBracket 311..312 "[" +| | | | | Expression 312..313 +| | | | | | ExpressionAtom 312..313 +| | | | | | | Number 312..313 +| | | | | | | | Number 312..313 "0" +| | | | | RBracket 313..314 +| | | | | | RBracket 313..314 "]" +| | | | | Dot 314..315 +| | | | | | Dot 314..315 "." +| | | | | Identifier 315..318 +| | | | | | Identifier 315..318 "in2" +| | | | WhiteSpace 318..319 +| | | | | WhiteSpace 318..319 " " +| | | | RAssignConstraintSignal 319..322 +| | | | | RAssignConstraintSignal 319..322 "<==" +| | | | WhiteSpace 322..323 +| | | | | WhiteSpace 322..323 " " +| | | | Expression 323..328 +| | | | | ArrayQuery 323..328 +| | | | | | ExpressionAtom 323..325 +| | | | | | | Identifier 323..325 +| | | | | | | | Identifier 323..325 "in" +| | | | | | LBracket 325..326 +| | | | | | | LBracket 325..326 "[" +| | | | | | ExpressionAtom 326..327 +| | | | | | | Number 326..327 +| | | | | | | | Number 326..327 "1" +| | | | | | RBracket 327..328 +| | | | | | | RBracket 327..328 "]" +| | | Semicolon 328..329 +| | | | Semicolon 328..329 ";" +| | EndLine 329..331 +| | | EndLine 329..331 "\r\n" +| | WhiteSpace 331..343 +| | | WhiteSpace 331..343 " " +| | Statement 343..481 +| | | ForLoop 343..481 +| | | | ForKw 343..346 +| | | | | ForKw 343..346 "for" +| | | | LParen 346..347 +| | | | | LParen 346..347 "(" +| | | | VarDecl 347..356 +| | | | | VarKw 347..350 +| | | | | | VarKw 347..350 "var" +| | | | | WhiteSpace 350..351 +| | | | | | WhiteSpace 350..351 " " +| | | | | VarIdentifier 351..353 +| | | | | | Identifier 351..352 +| | | | | | | Identifier 351..352 "i" +| | | | | | WhiteSpace 352..353 +| | | | | | | WhiteSpace 352..353 " " +| | | | | Assign 353..354 +| | | | | | Assign 353..354 "=" +| | | | | WhiteSpace 354..355 +| | | | | | WhiteSpace 354..355 " " +| | | | | Expression 355..356 +| | | | | | ExpressionAtom 355..356 +| | | | | | | Number 355..356 +| | | | | | | | Number 355..356 "0" +| | | | Semicolon 356..357 +| | | | | Semicolon 356..357 ";" +| | | | WhiteSpace 357..358 +| | | | | WhiteSpace 357..358 " " +| | | | Expression 358..365 +| | | | | LessThan 358..365 +| | | | | | ExpressionAtom 358..359 +| | | | | | | Identifier 358..359 +| | | | | | | | Identifier 358..359 "i" +| | | | | | WhiteSpace 359..360 +| | | | | | | WhiteSpace 359..360 " " +| | | | | | LessThan 360..361 +| | | | | | | LessThan 360..361 "<" +| | | | | | WhiteSpace 361..362 +| | | | | | | WhiteSpace 361..362 " " +| | | | | | Sub 362..365 +| | | | | | | ExpressionAtom 362..363 +| | | | | | | | Identifier 362..363 +| | | | | | | | | Identifier 362..363 "N" +| | | | | | | Sub 363..364 +| | | | | | | | Sub 363..364 "-" +| | | | | | | ExpressionAtom 364..365 +| | | | | | | | Number 364..365 +| | | | | | | | | Number 364..365 "2" +| | | | Semicolon 365..366 +| | | | | Semicolon 365..366 ";" +| | | | WhiteSpace 366..367 +| | | | | WhiteSpace 366..367 " " +| | | | AssignStatement 367..370 +| | | | | Expression 367..368 +| | | | | | ComponentIdentifier 367..368 +| | | | | | | Identifier 367..368 +| | | | | | | | Identifier 367..368 "i" +| | | | | UnitInc 368..370 +| | | | | | UnitInc 368..370 "++" +| | | | RParen 370..371 +| | | | | RParen 370..371 ")" +| | | | Statement 371..481 +| | | | | Block 371..481 +| | | | | | LCurly 371..372 +| | | | | | | LCurly 371..372 "{" +| | | | | | EndLine 372..374 +| | | | | | | EndLine 372..374 "\r\n" +| | | | | | WhiteSpace 374..390 +| | | | | | | WhiteSpace 374..390 " " +| | | | | | StatementList 390..480 +| | | | | | | Statement 390..420 +| | | | | | | | AssignStatement 390..419 +| | | | | | | | | ComponentCall 390..403 +| | | | | | | | | | ComponentIdentifier 390..394 +| | | | | | | | | | | Identifier 390..394 +| | | | | | | | | | | | Identifier 390..394 "comp" +| | | | | | | | | | LBracket 394..395 +| | | | | | | | | | | LBracket 394..395 "[" +| | | | | | | | | | Expression 395..398 +| | | | | | | | | | | Add 395..398 +| | | | | | | | | | | | ExpressionAtom 395..396 +| | | | | | | | | | | | | Identifier 395..396 +| | | | | | | | | | | | | | Identifier 395..396 "i" +| | | | | | | | | | | | Add 396..397 +| | | | | | | | | | | | | Add 396..397 "+" +| | | | | | | | | | | | ExpressionAtom 397..398 +| | | | | | | | | | | | | Number 397..398 +| | | | | | | | | | | | | | Number 397..398 "1" +| | | | | | | | | | RBracket 398..399 +| | | | | | | | | | | RBracket 398..399 "]" +| | | | | | | | | | Dot 399..400 +| | | | | | | | | | | Dot 399..400 "." +| | | | | | | | | | Identifier 400..403 +| | | | | | | | | | | Identifier 400..403 "in1" +| | | | | | | | | WhiteSpace 403..404 +| | | | | | | | | | WhiteSpace 403..404 " " +| | | | | | | | | RAssignConstraintSignal 404..407 +| | | | | | | | | | RAssignConstraintSignal 404..407 "<==" +| | | | | | | | | WhiteSpace 407..408 +| | | | | | | | | | WhiteSpace 407..408 " " +| | | | | | | | | Expression 408..419 +| | | | | | | | | | ComponentCall 408..419 +| | | | | | | | | | | ArrayQuery 408..415 +| | | | | | | | | | | | ExpressionAtom 408..412 +| | | | | | | | | | | | | Identifier 408..412 +| | | | | | | | | | | | | | Identifier 408..412 "comp" +| | | | | | | | | | | | LBracket 412..413 +| | | | | | | | | | | | | LBracket 412..413 "[" +| | | | | | | | | | | | ExpressionAtom 413..414 +| | | | | | | | | | | | | Identifier 413..414 +| | | | | | | | | | | | | | Identifier 413..414 "i" +| | | | | | | | | | | | RBracket 414..415 +| | | | | | | | | | | | | RBracket 414..415 "]" +| | | | | | | | | | | Dot 415..416 +| | | | | | | | | | | | Dot 415..416 "." +| | | | | | | | | | | Identifier 416..419 +| | | | | | | | | | | | Identifier 416..419 "out" +| | | | | | | | Semicolon 419..420 +| | | | | | | | | Semicolon 419..420 ";" +| | | | | | | EndLine 420..422 +| | | | | | | | EndLine 420..422 "\r\n" +| | | | | | | WhiteSpace 422..438 +| | | | | | | | WhiteSpace 422..438 " " +| | | | | | | Statement 438..464 +| | | | | | | | AssignStatement 438..463 +| | | | | | | | | ComponentCall 438..451 +| | | | | | | | | | ComponentIdentifier 438..442 +| | | | | | | | | | | Identifier 438..442 +| | | | | | | | | | | | Identifier 438..442 "comp" +| | | | | | | | | | LBracket 442..443 +| | | | | | | | | | | LBracket 442..443 "[" +| | | | | | | | | | Expression 443..446 +| | | | | | | | | | | Add 443..446 +| | | | | | | | | | | | ExpressionAtom 443..444 +| | | | | | | | | | | | | Identifier 443..444 +| | | | | | | | | | | | | | Identifier 443..444 "i" +| | | | | | | | | | | | Add 444..445 +| | | | | | | | | | | | | Add 444..445 "+" +| | | | | | | | | | | | ExpressionAtom 445..446 +| | | | | | | | | | | | | Number 445..446 +| | | | | | | | | | | | | | Number 445..446 "1" +| | | | | | | | | | RBracket 446..447 +| | | | | | | | | | | RBracket 446..447 "]" +| | | | | | | | | | Dot 447..448 +| | | | | | | | | | | Dot 447..448 "." +| | | | | | | | | | Identifier 448..451 +| | | | | | | | | | | Identifier 448..451 "in2" +| | | | | | | | | WhiteSpace 451..452 +| | | | | | | | | | WhiteSpace 451..452 " " +| | | | | | | | | RAssignConstraintSignal 452..455 +| | | | | | | | | | RAssignConstraintSignal 452..455 "<==" +| | | | | | | | | WhiteSpace 455..456 +| | | | | | | | | | WhiteSpace 455..456 " " +| | | | | | | | | Expression 456..463 +| | | | | | | | | | ArrayQuery 456..463 +| | | | | | | | | | | ExpressionAtom 456..458 +| | | | | | | | | | | | Identifier 456..458 +| | | | | | | | | | | | | Identifier 456..458 "in" +| | | | | | | | | | | LBracket 458..459 +| | | | | | | | | | | | LBracket 458..459 "[" +| | | | | | | | | | | Add 459..462 +| | | | | | | | | | | | ExpressionAtom 459..460 +| | | | | | | | | | | | | Identifier 459..460 +| | | | | | | | | | | | | | Identifier 459..460 "i" +| | | | | | | | | | | | Add 460..461 +| | | | | | | | | | | | | Add 460..461 "+" +| | | | | | | | | | | | ExpressionAtom 461..462 +| | | | | | | | | | | | | Number 461..462 +| | | | | | | | | | | | | | Number 461..462 "2" +| | | | | | | | | | | RBracket 462..463 +| | | | | | | | | | | | RBracket 462..463 "]" +| | | | | | | | Semicolon 463..464 +| | | | | | | | | Semicolon 463..464 ";" +| | | | | | | EndLine 464..466 +| | | | | | | | EndLine 464..466 "\r\n" +| | | | | | | EndLine 466..468 +| | | | | | | | EndLine 466..468 "\r\n" +| | | | | | | WhiteSpace 468..480 +| | | | | | | | WhiteSpace 468..480 " " +| | | | | | RCurly 480..481 +| | | | | | | RCurly 480..481 "}" +| | EndLine 481..483 +| | | EndLine 481..483 "\r\n" +| | WhiteSpace 483..495 +| | | WhiteSpace 483..495 " " +| | Statement 495..517 +| | | AssignStatement 495..516 +| | | | Expression 495..499 +| | | | | ComponentIdentifier 495..498 +| | | | | | Identifier 495..498 +| | | | | | | Identifier 495..498 "out" +| | | | | WhiteSpace 498..499 +| | | | | | WhiteSpace 498..499 " " +| | | | RAssignConstraintSignal 499..502 +| | | | | RAssignConstraintSignal 499..502 "<==" +| | | | WhiteSpace 502..503 +| | | | | WhiteSpace 502..503 " " +| | | | Expression 503..516 +| | | | | ComponentCall 503..516 +| | | | | | ArrayQuery 503..512 +| | | | | | | ExpressionAtom 503..507 +| | | | | | | | Identifier 503..507 +| | | | | | | | | Identifier 503..507 "comp" +| | | | | | | LBracket 507..508 +| | | | | | | | LBracket 507..508 "[" +| | | | | | | Sub 508..511 +| | | | | | | | ExpressionAtom 508..509 +| | | | | | | | | Identifier 508..509 +| | | | | | | | | | Identifier 508..509 "N" +| | | | | | | | Sub 509..510 +| | | | | | | | | Sub 509..510 "-" +| | | | | | | | ExpressionAtom 510..511 +| | | | | | | | | Number 510..511 +| | | | | | | | | | Number 510..511 "2" +| | | | | | | RBracket 511..512 +| | | | | | | | RBracket 511..512 "]" +| | | | | | Dot 512..513 +| | | | | | | Dot 512..513 "." +| | | | | | Identifier 513..516 +| | | | | | | Identifier 513..516 "out" +| | | Semicolon 516..517 +| | | | Semicolon 516..517 ";" +| | WhiteSpace 517..518 +| | | WhiteSpace 517..518 " " +| | EndLine 518..520 +| | | EndLine 518..520 "\r\n" +| | WhiteSpace 520..532 +| | | WhiteSpace 520..532 " " +| RCurly 532..533 +| | RCurly 532..533 "}" diff --git a/crates/syntax/src/snapshots/syntax__syntax__tests____src__test_files__happy__block_comment.circom.snap b/crates/syntax/src/snapshots/syntax__syntax__tests____src__test_files__happy__block_comment.circom.snap index 2932d5d..dd8199e 100644 --- a/crates/syntax/src/snapshots/syntax__syntax__tests____src__test_files__happy__block_comment.circom.snap +++ b/crates/syntax/src/snapshots/syntax__syntax__tests____src__test_files__happy__block_comment.circom.snap @@ -1,29 +1,24 @@ --- source: crates/syntax/src/syntax.rs -expression: "crate::view_syntax::view_ast(&syntax)" +expression: "crate :: view_syntax :: view_ast(& syntax)" --- - CircomProgram 0..42 -| EndLine 0..1 -| | EndLine 0..1 -| | | EndLine 0..1 "\n" -| BlockComment 1..21 -| | BlockComment 1..21 -| | | BlockComment 1..21 "/*\ncomment\nblocks\n*/" -| EndLine 21..22 -| | EndLine 21..22 -| | | EndLine 21..22 "\n" -| Pragma 22..42 -| | Pragma 22..28 -| | | Pragma 22..28 "pragma" -| | WhiteSpace 28..29 -| | | WhiteSpace 28..29 -| | | | WhiteSpace 28..29 " " -| | Circom 29..35 -| | | Circom 29..35 "circom" -| | WhiteSpace 35..36 -| | | WhiteSpace 35..36 -| | | | WhiteSpace 35..36 " " -| | Version 36..41 -| | | Version 36..41 "2.0.0" -| | Semicolon 41..42 -| | | Semicolon 41..42 ";" + CircomProgram 0..47 +| EndLine 0..2 +| | EndLine 0..2 "\r\n" +| BlockComment 2..25 +| | BlockComment 2..25 "/*\r\ncomment\r\nblocks\r\n*/" +| EndLine 25..27 +| | EndLine 25..27 "\r\n" +| Pragma 27..47 +| | PragmaKw 27..33 +| | | PragmaKw 27..33 "pragma" +| | WhiteSpace 33..34 +| | | WhiteSpace 33..34 " " +| | Circom 34..40 +| | | Circom 34..40 "circom" +| | WhiteSpace 40..41 +| | | WhiteSpace 40..41 " " +| | Version 41..46 +| | | Version 41..46 "2.0.0" +| | Semicolon 46..47 +| | | Semicolon 46..47 ";" diff --git a/crates/syntax/src/snapshots/syntax__syntax__tests____src__test_files__happy__full_circom_program.circom.snap b/crates/syntax/src/snapshots/syntax__syntax__tests____src__test_files__happy__full_circom_program.circom.snap index 2886dde..dfe9522 100644 --- a/crates/syntax/src/snapshots/syntax__syntax__tests____src__test_files__happy__full_circom_program.circom.snap +++ b/crates/syntax/src/snapshots/syntax__syntax__tests____src__test_files__happy__full_circom_program.circom.snap @@ -1,1417 +1,1033 @@ --- source: crates/syntax/src/syntax.rs -expression: "crate::view_syntax::view_ast(&syntax)" +expression: "crate :: view_syntax :: view_ast(& syntax)" --- - CircomProgram 0..3637 -| BlockComment 0..747 -| | BlockComment 0..747 -| | | BlockComment 0..747 "/*\n Copyright 2018 0KIMS association.\n\n This file is part of circom (Zero Knowledge Circuit Compiler).\n\n circom is a free software: you can redistribute it and/or modify it\n under the terms of the GNU General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n circom is distributed in the hope that it will be useful, but WITHOUT\n ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\n or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public\n License for more details.\n\n You should have received a copy of the GNU General Public License\n along with circom. If not, see .\n*/" -| EndLine 747..748 -| | EndLine 747..748 -| | | EndLine 747..748 "\n" -| BlockComment 748..1434 -| | BlockComment 748..1434 -| | | BlockComment 748..1434 "/*\n\nBinary Sum\n==========\n\nThis component creates a binary sum componet of ops operands and n bits each operand.\n\ne is Number of carries: Depends on the number of operands in the input.\n\nMain Constraint:\n in[0][0] * 2^0 + in[0][1] * 2^1 + ..... + in[0][n-1] * 2^(n-1) +\n + in[1][0] * 2^0 + in[1][1] * 2^1 + ..... + in[1][n-1] * 2^(n-1) +\n + ..\n + in[ops-1][0] * 2^0 + in[ops-1][1] * 2^1 + ..... + in[ops-1][n-1] * 2^(n-1) +\n ===\n out[0] * 2^0 + out[1] * 2^1 + + out[n+e-1] *2(n+e-1)\n\nTo waranty binary outputs:\n\n out[0] * (out[0] - 1) === 0\n out[1] * (out[0] - 1) === 0\n .\n .\n .\n out[n+e-1] * (out[n+e-1] - 1) == 0\n\n */" -| EndLine 1434..1435 -| | EndLine 1434..1435 -| | | EndLine 1434..1435 "\n" -| EndLine 1435..1436 -| | EndLine 1435..1436 -| | | EndLine 1435..1436 "\n" -| EndLine 1436..1437 -| | EndLine 1436..1437 -| | | EndLine 1436..1437 "\n" -| BlockComment 1437..1531 -| | BlockComment 1437..1531 -| | | BlockComment 1437..1531 "/*\n This function calculates the number of extra bits in the output to do the full sum.\n */" -| EndLine 1531..1532 -| | EndLine 1531..1532 -| | | EndLine 1531..1532 "\n" -| WhiteSpace 1532..1533 -| | WhiteSpace 1532..1533 -| | | WhiteSpace 1532..1533 " " -| Pragma 1533..1553 -| | Pragma 1533..1539 -| | | Pragma 1533..1539 "pragma" -| | WhiteSpace 1539..1540 -| | | WhiteSpace 1539..1540 -| | | | WhiteSpace 1539..1540 " " -| | Circom 1540..1546 -| | | Circom 1540..1546 "circom" -| | WhiteSpace 1546..1547 -| | | WhiteSpace 1546..1547 -| | | | WhiteSpace 1546..1547 " " -| | Version 1547..1552 -| | | Version 1547..1552 "2.0.0" -| | Semicolon 1552..1553 -| | | Semicolon 1552..1553 ";" -| EndLine 1553..1554 -| | EndLine 1553..1554 -| | | EndLine 1553..1554 "\n" -| EndLine 1554..1555 -| | EndLine 1554..1555 -| | | EndLine 1554..1555 "\n" -| FunctionDef 1555..1807 -| | FunctionKw 1555..1563 -| | | FunctionKw 1555..1563 "function" -| | WhiteSpace 1563..1564 -| | | WhiteSpace 1563..1564 -| | | | WhiteSpace 1563..1564 " " -| | FunctionName 1564..1569 -| | | Identifier 1564..1569 -| | | | Identifier 1564..1569 "nbits" -| | LParen 1569..1570 -| | | LParen 1569..1570 "(" -| | ParameterList 1570..1571 -| | | Identifier 1570..1571 -| | | | Identifier 1570..1571 "a" -| | RParen 1571..1572 -| | | RParen 1571..1572 ")" -| | WhiteSpace 1572..1573 -| | | WhiteSpace 1572..1573 -| | | | WhiteSpace 1572..1573 " " -| | Block 1573..1807 -| | | LCurly 1573..1574 -| | | | LCurly 1573..1574 "{" -| | | EndLine 1574..1575 -| | | | EndLine 1574..1575 -| | | | | EndLine 1574..1575 "\n" -| | | WhiteSpace 1575..1579 -| | | | WhiteSpace 1575..1579 -| | | | | WhiteSpace 1575..1579 " " -| | | StatementList 1579..1806 -| | | | VarDecl 1579..1588 -| | | | | VarKw 1579..1582 -| | | | | | VarKw 1579..1582 "var" -| | | | | WhiteSpace 1582..1583 -| | | | | | WhiteSpace 1582..1583 -| | | | | | | WhiteSpace 1582..1583 " " -| | | | | Identifier 1583..1584 -| | | | | | Identifier 1583..1584 "n" -| | | | | WhiteSpace 1584..1585 -| | | | | | WhiteSpace 1584..1585 -| | | | | | | WhiteSpace 1584..1585 " " -| | | | | Assign 1585..1586 -| | | | | | Assign 1585..1586 "=" -| | | | | WhiteSpace 1586..1587 -| | | | | | WhiteSpace 1586..1587 -| | | | | | | WhiteSpace 1586..1587 " " -| | | | | Expression 1587..1588 -| | | | | | Number 1587..1588 -| | | | | | | Number 1587..1588 -| | | | | | | | Number 1587..1588 "1" -| | | | Semicolon 1588..1589 -| | | | | Semicolon 1588..1589 ";" -| | | | EndLine 1589..1590 -| | | | | EndLine 1589..1590 -| | | | | | EndLine 1589..1590 "\n" -| | | | WhiteSpace 1590..1594 -| | | | | WhiteSpace 1590..1594 -| | | | | | WhiteSpace 1590..1594 " " -| | | | VarDecl 1594..1603 -| | | | | VarKw 1594..1597 -| | | | | | VarKw 1594..1597 "var" -| | | | | WhiteSpace 1597..1598 -| | | | | | WhiteSpace 1597..1598 -| | | | | | | WhiteSpace 1597..1598 " " -| | | | | Identifier 1598..1599 -| | | | | | Identifier 1598..1599 "r" -| | | | | WhiteSpace 1599..1600 -| | | | | | WhiteSpace 1599..1600 -| | | | | | | WhiteSpace 1599..1600 " " -| | | | | Assign 1600..1601 -| | | | | | Assign 1600..1601 "=" -| | | | | WhiteSpace 1601..1602 -| | | | | | WhiteSpace 1601..1602 -| | | | | | | WhiteSpace 1601..1602 " " -| | | | | Expression 1602..1603 -| | | | | | Number 1602..1603 -| | | | | | | Number 1602..1603 -| | | | | | | | Number 1602..1603 "0" -| | | | Semicolon 1603..1604 -| | | | | Semicolon 1603..1604 ";" -| | | | EndLine 1604..1605 -| | | | | EndLine 1604..1605 -| | | | | | EndLine 1604..1605 "\n" -| | | | WhiteSpace 1605..1609 -| | | | | WhiteSpace 1605..1609 -| | | | | | WhiteSpace 1605..1609 " " -| | | | Statement 1609..1791 -| | | | | WhileKw 1609..1614 -| | | | | | WhileKw 1609..1614 "while" -| | | | | WhiteSpace 1614..1615 -| | | | | | WhiteSpace 1614..1615 -| | | | | | | WhiteSpace 1614..1615 " " -| | | | | LParen 1615..1616 -| | | | | | LParen 1615..1616 "(" -| | | | | Expression 1616..1621 -| | | | | | LessThan 1616..1621 -| | | | | | | Sub 1616..1619 -| | | | | | | | Identifier 1616..1617 -| | | | | | | | | Identifier 1616..1617 -| | | | | | | | | | Identifier 1616..1617 "n" -| | | | | | | | Sub 1617..1618 -| | | | | | | | | Sub 1617..1618 "-" -| | | | | | | | Number 1618..1619 -| | | | | | | | | Number 1618..1619 -| | | | | | | | | | Number 1618..1619 "1" -| | | | | | | LessThan 1619..1620 -| | | | | | | | LessThan 1619..1620 "<" -| | | | | | | Identifier 1620..1621 -| | | | | | | | Identifier 1620..1621 -| | | | | | | | | Identifier 1620..1621 "a" -| | | | | RParen 1621..1622 -| | | | | | RParen 1621..1622 ")" -| | | | | WhiteSpace 1622..1623 -| | | | | | WhiteSpace 1622..1623 -| | | | | | | WhiteSpace 1622..1623 " " -| | | | | Statement 1623..1791 -| | | | | | Block 1623..1791 -| | | | | | | LCurly 1623..1624 -| | | | | | | | LCurly 1623..1624 "{" -| | | | | | | EndLine 1624..1625 -| | | | | | | | EndLine 1624..1625 -| | | | | | | | | EndLine 1624..1625 "\n" -| | | | | | | WhiteSpace 1625..1633 -| | | | | | | | WhiteSpace 1625..1633 -| | | | | | | | | WhiteSpace 1625..1633 " " -| | | | | | | StatementList 1633..1790 -| | | | | | | | Statement 1633..1666 -| | | | | | | | | Error 1633..1634 -| | | | | | | | | | Expression 1633..1634 -| | | | | | | | | | | ComponentIdentifier 1633..1634 -| | | | | | | | | | | | Identifier 1633..1634 -| | | | | | | | | | | | | Identifier 1633..1634 "r" -| | | | | | | | | Error 1634..1666 -| | | | | | | | | | Error 1634..1666 -| | | | | | | | | | | Error 1634..1666 "expect Semicolon but got UnitInc" -| | | | | | | | Statement 1666..1713 -| | | | | | | | | Error 1666..1678 -| | | | | | | | | | Expression 1666..1678 -| | | | | | | | | | | UnitInc 1666..1669 -| | | | | | | | | | | | UnitInc 1666..1668 -| | | | | | | | | | | | | UnitInc 1666..1668 "++" -| | | | | | | | | | | | Error 1668..1669 -| | | | | | | | | | | | | Semicolon 1668..1669 -| | | | | | | | | | | | | | Semicolon 1668..1669 ";" -| | | | | | | | | | | EndLine 1669..1670 -| | | | | | | | | | | | EndLine 1669..1670 -| | | | | | | | | | | | | EndLine 1669..1670 "\n" -| | | | | | | | | | | WhiteSpace 1670..1678 -| | | | | | | | | | | | WhiteSpace 1670..1678 -| | | | | | | | | | | | | WhiteSpace 1670..1678 " " -| | | | | | | | | Error 1678..1713 -| | | | | | | | | | Error 1678..1713 -| | | | | | | | | | | Error 1678..1713 "expect Semicolon but got Identifier" -| | | | | | | | Statement 1713..1749 -| | | | | | | | | Error 1713..1715 -| | | | | | | | | | Expression 1713..1715 -| | | | | | | | | | | ComponentIdentifier 1713..1714 -| | | | | | | | | | | | Identifier 1713..1714 -| | | | | | | | | | | | | Identifier 1713..1714 "n" -| | | | | | | | | | | WhiteSpace 1714..1715 -| | | | | | | | | | | | WhiteSpace 1714..1715 -| | | | | | | | | | | | | WhiteSpace 1714..1715 " " -| | | | | | | | | Error 1715..1749 -| | | | | | | | | | Error 1715..1749 -| | | | | | | | | | | Error 1715..1749 "expect Semicolon but got MulAssign" -| | | | | | | | Statement 1749..1783 -| | | | | | | | | Error 1749..1752 -| | | | | | | | | | Expression 1749..1751 -| | | | | | | | | | | Error 1749..1751 -| | | | | | | | | | | | MulAssign 1749..1751 -| | | | | | | | | | | | | MulAssign 1749..1751 "*=" -| | | | | | | | | | WhiteSpace 1751..1752 -| | | | | | | | | | | WhiteSpace 1751..1752 -| | | | | | | | | | | | WhiteSpace 1751..1752 " " -| | | | | | | | | Error 1752..1783 -| | | | | | | | | | Error 1752..1783 -| | | | | | | | | | | Error 1752..1783 "expect Semicolon but got Number" -| | | | | | | | Statement 1783..1785 -| | | | | | | | | Error 1783..1784 -| | | | | | | | | | Expression 1783..1784 -| | | | | | | | | | | Number 1783..1784 -| | | | | | | | | | | | Number 1783..1784 -| | | | | | | | | | | | | Number 1783..1784 "2" -| | | | | | | | | Semicolon 1784..1785 -| | | | | | | | | | Semicolon 1784..1785 ";" -| | | | | | | | EndLine 1785..1786 -| | | | | | | | | EndLine 1785..1786 -| | | | | | | | | | EndLine 1785..1786 "\n" -| | | | | | | | WhiteSpace 1786..1790 -| | | | | | | | | WhiteSpace 1786..1790 -| | | | | | | | | | WhiteSpace 1786..1790 " " -| | | | | | | RCurly 1790..1791 -| | | | | | | | RCurly 1790..1791 "}" -| | | | EndLine 1791..1792 -| | | | | EndLine 1791..1792 -| | | | | | EndLine 1791..1792 "\n" -| | | | WhiteSpace 1792..1796 -| | | | | WhiteSpace 1792..1796 -| | | | | | WhiteSpace 1792..1796 " " -| | | | Statement 1796..1805 -| | | | | ReturnKw 1796..1804 -| | | | | | ReturnKw 1796..1802 -| | | | | | | ReturnKw 1796..1802 "return" -| | | | | | WhiteSpace 1802..1803 -| | | | | | | WhiteSpace 1802..1803 -| | | | | | | | WhiteSpace 1802..1803 " " -| | | | | | Expression 1803..1804 -| | | | | | | Identifier 1803..1804 -| | | | | | | | Identifier 1803..1804 -| | | | | | | | | Identifier 1803..1804 "r" -| | | | | Semicolon 1804..1805 -| | | | | | Semicolon 1804..1805 ";" -| | | | EndLine 1805..1806 -| | | | | EndLine 1805..1806 -| | | | | | EndLine 1805..1806 "\n" -| | | RCurly 1806..1807 -| | | | RCurly 1806..1807 "}" -| EndLine 1807..1808 -| | EndLine 1807..1808 -| | | EndLine 1807..1808 "\n" -| EndLine 1808..1809 -| | EndLine 1808..1809 -| | | EndLine 1808..1809 "\n" -| EndLine 1809..1810 -| | EndLine 1809..1810 -| | | EndLine 1809..1810 "\n" -| TemplateDef 1810..3637 -| | TemplateKw 1810..1818 -| | | TemplateKw 1810..1818 "template" -| | WhiteSpace 1818..1819 -| | | WhiteSpace 1818..1819 -| | | | WhiteSpace 1818..1819 " " -| | TemplateName 1819..1825 -| | | Identifier 1819..1825 -| | | | Identifier 1819..1825 "BinSum" -| | LParen 1825..1826 -| | | LParen 1825..1826 "(" -| | ParameterList 1826..1832 -| | | Identifier 1826..1827 -| | | | Identifier 1826..1827 "n" -| | | Comma 1827..1828 -| | | | Comma 1827..1828 "," -| | | WhiteSpace 1828..1829 -| | | | WhiteSpace 1828..1829 -| | | | | WhiteSpace 1828..1829 " " -| | | Identifier 1829..1832 -| | | | Identifier 1829..1832 "ops" -| | RParen 1832..1833 -| | | RParen 1832..1833 ")" -| | WhiteSpace 1833..1834 -| | | WhiteSpace 1833..1834 -| | | | WhiteSpace 1833..1834 " " -| | Block 1834..3637 -| | | LCurly 1834..1835 -| | | | LCurly 1834..1835 "{" -| | | EndLine 1835..1836 -| | | | EndLine 1835..1836 -| | | | | EndLine 1835..1836 "\n" -| | | WhiteSpace 1836..1840 + CircomProgram 0..2508 +| BlockComment 0..764 +| | BlockComment 0..764 "/*\r\n Copyright 2018 0KIMS association.\r\n\r\n This file is part of circom (Zero Knowledge Circuit Compiler).\r\n\r\n circom is a free software: you can redistribute it and/or modify it\r\n under the terms of the GNU General Public License as published by\r\n the Free Software Foundation, either version 3 of the License, or\r\n (at your option) any later version.\r\n\r\n circom is distributed in the hope that it will be useful, but WITHOUT\r\n ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r\n or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public\r\n License for more details.\r\n\r\n You should have received a copy of the GNU General Public License\r\n along with circom. If not, see .\r\n*/" +| EndLine 764..766 +| | EndLine 764..766 "\r\n" +| BlockComment 766..1478 +| | BlockComment 766..1478 "/*\r\n\r\nBinary Sum\r\n==========\r\n\r\nThis component creates a binary sum componet of ops operands and n bits each operand.\r\n\r\ne is Number of carries: Depends on the number of operands in the input.\r\n\r\nMain Constraint:\r\n in[0][0] * 2^0 + in[0][1] * 2^1 + ..... + in[0][n-1] * 2^(n-1) +\r\n + in[1][0] * 2^0 + in[1][1] * 2^1 + ..... + in[1][n-1] * 2^(n-1) +\r\n + ..\r\n + in[ops-1][0] * 2^0 + in[ops-1][1] * 2^1 + ..... + in[ops-1][n-1] * 2^(n-1) +\r\n ===\r\n out[0] * 2^0 + out[1] * 2^1 + + out[n+e-1] *2(n+e-1)\r\n\r\nTo waranty binary outputs:\r\n\r\n out[0] * (out[0] - 1) === 0\r\n out[1] * (out[0] - 1) === 0\r\n .\r\n .\r\n .\r\n out[n+e-1] * (out[n+e-1] - 1) == 0\r\n\r\n */" +| EndLine 1478..1480 +| | EndLine 1478..1480 "\r\n" +| EndLine 1480..1482 +| | EndLine 1480..1482 "\r\n" +| EndLine 1482..1484 +| | EndLine 1482..1484 "\r\n" +| BlockComment 1484..1580 +| | BlockComment 1484..1580 "/*\r\n This function calculates the number of extra bits in the output to do the full sum.\r\n */" +| EndLine 1580..1582 +| | EndLine 1580..1582 "\r\n" +| WhiteSpace 1582..1583 +| | WhiteSpace 1582..1583 " " +| Pragma 1583..1603 +| | PragmaKw 1583..1589 +| | | PragmaKw 1583..1589 "pragma" +| | WhiteSpace 1589..1590 +| | | WhiteSpace 1589..1590 " " +| | Circom 1590..1596 +| | | Circom 1590..1596 "circom" +| | WhiteSpace 1596..1597 +| | | WhiteSpace 1596..1597 " " +| | Version 1597..1602 +| | | Version 1597..1602 "2.0.0" +| | Semicolon 1602..1603 +| | | Semicolon 1602..1603 ";" +| EndLine 1603..1605 +| | EndLine 1603..1605 "\r\n" +| EndLine 1605..1607 +| | EndLine 1605..1607 "\r\n" +| FunctionDef 1607..1735 +| | FunctionKw 1607..1615 +| | | FunctionKw 1607..1615 "function" +| | WhiteSpace 1615..1616 +| | | WhiteSpace 1615..1616 " " +| | FunctionName 1616..1621 +| | | Identifier 1616..1621 +| | | | Identifier 1616..1621 "nbits" +| | LParen 1621..1622 +| | | LParen 1621..1622 "(" +| | ParameterList 1622..1623 +| | | Identifier 1622..1623 +| | | | Identifier 1622..1623 "a" +| | RParen 1623..1624 +| | | RParen 1623..1624 ")" +| | WhiteSpace 1624..1625 +| | | WhiteSpace 1624..1625 " " +| | Block 1625..1735 +| | | LCurly 1625..1626 +| | | | LCurly 1625..1626 "{" +| | | EndLine 1626..1628 +| | | | EndLine 1626..1628 "\r\n" +| | | WhiteSpace 1628..1632 +| | | | WhiteSpace 1628..1632 " " +| | | StatementList 1632..1734 +| | | | VarDecl 1632..1641 +| | | | | VarKw 1632..1635 +| | | | | | VarKw 1632..1635 "var" +| | | | | WhiteSpace 1635..1636 +| | | | | | WhiteSpace 1635..1636 " " +| | | | | VarIdentifier 1636..1638 +| | | | | | Identifier 1636..1637 +| | | | | | | Identifier 1636..1637 "n" +| | | | | | WhiteSpace 1637..1638 +| | | | | | | WhiteSpace 1637..1638 " " +| | | | | Assign 1638..1639 +| | | | | | Assign 1638..1639 "=" +| | | | | WhiteSpace 1639..1640 +| | | | | | WhiteSpace 1639..1640 " " +| | | | | Expression 1640..1641 +| | | | | | ExpressionAtom 1640..1641 +| | | | | | | Number 1640..1641 +| | | | | | | | Number 1640..1641 "1" +| | | | Semicolon 1641..1642 +| | | | | Semicolon 1641..1642 ";" +| | | | EndLine 1642..1644 +| | | | | EndLine 1642..1644 "\r\n" +| | | | WhiteSpace 1644..1648 +| | | | | WhiteSpace 1644..1648 " " +| | | | VarDecl 1648..1657 +| | | | | VarKw 1648..1651 +| | | | | | VarKw 1648..1651 "var" +| | | | | WhiteSpace 1651..1652 +| | | | | | WhiteSpace 1651..1652 " " +| | | | | VarIdentifier 1652..1654 +| | | | | | Identifier 1652..1653 +| | | | | | | Identifier 1652..1653 "r" +| | | | | | WhiteSpace 1653..1654 +| | | | | | | WhiteSpace 1653..1654 " " +| | | | | Assign 1654..1655 +| | | | | | Assign 1654..1655 "=" +| | | | | WhiteSpace 1655..1656 +| | | | | | WhiteSpace 1655..1656 " " +| | | | | Expression 1656..1657 +| | | | | | ExpressionAtom 1656..1657 +| | | | | | | Number 1656..1657 +| | | | | | | | Number 1656..1657 "0" +| | | | Semicolon 1657..1658 +| | | | | Semicolon 1657..1658 ";" +| | | | EndLine 1658..1660 +| | | | | EndLine 1658..1660 "\r\n" +| | | | WhiteSpace 1660..1664 +| | | | | WhiteSpace 1660..1664 " " +| | | | Statement 1664..1717 +| | | | | WhileKw 1664..1669 +| | | | | | WhileKw 1664..1669 "while" +| | | | | WhiteSpace 1669..1670 +| | | | | | WhiteSpace 1669..1670 " " +| | | | | LParen 1670..1671 +| | | | | | LParen 1670..1671 "(" +| | | | | Expression 1671..1676 +| | | | | | LessThan 1671..1676 +| | | | | | | Sub 1671..1674 +| | | | | | | | ExpressionAtom 1671..1672 +| | | | | | | | | Identifier 1671..1672 +| | | | | | | | | | Identifier 1671..1672 "n" +| | | | | | | | Sub 1672..1673 +| | | | | | | | | Sub 1672..1673 "-" +| | | | | | | | ExpressionAtom 1673..1674 +| | | | | | | | | Number 1673..1674 +| | | | | | | | | | Number 1673..1674 "1" +| | | | | | | LessThan 1674..1675 +| | | | | | | | LessThan 1674..1675 "<" +| | | | | | | ExpressionAtom 1675..1676 +| | | | | | | | Identifier 1675..1676 +| | | | | | | | | Identifier 1675..1676 "a" +| | | | | RParen 1676..1677 +| | | | | | RParen 1676..1677 ")" +| | | | | WhiteSpace 1677..1678 +| | | | | | WhiteSpace 1677..1678 " " +| | | | | Statement 1678..1717 +| | | | | | Block 1678..1717 +| | | | | | | LCurly 1678..1679 +| | | | | | | | LCurly 1678..1679 "{" +| | | | | | | EndLine 1679..1681 +| | | | | | | | EndLine 1679..1681 "\r\n" +| | | | | | | WhiteSpace 1681..1689 +| | | | | | | | WhiteSpace 1681..1689 " " +| | | | | | | StatementList 1689..1716 +| | | | | | | | Statement 1689..1693 +| | | | | | | | | AssignStatement 1689..1692 +| | | | | | | | | | Expression 1689..1690 +| | | | | | | | | | | ComponentIdentifier 1689..1690 +| | | | | | | | | | | | Identifier 1689..1690 +| | | | | | | | | | | | | Identifier 1689..1690 "r" +| | | | | | | | | | UnitInc 1690..1692 +| | | | | | | | | | | UnitInc 1690..1692 "++" +| | | | | | | | | Semicolon 1692..1693 +| | | | | | | | | | Semicolon 1692..1693 ";" +| | | | | | | | EndLine 1693..1695 +| | | | | | | | | EndLine 1693..1695 "\r\n" +| | | | | | | | WhiteSpace 1695..1703 +| | | | | | | | | WhiteSpace 1695..1703 " " +| | | | | | | | Statement 1703..1710 +| | | | | | | | | AssignStatement 1703..1709 +| | | | | | | | | | Expression 1703..1705 +| | | | | | | | | | | ComponentIdentifier 1703..1704 +| | | | | | | | | | | | Identifier 1703..1704 +| | | | | | | | | | | | | Identifier 1703..1704 "n" +| | | | | | | | | | | WhiteSpace 1704..1705 +| | | | | | | | | | | | WhiteSpace 1704..1705 " " +| | | | | | | | | | MulAssign 1705..1707 +| | | | | | | | | | | MulAssign 1705..1707 "*=" +| | | | | | | | | | WhiteSpace 1707..1708 +| | | | | | | | | | | WhiteSpace 1707..1708 " " +| | | | | | | | | | Expression 1708..1709 +| | | | | | | | | | | ExpressionAtom 1708..1709 +| | | | | | | | | | | | Number 1708..1709 +| | | | | | | | | | | | | Number 1708..1709 "2" +| | | | | | | | | Semicolon 1709..1710 +| | | | | | | | | | Semicolon 1709..1710 ";" +| | | | | | | | EndLine 1710..1712 +| | | | | | | | | EndLine 1710..1712 "\r\n" +| | | | | | | | WhiteSpace 1712..1716 +| | | | | | | | | WhiteSpace 1712..1716 " " +| | | | | | | RCurly 1716..1717 +| | | | | | | | RCurly 1716..1717 "}" +| | | | EndLine 1717..1719 +| | | | | EndLine 1717..1719 "\r\n" +| | | | WhiteSpace 1719..1723 +| | | | | WhiteSpace 1719..1723 " " +| | | | Statement 1723..1732 +| | | | | ReturnKw 1723..1731 +| | | | | | ReturnKw 1723..1729 +| | | | | | | ReturnKw 1723..1729 "return" +| | | | | | WhiteSpace 1729..1730 +| | | | | | | WhiteSpace 1729..1730 " " +| | | | | | Expression 1730..1731 +| | | | | | | ExpressionAtom 1730..1731 +| | | | | | | | Identifier 1730..1731 +| | | | | | | | | Identifier 1730..1731 "r" +| | | | | Semicolon 1731..1732 +| | | | | | Semicolon 1731..1732 ";" +| | | | EndLine 1732..1734 +| | | | | EndLine 1732..1734 "\r\n" +| | | RCurly 1734..1735 +| | | | RCurly 1734..1735 "}" +| EndLine 1735..1737 +| | EndLine 1735..1737 "\r\n" +| EndLine 1737..1739 +| | EndLine 1737..1739 "\r\n" +| EndLine 1739..1741 +| | EndLine 1739..1741 "\r\n" +| TemplateDef 1741..2508 +| | TemplateKw 1741..1749 +| | | TemplateKw 1741..1749 "template" +| | WhiteSpace 1749..1750 +| | | WhiteSpace 1749..1750 " " +| | TemplateName 1750..1756 +| | | Identifier 1750..1756 +| | | | Identifier 1750..1756 "BinSum" +| | LParen 1756..1757 +| | | LParen 1756..1757 "(" +| | ParameterList 1757..1763 +| | | Identifier 1757..1758 +| | | | Identifier 1757..1758 "n" +| | | Comma 1758..1759 +| | | | Comma 1758..1759 "," +| | | WhiteSpace 1759..1760 +| | | | WhiteSpace 1759..1760 " " +| | | Identifier 1760..1763 +| | | | Identifier 1760..1763 "ops" +| | RParen 1763..1764 +| | | RParen 1763..1764 ")" +| | WhiteSpace 1764..1765 +| | | WhiteSpace 1764..1765 " " +| | Block 1765..2508 +| | | LCurly 1765..1766 +| | | | LCurly 1765..1766 "{" +| | | EndLine 1766..1768 +| | | | EndLine 1766..1768 "\r\n" +| | | WhiteSpace 1768..1772 +| | | | WhiteSpace 1768..1772 " " +| | | StatementList 1772..2483 +| | | | VarDecl 1772..1803 +| | | | | VarKw 1772..1775 +| | | | | | VarKw 1772..1775 "var" +| | | | | WhiteSpace 1775..1776 +| | | | | | WhiteSpace 1775..1776 " " +| | | | | VarIdentifier 1776..1781 +| | | | | | Identifier 1776..1780 +| | | | | | | Identifier 1776..1780 "nout" +| | | | | | WhiteSpace 1780..1781 +| | | | | | | WhiteSpace 1780..1781 " " +| | | | | Assign 1781..1782 +| | | | | | Assign 1781..1782 "=" +| | | | | WhiteSpace 1782..1783 +| | | | | | WhiteSpace 1782..1783 " " +| | | | | Expression 1783..1803 +| | | | | | Call 1783..1803 +| | | | | | | ExpressionAtom 1783..1788 +| | | | | | | | Identifier 1783..1788 +| | | | | | | | | Identifier 1783..1788 "nbits" +| | | | | | | Tuple 1788..1803 +| | | | | | | | LParen 1788..1789 +| | | | | | | | | LParen 1788..1789 "(" +| | | | | | | | Expression 1789..1802 +| | | | | | | | | Mul 1789..1802 +| | | | | | | | | | Tuple 1789..1798 +| | | | | | | | | | | LParen 1789..1790 +| | | | | | | | | | | | LParen 1789..1790 "(" +| | | | | | | | | | | Sub 1790..1797 +| | | | | | | | | | | | Power 1790..1795 +| | | | | | | | | | | | | ExpressionAtom 1790..1791 +| | | | | | | | | | | | | | Number 1790..1791 +| | | | | | | | | | | | | | | Number 1790..1791 "2" +| | | | | | | | | | | | | Power 1791..1793 +| | | | | | | | | | | | | | Power 1791..1793 "**" +| | | | | | | | | | | | | ExpressionAtom 1793..1794 +| | | | | | | | | | | | | | Identifier 1793..1794 +| | | | | | | | | | | | | | | Identifier 1793..1794 "n" +| | | | | | | | | | | | | WhiteSpace 1794..1795 +| | | | | | | | | | | | | | WhiteSpace 1794..1795 " " +| | | | | | | | | | | | Sub 1795..1796 +| | | | | | | | | | | | | Sub 1795..1796 "-" +| | | | | | | | | | | | ExpressionAtom 1796..1797 +| | | | | | | | | | | | | Number 1796..1797 +| | | | | | | | | | | | | | Number 1796..1797 "1" +| | | | | | | | | | | RParen 1797..1798 +| | | | | | | | | | | | RParen 1797..1798 ")" +| | | | | | | | | | Mul 1798..1799 +| | | | | | | | | | | Mul 1798..1799 "*" +| | | | | | | | | | ExpressionAtom 1799..1802 +| | | | | | | | | | | Identifier 1799..1802 +| | | | | | | | | | | | Identifier 1799..1802 "ops" +| | | | | | | | RParen 1802..1803 +| | | | | | | | | RParen 1802..1803 ")" +| | | | Semicolon 1803..1804 +| | | | | Semicolon 1803..1804 ";" +| | | | EndLine 1804..1806 +| | | | | EndLine 1804..1806 "\r\n" +| | | | WhiteSpace 1806..1810 +| | | | | WhiteSpace 1806..1810 " " +| | | | InputSignalDecl 1810..1833 +| | | | | SignalHeader 1810..1823 +| | | | | | SignalKw 1810..1816 +| | | | | | | SignalKw 1810..1816 "signal" +| | | | | | WhiteSpace 1816..1817 +| | | | | | | WhiteSpace 1816..1817 " " +| | | | | | InputKw 1817..1822 +| | | | | | | InputKw 1817..1822 "input" +| | | | | | WhiteSpace 1822..1823 +| | | | | | | WhiteSpace 1822..1823 " " +| | | | | SignalIdentifier 1823..1833 +| | | | | | Identifier 1823..1825 +| | | | | | | Identifier 1823..1825 "in" +| | | | | | LBracket 1825..1826 +| | | | | | | LBracket 1825..1826 "[" +| | | | | | Expression 1826..1829 +| | | | | | | ExpressionAtom 1826..1829 +| | | | | | | | Identifier 1826..1829 +| | | | | | | | | Identifier 1826..1829 "ops" +| | | | | | RBracket 1829..1830 +| | | | | | | RBracket 1829..1830 "]" +| | | | | | LBracket 1830..1831 +| | | | | | | LBracket 1830..1831 "[" +| | | | | | Expression 1831..1832 +| | | | | | | ExpressionAtom 1831..1832 +| | | | | | | | Identifier 1831..1832 +| | | | | | | | | Identifier 1831..1832 "n" +| | | | | | RBracket 1832..1833 +| | | | | | | RBracket 1832..1833 "]" +| | | | Semicolon 1833..1834 +| | | | | Semicolon 1833..1834 ";" +| | | | EndLine 1834..1836 +| | | | | EndLine 1834..1836 "\r\n" | | | | WhiteSpace 1836..1840 | | | | | WhiteSpace 1836..1840 " " -| | | StatementList 1840..3612 -| | | | VarDecl 1840..1950 -| | | | | VarKw 1840..1843 -| | | | | | VarKw 1840..1843 "var" -| | | | | WhiteSpace 1843..1844 -| | | | | | WhiteSpace 1843..1844 -| | | | | | | WhiteSpace 1843..1844 " " -| | | | | Identifier 1844..1848 -| | | | | | Identifier 1844..1848 "nout" -| | | | | WhiteSpace 1848..1849 -| | | | | | WhiteSpace 1848..1849 -| | | | | | | WhiteSpace 1848..1849 " " -| | | | | Assign 1849..1850 -| | | | | | Assign 1849..1850 "=" -| | | | | WhiteSpace 1850..1851 -| | | | | | WhiteSpace 1850..1851 -| | | | | | | WhiteSpace 1850..1851 " " -| | | | | Expression 1851..1950 -| | | | | | ArrayQuery 1851..1950 -| | | | | | | Call 1851..1917 -| | | | | | | | Identifier 1851..1856 -| | | | | | | | | Identifier 1851..1856 -| | | | | | | | | | Identifier 1851..1856 "nbits" -| | | | | | | | Tuple 1856..1917 -| | | | | | | | | LParen 1856..1857 -| | | | | | | | | | LParen 1856..1857 "(" -| | | | | | | | | Error 1857..1889 -| | | | | | | | | | Error 1857..1889 -| | | | | | | | | | | Error 1857..1889 "expect Identifier but got LParen" -| | | | | | | | | Error 1889..1917 -| | | | | | | | | | Error 1889..1917 -| | | | | | | | | | | Error 1889..1917 "expect RParen but got LParen" -| | | | | | | LParen 1917..1918 -| | | | | | | | LParen 1917..1918 "(" -| | | | | | | Error 1918..1950 -| | | | | | | | Error 1918..1950 -| | | | | | | | | Error 1918..1950 "expect Identifier but got Number" -| | | | Error 1950..1981 -| | | | | Error 1950..1981 -| | | | | | Error 1950..1981 "expect Semicolon but got Number" -| | | | Statement 1981..2019 -| | | | | Error 1981..1988 -| | | | | | Expression 1981..1988 -| | | | | | | Sub 1981..1988 -| | | | | | | | Power 1981..1986 -| | | | | | | | | Number 1981..1982 -| | | | | | | | | | Number 1981..1982 -| | | | | | | | | | | Number 1981..1982 "2" -| | | | | | | | | Power 1982..1984 -| | | | | | | | | | Power 1982..1984 "**" -| | | | | | | | | Identifier 1984..1985 -| | | | | | | | | | Identifier 1984..1985 -| | | | | | | | | | | Identifier 1984..1985 "n" -| | | | | | | | | WhiteSpace 1985..1986 -| | | | | | | | | | WhiteSpace 1985..1986 -| | | | | | | | | | | WhiteSpace 1985..1986 " " -| | | | | | | | Sub 1986..1987 -| | | | | | | | | Sub 1986..1987 "-" -| | | | | | | | Number 1987..1988 -| | | | | | | | | Number 1987..1988 -| | | | | | | | | | Number 1987..1988 "1" -| | | | | Error 1988..2019 -| | | | | | Error 1988..2019 -| | | | | | | Error 1988..2019 "expect Semicolon but got RParen" -| | | | Statement 2019..2048 -| | | | | Error 2019..2020 -| | | | | | Expression 2019..2020 -| | | | | | | Error 2019..2020 -| | | | | | | | RParen 2019..2020 -| | | | | | | | | RParen 2019..2020 ")" -| | | | | Error 2020..2048 -| | | | | | Error 2020..2048 -| | | | | | | Error 2020..2048 "expect Semicolon but got Mul" -| | | | Statement 2048..2084 -| | | | | Error 2048..2049 -| | | | | | Expression 2048..2049 -| | | | | | | Error 2048..2049 -| | | | | | | | Mul 2048..2049 -| | | | | | | | | Mul 2048..2049 "*" -| | | | | Error 2049..2084 -| | | | | | Error 2049..2084 -| | | | | | | Error 2049..2084 "expect Semicolon but got Identifier" -| | | | Statement 2084..2118 -| | | | | Error 2084..2087 -| | | | | | Expression 2084..2087 -| | | | | | | ComponentIdentifier 2084..2087 -| | | | | | | | Identifier 2084..2087 -| | | | | | | | | Identifier 2084..2087 "ops" -| | | | | Error 2087..2118 -| | | | | | Error 2087..2118 -| | | | | | | Error 2087..2118 "expect Semicolon but got RParen" -| | | | Statement 2118..2120 -| | | | | Error 2118..2119 -| | | | | | Expression 2118..2119 -| | | | | | | Error 2118..2119 -| | | | | | | | RParen 2118..2119 -| | | | | | | | | RParen 2118..2119 ")" -| | | | | Semicolon 2119..2120 -| | | | | | Semicolon 2119..2120 ";" -| | | | EndLine 2120..2121 -| | | | | EndLine 2120..2121 -| | | | | | EndLine 2120..2121 "\n" -| | | | WhiteSpace 2121..2125 -| | | | | WhiteSpace 2121..2125 -| | | | | | WhiteSpace 2121..2125 " " -| | | | InputSignalDecl 2125..2140 -| | | | | SignalHeader 2125..2138 -| | | | | | SignalKw 2125..2131 -| | | | | | | SignalKw 2125..2131 "signal" -| | | | | | WhiteSpace 2131..2132 -| | | | | | | WhiteSpace 2131..2132 -| | | | | | | | WhiteSpace 2131..2132 " " -| | | | | | InputKw 2132..2137 -| | | | | | | InputKw 2132..2137 "input" -| | | | | | WhiteSpace 2137..2138 -| | | | | | | WhiteSpace 2137..2138 -| | | | | | | | WhiteSpace 2137..2138 " " -| | | | | Identifier 2138..2140 -| | | | | | Identifier 2138..2140 "in" -| | | | Error 2140..2173 -| | | | | Error 2140..2173 -| | | | | | Error 2140..2173 "expect Semicolon but got LBracket" -| | | | Statement 2173..2209 -| | | | | Error 2173..2174 -| | | | | | Expression 2173..2174 -| | | | | | | Error 2173..2174 -| | | | | | | | LBracket 2173..2174 -| | | | | | | | | LBracket 2173..2174 "[" -| | | | | Error 2174..2209 -| | | | | | Error 2174..2209 -| | | | | | | Error 2174..2209 "expect Semicolon but got Identifier" -| | | | Statement 2209..2245 -| | | | | Error 2209..2212 -| | | | | | Expression 2209..2212 -| | | | | | | ComponentIdentifier 2209..2212 -| | | | | | | | Identifier 2209..2212 -| | | | | | | | | Identifier 2209..2212 "ops" -| | | | | Error 2212..2245 -| | | | | | Error 2212..2245 -| | | | | | | Error 2212..2245 "expect Semicolon but got RBracket" -| | | | Statement 2245..2279 -| | | | | Error 2245..2246 -| | | | | | Expression 2245..2246 -| | | | | | | Error 2245..2246 -| | | | | | | | RBracket 2245..2246 -| | | | | | | | | RBracket 2245..2246 "]" -| | | | | Error 2246..2279 -| | | | | | Error 2246..2279 -| | | | | | | Error 2246..2279 "expect Semicolon but got LBracket" -| | | | Statement 2279..2315 -| | | | | Error 2279..2280 -| | | | | | Expression 2279..2280 -| | | | | | | Error 2279..2280 -| | | | | | | | LBracket 2279..2280 -| | | | | | | | | LBracket 2279..2280 "[" -| | | | | Error 2280..2315 -| | | | | | Error 2280..2315 -| | | | | | | Error 2280..2315 "expect Semicolon but got Identifier" -| | | | Statement 2315..2349 -| | | | | Error 2315..2316 -| | | | | | Expression 2315..2316 -| | | | | | | ComponentIdentifier 2315..2316 -| | | | | | | | Identifier 2315..2316 -| | | | | | | | | Identifier 2315..2316 "n" -| | | | | Error 2316..2349 -| | | | | | Error 2316..2349 -| | | | | | | Error 2316..2349 "expect Semicolon but got RBracket" -| | | | Statement 2349..2351 -| | | | | Error 2349..2350 -| | | | | | Expression 2349..2350 -| | | | | | | Error 2349..2350 -| | | | | | | | RBracket 2349..2350 -| | | | | | | | | RBracket 2349..2350 "]" -| | | | | Semicolon 2350..2351 -| | | | | | Semicolon 2350..2351 ";" -| | | | EndLine 2351..2352 -| | | | | EndLine 2351..2352 -| | | | | | EndLine 2351..2352 "\n" -| | | | WhiteSpace 2352..2356 -| | | | | WhiteSpace 2352..2356 -| | | | | | WhiteSpace 2352..2356 " " -| | | | OutputSignalDecl 2356..2373 -| | | | | SignalHeader 2356..2370 -| | | | | | SignalKw 2356..2362 -| | | | | | | SignalKw 2356..2362 "signal" -| | | | | | WhiteSpace 2362..2363 -| | | | | | | WhiteSpace 2362..2363 -| | | | | | | | WhiteSpace 2362..2363 " " -| | | | | | OutputKw 2363..2369 -| | | | | | | OutputKw 2363..2369 "output" -| | | | | | WhiteSpace 2369..2370 -| | | | | | | WhiteSpace 2369..2370 -| | | | | | | | WhiteSpace 2369..2370 " " -| | | | | Identifier 2370..2373 -| | | | | | Identifier 2370..2373 "out" -| | | | Error 2373..2406 -| | | | | Error 2373..2406 -| | | | | | Error 2373..2406 "expect Semicolon but got LBracket" -| | | | Statement 2406..2442 -| | | | | Error 2406..2407 -| | | | | | Expression 2406..2407 -| | | | | | | Error 2406..2407 -| | | | | | | | LBracket 2406..2407 -| | | | | | | | | LBracket 2406..2407 "[" -| | | | | Error 2407..2442 -| | | | | | Error 2407..2442 -| | | | | | | Error 2407..2442 "expect Semicolon but got Identifier" -| | | | Statement 2442..2479 -| | | | | Error 2442..2446 -| | | | | | Expression 2442..2446 -| | | | | | | ComponentIdentifier 2442..2446 -| | | | | | | | Identifier 2442..2446 -| | | | | | | | | Identifier 2442..2446 "nout" -| | | | | Error 2446..2479 -| | | | | | Error 2446..2479 -| | | | | | | Error 2446..2479 "expect Semicolon but got RBracket" -| | | | Statement 2479..2481 -| | | | | Error 2479..2480 -| | | | | | Expression 2479..2480 -| | | | | | | Error 2479..2480 -| | | | | | | | RBracket 2479..2480 -| | | | | | | | | RBracket 2479..2480 "]" -| | | | | Semicolon 2480..2481 -| | | | | | Semicolon 2480..2481 ";" -| | | | EndLine 2481..2482 -| | | | | EndLine 2481..2482 -| | | | | | EndLine 2481..2482 "\n" -| | | | EndLine 2482..2483 -| | | | | EndLine 2482..2483 -| | | | | | EndLine 2482..2483 "\n" -| | | | WhiteSpace 2483..2487 -| | | | | WhiteSpace 2483..2487 -| | | | | | WhiteSpace 2483..2487 " " -| | | | VarDecl 2487..2498 -| | | | | VarKw 2487..2490 -| | | | | | VarKw 2487..2490 "var" -| | | | | WhiteSpace 2490..2491 -| | | | | | WhiteSpace 2490..2491 -| | | | | | | WhiteSpace 2490..2491 " " -| | | | | Identifier 2491..2494 -| | | | | | Identifier 2491..2494 "lin" -| | | | | WhiteSpace 2494..2495 -| | | | | | WhiteSpace 2494..2495 -| | | | | | | WhiteSpace 2494..2495 " " -| | | | | Assign 2495..2496 -| | | | | | Assign 2495..2496 "=" -| | | | | WhiteSpace 2496..2497 -| | | | | | WhiteSpace 2496..2497 -| | | | | | | WhiteSpace 2496..2497 " " -| | | | | Expression 2497..2498 -| | | | | | Number 2497..2498 -| | | | | | | Number 2497..2498 -| | | | | | | | Number 2497..2498 "0" -| | | | Semicolon 2498..2499 -| | | | | Semicolon 2498..2499 ";" -| | | | EndLine 2499..2500 -| | | | | EndLine 2499..2500 -| | | | | | EndLine 2499..2500 "\n" -| | | | WhiteSpace 2500..2504 -| | | | | WhiteSpace 2500..2504 -| | | | | | WhiteSpace 2500..2504 " " -| | | | VarDecl 2504..2516 -| | | | | VarKw 2504..2507 -| | | | | | VarKw 2504..2507 "var" -| | | | | WhiteSpace 2507..2508 -| | | | | | WhiteSpace 2507..2508 -| | | | | | | WhiteSpace 2507..2508 " " -| | | | | Identifier 2508..2512 -| | | | | | Identifier 2508..2512 "lout" -| | | | | WhiteSpace 2512..2513 -| | | | | | WhiteSpace 2512..2513 -| | | | | | | WhiteSpace 2512..2513 " " -| | | | | Assign 2513..2514 -| | | | | | Assign 2513..2514 "=" -| | | | | WhiteSpace 2514..2515 -| | | | | | WhiteSpace 2514..2515 -| | | | | | | WhiteSpace 2514..2515 " " -| | | | | Expression 2515..2516 -| | | | | | Number 2515..2516 -| | | | | | | Number 2515..2516 -| | | | | | | | Number 2515..2516 "0" -| | | | Semicolon 2516..2517 -| | | | | Semicolon 2516..2517 ";" -| | | | EndLine 2517..2518 -| | | | | EndLine 2517..2518 -| | | | | | EndLine 2517..2518 "\n" -| | | | EndLine 2518..2519 -| | | | | EndLine 2518..2519 -| | | | | | EndLine 2518..2519 "\n" -| | | | WhiteSpace 2519..2523 -| | | | | WhiteSpace 2519..2523 -| | | | | | WhiteSpace 2519..2523 " " -| | | | VarDecl 2523..2528 -| | | | | VarKw 2523..2526 -| | | | | | VarKw 2523..2526 "var" -| | | | | WhiteSpace 2526..2527 -| | | | | | WhiteSpace 2526..2527 -| | | | | | | WhiteSpace 2526..2527 " " -| | | | | Identifier 2527..2528 -| | | | | | Identifier 2527..2528 "k" -| | | | Semicolon 2528..2529 -| | | | | Semicolon 2528..2529 ";" -| | | | EndLine 2529..2530 -| | | | | EndLine 2529..2530 -| | | | | | EndLine 2529..2530 "\n" -| | | | WhiteSpace 2530..2534 -| | | | | WhiteSpace 2530..2534 -| | | | | | WhiteSpace 2530..2534 " " -| | | | VarDecl 2534..2539 -| | | | | VarKw 2534..2537 -| | | | | | VarKw 2534..2537 "var" -| | | | | WhiteSpace 2537..2538 -| | | | | | WhiteSpace 2537..2538 -| | | | | | | WhiteSpace 2537..2538 " " -| | | | | Identifier 2538..2539 -| | | | | | Identifier 2538..2539 "j" -| | | | Semicolon 2539..2540 -| | | | | Semicolon 2539..2540 ";" -| | | | EndLine 2540..2541 -| | | | | EndLine 2540..2541 -| | | | | | EndLine 2540..2541 "\n" -| | | | EndLine 2541..2542 -| | | | | EndLine 2541..2542 -| | | | | | EndLine 2541..2542 "\n" -| | | | WhiteSpace 2542..2546 -| | | | | WhiteSpace 2542..2546 -| | | | | | WhiteSpace 2542..2546 " " -| | | | VarDecl 2546..2552 -| | | | | VarKw 2546..2549 -| | | | | | VarKw 2546..2549 "var" -| | | | | WhiteSpace 2549..2550 -| | | | | | WhiteSpace 2549..2550 -| | | | | | | WhiteSpace 2549..2550 " " -| | | | | Identifier 2550..2552 -| | | | | | Identifier 2550..2552 "e2" -| | | | Semicolon 2552..2553 -| | | | | Semicolon 2552..2553 ";" -| | | | EndLine 2553..2554 -| | | | | EndLine 2553..2554 -| | | | | | EndLine 2553..2554 "\n" -| | | | EndLine 2554..2555 -| | | | | EndLine 2554..2555 -| | | | | | EndLine 2554..2555 "\n" -| | | | WhiteSpace 2555..2559 -| | | | | WhiteSpace 2555..2559 -| | | | | | WhiteSpace 2555..2559 " " -| | | | Statement 2559..2566 -| | | | | AssignStatement 2559..2565 -| | | | | | Expression 2559..2562 -| | | | | | | ComponentIdentifier 2559..2561 -| | | | | | | | Identifier 2559..2561 -| | | | | | | | | Identifier 2559..2561 "e2" -| | | | | | | WhiteSpace 2561..2562 -| | | | | | | | WhiteSpace 2561..2562 -| | | | | | | | | WhiteSpace 2561..2562 " " -| | | | | | Assign 2562..2563 -| | | | | | | Assign 2562..2563 "=" -| | | | | | WhiteSpace 2563..2564 -| | | | | | | WhiteSpace 2563..2564 -| | | | | | | | WhiteSpace 2563..2564 " " -| | | | | | Expression 2564..2565 -| | | | | | | Number 2564..2565 -| | | | | | | | Number 2564..2565 -| | | | | | | | | Number 2564..2565 "1" -| | | | | Semicolon 2565..2566 -| | | | | | Semicolon 2565..2566 ";" -| | | | EndLine 2566..2567 -| | | | | EndLine 2566..2567 -| | | | | | EndLine 2566..2567 "\n" -| | | | WhiteSpace 2567..2571 -| | | | | WhiteSpace 2567..2571 -| | | | | | WhiteSpace 2567..2571 " " -| | | | Statement 2571..2651 -| | | | | ForLoop 2571..2651 -| | | | | | ForKw 2571..2574 -| | | | | | | ForKw 2571..2574 "for" -| | | | | | WhiteSpace 2574..2575 -| | | | | | | WhiteSpace 2574..2575 -| | | | | | | | WhiteSpace 2574..2575 " " -| | | | | | LParen 2575..2576 -| | | | | | | LParen 2575..2576 "(" -| | | | | | AssignStatement 2576..2579 -| | | | | | | Expression 2576..2577 -| | | | | | | | ComponentIdentifier 2576..2577 -| | | | | | | | | Identifier 2576..2577 -| | | | | | | | | | Identifier 2576..2577 "k" -| | | | | | | Assign 2577..2578 -| | | | | | | | Assign 2577..2578 "=" -| | | | | | | Expression 2578..2579 -| | | | | | | | Number 2578..2579 -| | | | | | | | | Number 2578..2579 -| | | | | | | | | | Number 2578..2579 "0" -| | | | | | Semicolon 2579..2580 -| | | | | | | Semicolon 2579..2580 ";" -| | | | | | WhiteSpace 2580..2581 -| | | | | | | WhiteSpace 2580..2581 -| | | | | | | | WhiteSpace 2580..2581 " " -| | | | | | Expression 2581..2584 -| | | | | | | LessThan 2581..2584 -| | | | | | | | Identifier 2581..2582 -| | | | | | | | | Identifier 2581..2582 -| | | | | | | | | | Identifier 2581..2582 "k" -| | | | | | | | LessThan 2582..2583 -| | | | | | | | | LessThan 2582..2583 "<" -| | | | | | | | Identifier 2583..2584 -| | | | | | | | | Identifier 2583..2584 -| | | | | | | | | | Identifier 2583..2584 "n" -| | | | | | Semicolon 2584..2585 -| | | | | | | Semicolon 2584..2585 ";" -| | | | | | WhiteSpace 2585..2586 -| | | | | | | WhiteSpace 2585..2586 -| | | | | | | | WhiteSpace 2585..2586 " " -| | | | | | Error 2586..2587 -| | | | | | | Expression 2586..2587 -| | | | | | | | ComponentIdentifier 2586..2587 -| | | | | | | | | Identifier 2586..2587 -| | | | | | | | | | Identifier 2586..2587 "k" -| | | | | | Error 2587..2616 -| | | | | | | Error 2587..2616 -| | | | | | | | Error 2587..2616 "expect RParen but got UnitInc" -| | | | | | Error 2616..2620 -| | | | | | | Expression 2616..2620 -| | | | | | | | UnitInc 2616..2619 -| | | | | | | | | UnitInc 2616..2618 -| | | | | | | | | | UnitInc 2616..2618 "++" -| | | | | | | | | Error 2618..2619 -| | | | | | | | | | RParen 2618..2619 -| | | | | | | | | | | RParen 2618..2619 ")" -| | | | | | | | WhiteSpace 2619..2620 -| | | | | | | | | WhiteSpace 2619..2620 -| | | | | | | | | | WhiteSpace 2619..2620 " " -| | | | | | Error 2620..2651 -| | | | | | | Error 2620..2651 -| | | | | | | | Error 2620..2651 "expect Semicolon but got LCurly" -| | | | Statement 2651..3611 -| | | | | Block 2651..3611 -| | | | | | LCurly 2651..2652 -| | | | | | | LCurly 2651..2652 "{" -| | | | | | EndLine 2652..2653 -| | | | | | | EndLine 2652..2653 -| | | | | | | | EndLine 2652..2653 "\n" -| | | | | | WhiteSpace 2653..2661 -| | | | | | | WhiteSpace 2653..2661 -| | | | | | | | WhiteSpace 2653..2661 " " -| | | | | | StatementList 2661..3610 -| | | | | | | Statement 2661..2743 -| | | | | | | | ForLoop 2661..2743 -| | | | | | | | | ForKw 2661..2664 -| | | | | | | | | | ForKw 2661..2664 "for" -| | | | | | | | | WhiteSpace 2664..2665 -| | | | | | | | | | WhiteSpace 2664..2665 -| | | | | | | | | | | WhiteSpace 2664..2665 " " -| | | | | | | | | LParen 2665..2666 -| | | | | | | | | | LParen 2665..2666 "(" -| | | | | | | | | AssignStatement 2666..2669 -| | | | | | | | | | Expression 2666..2667 -| | | | | | | | | | | ComponentIdentifier 2666..2667 -| | | | | | | | | | | | Identifier 2666..2667 -| | | | | | | | | | | | | Identifier 2666..2667 "j" -| | | | | | | | | | Assign 2667..2668 -| | | | | | | | | | | Assign 2667..2668 "=" -| | | | | | | | | | Expression 2668..2669 -| | | | | | | | | | | Number 2668..2669 -| | | | | | | | | | | | Number 2668..2669 -| | | | | | | | | | | | | Number 2668..2669 "0" -| | | | | | | | | Semicolon 2669..2670 -| | | | | | | | | | Semicolon 2669..2670 ";" -| | | | | | | | | WhiteSpace 2670..2671 -| | | | | | | | | | WhiteSpace 2670..2671 -| | | | | | | | | | | WhiteSpace 2670..2671 " " -| | | | | | | | | Expression 2671..2676 -| | | | | | | | | | LessThan 2671..2676 -| | | | | | | | | | | Identifier 2671..2672 -| | | | | | | | | | | | Identifier 2671..2672 -| | | | | | | | | | | | | Identifier 2671..2672 "j" -| | | | | | | | | | | LessThan 2672..2673 -| | | | | | | | | | | | LessThan 2672..2673 "<" -| | | | | | | | | | | Identifier 2673..2676 -| | | | | | | | | | | | Identifier 2673..2676 -| | | | | | | | | | | | | Identifier 2673..2676 "ops" -| | | | | | | | | Semicolon 2676..2677 -| | | | | | | | | | Semicolon 2676..2677 ";" -| | | | | | | | | WhiteSpace 2677..2678 -| | | | | | | | | | WhiteSpace 2677..2678 -| | | | | | | | | | | WhiteSpace 2677..2678 " " -| | | | | | | | | Error 2678..2679 -| | | | | | | | | | Expression 2678..2679 -| | | | | | | | | | | ComponentIdentifier 2678..2679 -| | | | | | | | | | | | Identifier 2678..2679 -| | | | | | | | | | | | | Identifier 2678..2679 "j" -| | | | | | | | | Error 2679..2708 -| | | | | | | | | | Error 2679..2708 -| | | | | | | | | | | Error 2679..2708 "expect RParen but got UnitInc" -| | | | | | | | | Error 2708..2712 -| | | | | | | | | | Expression 2708..2712 -| | | | | | | | | | | UnitInc 2708..2711 -| | | | | | | | | | | | UnitInc 2708..2710 -| | | | | | | | | | | | | UnitInc 2708..2710 "++" -| | | | | | | | | | | | Error 2710..2711 -| | | | | | | | | | | | | RParen 2710..2711 -| | | | | | | | | | | | | | RParen 2710..2711 ")" -| | | | | | | | | | | WhiteSpace 2711..2712 -| | | | | | | | | | | | WhiteSpace 2711..2712 -| | | | | | | | | | | | | WhiteSpace 2711..2712 " " -| | | | | | | | | Error 2712..2743 -| | | | | | | | | | Error 2712..2743 -| | | | | | | | | | | Error 2712..2743 "expect Semicolon but got LCurly" -| | | | | | | Statement 2743..3021 -| | | | | | | | Block 2743..3021 -| | | | | | | | | LCurly 2743..2744 -| | | | | | | | | | LCurly 2743..2744 "{" -| | | | | | | | | EndLine 2744..2745 -| | | | | | | | | | EndLine 2744..2745 -| | | | | | | | | | | EndLine 2744..2745 "\n" -| | | | | | | | | WhiteSpace 2745..2757 -| | | | | | | | | | WhiteSpace 2745..2757 -| | | | | | | | | | | WhiteSpace 2745..2757 " " -| | | | | | | | | StatementList 2757..3020 -| | | | | | | | | | Statement 2757..2795 -| | | | | | | | | | | Error 2757..2761 -| | | | | | | | | | | | Expression 2757..2761 -| | | | | | | | | | | | | ComponentIdentifier 2757..2760 -| | | | | | | | | | | | | | Identifier 2757..2760 -| | | | | | | | | | | | | | | Identifier 2757..2760 "lin" -| | | | | | | | | | | | | WhiteSpace 2760..2761 -| | | | | | | | | | | | | | WhiteSpace 2760..2761 -| | | | | | | | | | | | | | | WhiteSpace 2760..2761 " " -| | | | | | | | | | | Error 2761..2795 -| | | | | | | | | | | | Error 2761..2795 -| | | | | | | | | | | | | Error 2761..2795 "expect Semicolon but got AddAssign" -| | | | | | | | | | Statement 2795..2833 -| | | | | | | | | | | Error 2795..2798 -| | | | | | | | | | | | Expression 2795..2797 -| | | | | | | | | | | | | Error 2795..2797 -| | | | | | | | | | | | | | AddAssign 2795..2797 -| | | | | | | | | | | | | | | AddAssign 2795..2797 "+=" -| | | | | | | | | | | | WhiteSpace 2797..2798 -| | | | | | | | | | | | | WhiteSpace 2797..2798 -| | | | | | | | | | | | | | WhiteSpace 2797..2798 " " -| | | | | | | | | | | Error 2798..2833 -| | | | | | | | | | | | Error 2798..2833 -| | | | | | | | | | | | | Error 2798..2833 "expect Semicolon but got Identifier" -| | | | | | | | | | Statement 2833..2871 -| | | | | | | | | | | Error 2833..2838 -| | | | | | | | | | | | Expression 2833..2838 -| | | | | | | | | | | | | ComponentIdentifier 2833..2835 -| | | | | | | | | | | | | | Identifier 2833..2835 -| | | | | | | | | | | | | | | Identifier 2833..2835 "in" -| | | | | | | | | | | | | LBracket 2835..2836 -| | | | | | | | | | | | | | LBracket 2835..2836 "[" -| | | | | | | | | | | | | Expression 2836..2837 -| | | | | | | | | | | | | | Identifier 2836..2837 -| | | | | | | | | | | | | | | Identifier 2836..2837 -| | | | | | | | | | | | | | | | Identifier 2836..2837 "j" -| | | | | | | | | | | | | RBracket 2837..2838 -| | | | | | | | | | | | | | RBracket 2837..2838 "]" -| | | | | | | | | | | Error 2838..2871 -| | | | | | | | | | | | Error 2838..2871 -| | | | | | | | | | | | | Error 2838..2871 "expect Semicolon but got LBracket" -| | | | | | | | | | Statement 2871..2907 -| | | | | | | | | | | Error 2871..2872 -| | | | | | | | | | | | Expression 2871..2872 -| | | | | | | | | | | | | Error 2871..2872 -| | | | | | | | | | | | | | LBracket 2871..2872 -| | | | | | | | | | | | | | | LBracket 2871..2872 "[" -| | | | | | | | | | | Error 2872..2907 -| | | | | | | | | | | | Error 2872..2907 -| | | | | | | | | | | | | Error 2872..2907 "expect Semicolon but got Identifier" -| | | | | | | | | | Statement 2907..2941 -| | | | | | | | | | | Error 2907..2908 -| | | | | | | | | | | | Expression 2907..2908 -| | | | | | | | | | | | | ComponentIdentifier 2907..2908 -| | | | | | | | | | | | | | Identifier 2907..2908 -| | | | | | | | | | | | | | | Identifier 2907..2908 "k" -| | | | | | | | | | | Error 2908..2941 -| | | | | | | | | | | | Error 2908..2941 -| | | | | | | | | | | | | Error 2908..2941 "expect Semicolon but got RBracket" -| | | | | | | | | | Statement 2941..2971 -| | | | | | | | | | | Error 2941..2943 -| | | | | | | | | | | | Expression 2941..2942 -| | | | | | | | | | | | | Error 2941..2942 -| | | | | | | | | | | | | | RBracket 2941..2942 -| | | | | | | | | | | | | | | RBracket 2941..2942 "]" -| | | | | | | | | | | | WhiteSpace 2942..2943 -| | | | | | | | | | | | | WhiteSpace 2942..2943 -| | | | | | | | | | | | | | WhiteSpace 2942..2943 " " -| | | | | | | | | | | Error 2943..2971 -| | | | | | | | | | | | Error 2943..2971 -| | | | | | | | | | | | | Error 2943..2971 "expect Semicolon but got Mul" -| | | | | | | | | | Statement 2971..3008 -| | | | | | | | | | | Error 2971..2973 -| | | | | | | | | | | | Expression 2971..2972 -| | | | | | | | | | | | | Error 2971..2972 -| | | | | | | | | | | | | | Mul 2971..2972 -| | | | | | | | | | | | | | | Mul 2971..2972 "*" -| | | | | | | | | | | | WhiteSpace 2972..2973 -| | | | | | | | | | | | | WhiteSpace 2972..2973 -| | | | | | | | | | | | | | WhiteSpace 2972..2973 " " -| | | | | | | | | | | Error 2973..3008 -| | | | | | | | | | | | Error 2973..3008 -| | | | | | | | | | | | | Error 2973..3008 "expect Semicolon but got Identifier" -| | | | | | | | | | Statement 3008..3011 -| | | | | | | | | | | Error 3008..3010 -| | | | | | | | | | | | Expression 3008..3010 -| | | | | | | | | | | | | ComponentIdentifier 3008..3010 -| | | | | | | | | | | | | | Identifier 3008..3010 -| | | | | | | | | | | | | | | Identifier 3008..3010 "e2" -| | | | | | | | | | | Semicolon 3010..3011 -| | | | | | | | | | | | Semicolon 3010..3011 ";" -| | | | | | | | | | EndLine 3011..3012 -| | | | | | | | | | | EndLine 3011..3012 -| | | | | | | | | | | | EndLine 3011..3012 "\n" -| | | | | | | | | | WhiteSpace 3012..3020 -| | | | | | | | | | | WhiteSpace 3012..3020 -| | | | | | | | | | | | WhiteSpace 3012..3020 " " -| | | | | | | | | RCurly 3020..3021 -| | | | | | | | | | RCurly 3020..3021 "}" -| | | | | | | EndLine 3021..3022 -| | | | | | | | EndLine 3021..3022 -| | | | | | | | | EndLine 3021..3022 "\n" -| | | | | | | WhiteSpace 3022..3030 -| | | | | | | | WhiteSpace 3022..3030 -| | | | | | | | | WhiteSpace 3022..3030 " " -| | | | | | | Statement 3030..3043 -| | | | | | | | AssignStatement 3030..3042 -| | | | | | | | | Expression 3030..3033 -| | | | | | | | | | ComponentIdentifier 3030..3032 -| | | | | | | | | | | Identifier 3030..3032 -| | | | | | | | | | | | Identifier 3030..3032 "e2" -| | | | | | | | | | WhiteSpace 3032..3033 -| | | | | | | | | | | WhiteSpace 3032..3033 -| | | | | | | | | | | | WhiteSpace 3032..3033 " " -| | | | | | | | | Assign 3033..3034 -| | | | | | | | | | Assign 3033..3034 "=" -| | | | | | | | | WhiteSpace 3034..3035 -| | | | | | | | | | WhiteSpace 3034..3035 -| | | | | | | | | | | WhiteSpace 3034..3035 " " -| | | | | | | | | Expression 3035..3042 -| | | | | | | | | | Add 3035..3042 -| | | | | | | | | | | Identifier 3035..3037 -| | | | | | | | | | | | Identifier 3035..3037 -| | | | | | | | | | | | | Identifier 3035..3037 "e2" -| | | | | | | | | | | WhiteSpace 3037..3038 -| | | | | | | | | | | | WhiteSpace 3037..3038 -| | | | | | | | | | | | | WhiteSpace 3037..3038 " " -| | | | | | | | | | | Add 3038..3039 -| | | | | | | | | | | | Add 3038..3039 "+" -| | | | | | | | | | | WhiteSpace 3039..3040 -| | | | | | | | | | | | WhiteSpace 3039..3040 -| | | | | | | | | | | | | WhiteSpace 3039..3040 " " -| | | | | | | | | | | Identifier 3040..3042 -| | | | | | | | | | | | Identifier 3040..3042 -| | | | | | | | | | | | | Identifier 3040..3042 "e2" -| | | | | | | | Semicolon 3042..3043 -| | | | | | | | | Semicolon 3042..3043 ";" -| | | | | | | EndLine 3043..3044 -| | | | | | | | EndLine 3043..3044 -| | | | | | | | | EndLine 3043..3044 "\n" -| | | | | | | WhiteSpace 3044..3048 -| | | | | | | | WhiteSpace 3044..3048 -| | | | | | | | | WhiteSpace 3044..3048 " " -| | | | | | | EndLine 3048..3049 -| | | | | | | | EndLine 3048..3049 -| | | | | | | | | EndLine 3048..3049 "\n" -| | | | | | | WhiteSpace 3049..3057 -| | | | | | | | WhiteSpace 3049..3057 -| | | | | | | | | WhiteSpace 3049..3057 " " -| | | | | | | Statement 3057..3064 -| | | | | | | | AssignStatement 3057..3063 -| | | | | | | | | Expression 3057..3060 -| | | | | | | | | | ComponentIdentifier 3057..3059 -| | | | | | | | | | | Identifier 3057..3059 -| | | | | | | | | | | | Identifier 3057..3059 "e2" -| | | | | | | | | | WhiteSpace 3059..3060 -| | | | | | | | | | | WhiteSpace 3059..3060 -| | | | | | | | | | | | WhiteSpace 3059..3060 " " -| | | | | | | | | Assign 3060..3061 -| | | | | | | | | | Assign 3060..3061 "=" -| | | | | | | | | WhiteSpace 3061..3062 -| | | | | | | | | | WhiteSpace 3061..3062 -| | | | | | | | | | | WhiteSpace 3061..3062 " " -| | | | | | | | | Expression 3062..3063 -| | | | | | | | | | Number 3062..3063 -| | | | | | | | | | | Number 3062..3063 -| | | | | | | | | | | | Number 3062..3063 "1" -| | | | | | | | Semicolon 3063..3064 -| | | | | | | | | Semicolon 3063..3064 ";" -| | | | | | | EndLine 3064..3065 -| | | | | | | | EndLine 3064..3065 -| | | | | | | | | EndLine 3064..3065 "\n" -| | | | | | | WhiteSpace 3065..3073 -| | | | | | | | WhiteSpace 3065..3073 -| | | | | | | | | WhiteSpace 3065..3073 " " -| | | | | | | Statement 3073..3156 -| | | | | | | | ForLoop 3073..3156 -| | | | | | | | | ForKw 3073..3076 -| | | | | | | | | | ForKw 3073..3076 "for" -| | | | | | | | | WhiteSpace 3076..3077 -| | | | | | | | | | WhiteSpace 3076..3077 -| | | | | | | | | | | WhiteSpace 3076..3077 " " -| | | | | | | | | LParen 3077..3078 -| | | | | | | | | | LParen 3077..3078 "(" -| | | | | | | | | AssignStatement 3078..3081 -| | | | | | | | | | Expression 3078..3079 -| | | | | | | | | | | ComponentIdentifier 3078..3079 -| | | | | | | | | | | | Identifier 3078..3079 -| | | | | | | | | | | | | Identifier 3078..3079 "k" -| | | | | | | | | | Assign 3079..3080 -| | | | | | | | | | | Assign 3079..3080 "=" -| | | | | | | | | | Expression 3080..3081 -| | | | | | | | | | | Number 3080..3081 -| | | | | | | | | | | | Number 3080..3081 -| | | | | | | | | | | | | Number 3080..3081 "0" -| | | | | | | | | Semicolon 3081..3082 -| | | | | | | | | | Semicolon 3081..3082 ";" -| | | | | | | | | WhiteSpace 3082..3083 -| | | | | | | | | | WhiteSpace 3082..3083 -| | | | | | | | | | | WhiteSpace 3082..3083 " " -| | | | | | | | | Expression 3083..3089 -| | | | | | | | | | LessThan 3083..3089 -| | | | | | | | | | | Identifier 3083..3084 -| | | | | | | | | | | | Identifier 3083..3084 -| | | | | | | | | | | | | Identifier 3083..3084 "k" -| | | | | | | | | | | LessThan 3084..3085 -| | | | | | | | | | | | LessThan 3084..3085 "<" -| | | | | | | | | | | Identifier 3085..3089 -| | | | | | | | | | | | Identifier 3085..3089 -| | | | | | | | | | | | | Identifier 3085..3089 "nout" -| | | | | | | | | Semicolon 3089..3090 -| | | | | | | | | | Semicolon 3089..3090 ";" -| | | | | | | | | WhiteSpace 3090..3091 -| | | | | | | | | | WhiteSpace 3090..3091 -| | | | | | | | | | | WhiteSpace 3090..3091 " " -| | | | | | | | | Error 3091..3092 -| | | | | | | | | | Expression 3091..3092 -| | | | | | | | | | | ComponentIdentifier 3091..3092 -| | | | | | | | | | | | Identifier 3091..3092 -| | | | | | | | | | | | | Identifier 3091..3092 "k" -| | | | | | | | | Error 3092..3121 -| | | | | | | | | | Error 3092..3121 -| | | | | | | | | | | Error 3092..3121 "expect RParen but got UnitInc" -| | | | | | | | | Error 3121..3125 -| | | | | | | | | | Expression 3121..3125 -| | | | | | | | | | | UnitInc 3121..3124 -| | | | | | | | | | | | UnitInc 3121..3123 -| | | | | | | | | | | | | UnitInc 3121..3123 "++" -| | | | | | | | | | | | Error 3123..3124 -| | | | | | | | | | | | | RParen 3123..3124 -| | | | | | | | | | | | | | RParen 3123..3124 ")" -| | | | | | | | | | | WhiteSpace 3124..3125 -| | | | | | | | | | | | WhiteSpace 3124..3125 -| | | | | | | | | | | | | WhiteSpace 3124..3125 " " -| | | | | | | | | Error 3125..3156 -| | | | | | | | | | Error 3125..3156 -| | | | | | | | | | | Error 3125..3156 "expect Semicolon but got LCurly" -| | | | | | | Statement 3156..3546 -| | | | | | | | Block 3156..3546 -| | | | | | | | | LCurly 3156..3157 -| | | | | | | | | | LCurly 3156..3157 "{" -| | | | | | | | | EndLine 3157..3158 -| | | | | | | | | | EndLine 3157..3158 -| | | | | | | | | | | EndLine 3157..3158 "\n" -| | | | | | | | | WhiteSpace 3158..3170 -| | | | | | | | | | WhiteSpace 3158..3170 -| | | | | | | | | | | WhiteSpace 3158..3170 " " -| | | | | | | | | StatementList 3170..3545 -| | | | | | | | | | Statement 3170..3196 -| | | | | | | | | | | AssignStatement 3170..3195 -| | | | | | | | | | | | Expression 3170..3177 -| | | | | | | | | | | | | ComponentIdentifier 3170..3173 -| | | | | | | | | | | | | | Identifier 3170..3173 -| | | | | | | | | | | | | | | Identifier 3170..3173 "out" -| | | | | | | | | | | | | LBracket 3173..3174 -| | | | | | | | | | | | | | LBracket 3173..3174 "[" -| | | | | | | | | | | | | Expression 3174..3175 -| | | | | | | | | | | | | | Identifier 3174..3175 -| | | | | | | | | | | | | | | Identifier 3174..3175 -| | | | | | | | | | | | | | | | Identifier 3174..3175 "k" -| | | | | | | | | | | | | RBracket 3175..3176 -| | | | | | | | | | | | | | RBracket 3175..3176 "]" -| | | | | | | | | | | | | WhiteSpace 3176..3177 -| | | | | | | | | | | | | | WhiteSpace 3176..3177 -| | | | | | | | | | | | | | | WhiteSpace 3176..3177 " " -| | | | | | | | | | | | RAssignSignal 3177..3180 -| | | | | | | | | | | | | RAssignSignal 3177..3180 "<--" -| | | | | | | | | | | | WhiteSpace 3180..3181 -| | | | | | | | | | | | | WhiteSpace 3180..3181 -| | | | | | | | | | | | | | WhiteSpace 3180..3181 " " -| | | | | | | | | | | | Expression 3181..3195 -| | | | | | | | | | | | | BitAnd 3181..3195 -| | | | | | | | | | | | | | Tuple 3181..3191 -| | | | | | | | | | | | | | | LParen 3181..3182 -| | | | | | | | | | | | | | | | LParen 3181..3182 "(" -| | | | | | | | | | | | | | | ShiftR 3182..3190 -| | | | | | | | | | | | | | | | Identifier 3182..3185 -| | | | | | | | | | | | | | | | | Identifier 3182..3185 -| | | | | | | | | | | | | | | | | | Identifier 3182..3185 "lin" -| | | | | | | | | | | | | | | | WhiteSpace 3185..3186 -| | | | | | | | | | | | | | | | | WhiteSpace 3185..3186 -| | | | | | | | | | | | | | | | | | WhiteSpace 3185..3186 " " -| | | | | | | | | | | | | | | | ShiftR 3186..3188 -| | | | | | | | | | | | | | | | | ShiftR 3186..3188 ">>" -| | | | | | | | | | | | | | | | WhiteSpace 3188..3189 -| | | | | | | | | | | | | | | | | WhiteSpace 3188..3189 -| | | | | | | | | | | | | | | | | | WhiteSpace 3188..3189 " " -| | | | | | | | | | | | | | | | Identifier 3189..3190 -| | | | | | | | | | | | | | | | | Identifier 3189..3190 -| | | | | | | | | | | | | | | | | | Identifier 3189..3190 "k" -| | | | | | | | | | | | | | | RParen 3190..3191 -| | | | | | | | | | | | | | | | RParen 3190..3191 ")" -| | | | | | | | | | | | | | WhiteSpace 3191..3192 -| | | | | | | | | | | | | | | WhiteSpace 3191..3192 -| | | | | | | | | | | | | | | | WhiteSpace 3191..3192 " " -| | | | | | | | | | | | | | BitAnd 3192..3193 -| | | | | | | | | | | | | | | BitAnd 3192..3193 "&" -| | | | | | | | | | | | | | WhiteSpace 3193..3194 -| | | | | | | | | | | | | | | WhiteSpace 3193..3194 -| | | | | | | | | | | | | | | | WhiteSpace 3193..3194 " " -| | | | | | | | | | | | | | Number 3194..3195 -| | | | | | | | | | | | | | | Number 3194..3195 -| | | | | | | | | | | | | | | | Number 3194..3195 "1" -| | | | | | | | | | | Semicolon 3195..3196 -| | | | | | | | | | | | Semicolon 3195..3196 ";" -| | | | | | | | | | EndLine 3196..3197 -| | | | | | | | | | | EndLine 3196..3197 -| | | | | | | | | | | | EndLine 3196..3197 "\n" -| | | | | | | | | | WhiteSpace 3197..3201 -| | | | | | | | | | | WhiteSpace 3197..3201 -| | | | | | | | | | | | WhiteSpace 3197..3201 " " -| | | | | | | | | | EndLine 3201..3202 -| | | | | | | | | | | EndLine 3201..3202 -| | | | | | | | | | | | EndLine 3201..3202 "\n" -| | | | | | | | | | WhiteSpace 3202..3214 -| | | | | | | | | | | WhiteSpace 3202..3214 -| | | | | | | | | | | | WhiteSpace 3202..3214 " " -| | | | | | | | | | CommentLine 3214..3237 -| | | | | | | | | | | CommentLine 3214..3237 -| | | | | | | | | | | | CommentLine 3214..3237 "// Ensure out is binary" -| | | | | | | | | | EndLine 3237..3238 -| | | | | | | | | | | EndLine 3237..3238 -| | | | | | | | | | | | EndLine 3237..3238 "\n" -| | | | | | | | | | WhiteSpace 3238..3250 -| | | | | | | | | | | WhiteSpace 3238..3250 -| | | | | | | | | | | | WhiteSpace 3238..3250 " " -| | | | | | | | | | Statement 3250..3285 -| | | | | | | | | | | Error 3250..3257 -| | | | | | | | | | | | Expression 3250..3257 -| | | | | | | | | | | | | ComponentIdentifier 3250..3253 -| | | | | | | | | | | | | | Identifier 3250..3253 -| | | | | | | | | | | | | | | Identifier 3250..3253 "out" -| | | | | | | | | | | | | LBracket 3253..3254 -| | | | | | | | | | | | | | LBracket 3253..3254 "[" -| | | | | | | | | | | | | Expression 3254..3255 -| | | | | | | | | | | | | | Identifier 3254..3255 -| | | | | | | | | | | | | | | Identifier 3254..3255 -| | | | | | | | | | | | | | | | Identifier 3254..3255 "k" -| | | | | | | | | | | | | RBracket 3255..3256 -| | | | | | | | | | | | | | RBracket 3255..3256 "]" -| | | | | | | | | | | | | WhiteSpace 3256..3257 -| | | | | | | | | | | | | | WhiteSpace 3256..3257 -| | | | | | | | | | | | | | | WhiteSpace 3256..3257 " " -| | | | | | | | | | | Error 3257..3285 -| | | | | | | | | | | | Error 3257..3285 -| | | | | | | | | | | | | Error 3257..3285 "expect Semicolon but got Mul" -| | | | | | | | | | Statement 3285..3318 -| | | | | | | | | | | Error 3285..3287 -| | | | | | | | | | | | Expression 3285..3286 -| | | | | | | | | | | | | Error 3285..3286 -| | | | | | | | | | | | | | Mul 3285..3286 -| | | | | | | | | | | | | | | Mul 3285..3286 "*" -| | | | | | | | | | | | WhiteSpace 3286..3287 -| | | | | | | | | | | | | WhiteSpace 3286..3287 -| | | | | | | | | | | | | | WhiteSpace 3286..3287 " " -| | | | | | | | | | | Error 3287..3318 -| | | | | | | | | | | | Error 3287..3318 -| | | | | | | | | | | | | Error 3287..3318 "expect Semicolon but got LParen" -| | | | | | | | | | Statement 3318..3337 -| | | | | | | | | | | AssignStatement 3318..3336 -| | | | | | | | | | | | Expression 3318..3331 -| | | | | | | | | | | | | Tuple 3318..3330 -| | | | | | | | | | | | | | LParen 3318..3319 -| | | | | | | | | | | | | | | LParen 3318..3319 "(" -| | | | | | | | | | | | | | Sub 3319..3329 -| | | | | | | | | | | | | | | ArrayQuery 3319..3325 -| | | | | | | | | | | | | | | | Identifier 3319..3322 -| | | | | | | | | | | | | | | | | Identifier 3319..3322 -| | | | | | | | | | | | | | | | | | Identifier 3319..3322 "out" -| | | | | | | | | | | | | | | | LBracket 3322..3323 -| | | | | | | | | | | | | | | | | LBracket 3322..3323 "[" -| | | | | | | | | | | | | | | | Identifier 3323..3324 -| | | | | | | | | | | | | | | | | Identifier 3323..3324 -| | | | | | | | | | | | | | | | | | Identifier 3323..3324 "k" -| | | | | | | | | | | | | | | | RBracket 3324..3325 -| | | | | | | | | | | | | | | | | RBracket 3324..3325 "]" -| | | | | | | | | | | | | | | WhiteSpace 3325..3326 -| | | | | | | | | | | | | | | | WhiteSpace 3325..3326 -| | | | | | | | | | | | | | | | | WhiteSpace 3325..3326 " " -| | | | | | | | | | | | | | | Sub 3326..3327 -| | | | | | | | | | | | | | | | Sub 3326..3327 "-" -| | | | | | | | | | | | | | | WhiteSpace 3327..3328 -| | | | | | | | | | | | | | | | WhiteSpace 3327..3328 -| | | | | | | | | | | | | | | | | WhiteSpace 3327..3328 " " -| | | | | | | | | | | | | | | Number 3328..3329 -| | | | | | | | | | | | | | | | Number 3328..3329 -| | | | | | | | | | | | | | | | | Number 3328..3329 "1" -| | | | | | | | | | | | | | RParen 3329..3330 -| | | | | | | | | | | | | | | RParen 3329..3330 ")" -| | | | | | | | | | | | | WhiteSpace 3330..3331 -| | | | | | | | | | | | | | WhiteSpace 3330..3331 -| | | | | | | | | | | | | | | WhiteSpace 3330..3331 " " -| | | | | | | | | | | | EqualSignal 3331..3334 -| | | | | | | | | | | | | EqualSignal 3331..3334 "===" -| | | | | | | | | | | | WhiteSpace 3334..3335 -| | | | | | | | | | | | | WhiteSpace 3334..3335 -| | | | | | | | | | | | | | WhiteSpace 3334..3335 " " -| | | | | | | | | | | | Expression 3335..3336 -| | | | | | | | | | | | | Number 3335..3336 -| | | | | | | | | | | | | | Number 3335..3336 -| | | | | | | | | | | | | | | Number 3335..3336 "0" -| | | | | | | | | | | Semicolon 3336..3337 -| | | | | | | | | | | | Semicolon 3336..3337 ";" -| | | | | | | | | | EndLine 3337..3338 -| | | | | | | | | | | EndLine 3337..3338 -| | | | | | | | | | | | EndLine 3337..3338 "\n" -| | | | | | | | | | WhiteSpace 3338..3342 -| | | | | | | | | | | WhiteSpace 3338..3342 -| | | | | | | | | | | | WhiteSpace 3338..3342 " " -| | | | | | | | | | EndLine 3342..3343 -| | | | | | | | | | | EndLine 3342..3343 -| | | | | | | | | | | | EndLine 3342..3343 "\n" -| | | | | | | | | | WhiteSpace 3343..3355 -| | | | | | | | | | | WhiteSpace 3343..3355 -| | | | | | | | | | | | WhiteSpace 3343..3355 " " -| | | | | | | | | | Statement 3355..3394 -| | | | | | | | | | | Error 3355..3360 -| | | | | | | | | | | | Expression 3355..3360 -| | | | | | | | | | | | | ComponentIdentifier 3355..3359 -| | | | | | | | | | | | | | Identifier 3355..3359 -| | | | | | | | | | | | | | | Identifier 3355..3359 "lout" -| | | | | | | | | | | | | WhiteSpace 3359..3360 -| | | | | | | | | | | | | | WhiteSpace 3359..3360 -| | | | | | | | | | | | | | | WhiteSpace 3359..3360 " " -| | | | | | | | | | | Error 3360..3394 -| | | | | | | | | | | | Error 3360..3394 -| | | | | | | | | | | | | Error 3360..3394 "expect Semicolon but got AddAssign" -| | | | | | | | | | Statement 3394..3432 -| | | | | | | | | | | Error 3394..3397 -| | | | | | | | | | | | Expression 3394..3396 -| | | | | | | | | | | | | Error 3394..3396 -| | | | | | | | | | | | | | AddAssign 3394..3396 -| | | | | | | | | | | | | | | AddAssign 3394..3396 "+=" -| | | | | | | | | | | | WhiteSpace 3396..3397 -| | | | | | | | | | | | | WhiteSpace 3396..3397 -| | | | | | | | | | | | | | WhiteSpace 3396..3397 " " -| | | | | | | | | | | Error 3397..3432 -| | | | | | | | | | | | Error 3397..3432 -| | | | | | | | | | | | | Error 3397..3432 "expect Semicolon but got Identifier" -| | | | | | | | | | Statement 3432..3467 -| | | | | | | | | | | Error 3432..3439 -| | | | | | | | | | | | Expression 3432..3439 -| | | | | | | | | | | | | ComponentIdentifier 3432..3435 -| | | | | | | | | | | | | | Identifier 3432..3435 -| | | | | | | | | | | | | | | Identifier 3432..3435 "out" -| | | | | | | | | | | | | LBracket 3435..3436 -| | | | | | | | | | | | | | LBracket 3435..3436 "[" -| | | | | | | | | | | | | Expression 3436..3437 -| | | | | | | | | | | | | | Identifier 3436..3437 -| | | | | | | | | | | | | | | Identifier 3436..3437 -| | | | | | | | | | | | | | | | Identifier 3436..3437 "k" -| | | | | | | | | | | | | RBracket 3437..3438 -| | | | | | | | | | | | | | RBracket 3437..3438 "]" -| | | | | | | | | | | | | WhiteSpace 3438..3439 -| | | | | | | | | | | | | | WhiteSpace 3438..3439 -| | | | | | | | | | | | | | | WhiteSpace 3438..3439 " " -| | | | | | | | | | | Error 3439..3467 -| | | | | | | | | | | | Error 3439..3467 -| | | | | | | | | | | | | Error 3439..3467 "expect Semicolon but got Mul" -| | | | | | | | | | Statement 3467..3504 -| | | | | | | | | | | Error 3467..3469 -| | | | | | | | | | | | Expression 3467..3468 -| | | | | | | | | | | | | Error 3467..3468 -| | | | | | | | | | | | | | Mul 3467..3468 -| | | | | | | | | | | | | | | Mul 3467..3468 "*" -| | | | | | | | | | | | WhiteSpace 3468..3469 -| | | | | | | | | | | | | WhiteSpace 3468..3469 -| | | | | | | | | | | | | | WhiteSpace 3468..3469 " " -| | | | | | | | | | | Error 3469..3504 -| | | | | | | | | | | | Error 3469..3504 -| | | | | | | | | | | | | Error 3469..3504 "expect Semicolon but got Identifier" -| | | | | | | | | | Statement 3504..3507 -| | | | | | | | | | | Error 3504..3506 -| | | | | | | | | | | | Expression 3504..3506 -| | | | | | | | | | | | | ComponentIdentifier 3504..3506 -| | | | | | | | | | | | | | Identifier 3504..3506 -| | | | | | | | | | | | | | | Identifier 3504..3506 "e2" -| | | | | | | | | | | Semicolon 3506..3507 -| | | | | | | | | | | | Semicolon 3506..3507 ";" -| | | | | | | | | | EndLine 3507..3508 -| | | | | | | | | | | EndLine 3507..3508 -| | | | | | | | | | | | EndLine 3507..3508 "\n" -| | | | | | | | | | WhiteSpace 3508..3512 -| | | | | | | | | | | WhiteSpace 3508..3512 -| | | | | | | | | | | | WhiteSpace 3508..3512 " " -| | | | | | | | | | EndLine 3512..3513 -| | | | | | | | | | | EndLine 3512..3513 -| | | | | | | | | | | | EndLine 3512..3513 "\n" -| | | | | | | | | | WhiteSpace 3513..3525 -| | | | | | | | | | | WhiteSpace 3513..3525 -| | | | | | | | | | | | WhiteSpace 3513..3525 " " -| | | | | | | | | | Statement 3525..3536 -| | | | | | | | | | | AssignStatement 3525..3535 -| | | | | | | | | | | | Expression 3525..3528 -| | | | | | | | | | | | | ComponentIdentifier 3525..3527 -| | | | | | | | | | | | | | Identifier 3525..3527 -| | | | | | | | | | | | | | | Identifier 3525..3527 "e2" -| | | | | | | | | | | | | WhiteSpace 3527..3528 -| | | | | | | | | | | | | | WhiteSpace 3527..3528 -| | | | | | | | | | | | | | | WhiteSpace 3527..3528 " " -| | | | | | | | | | | | Assign 3528..3529 -| | | | | | | | | | | | | Assign 3528..3529 "=" -| | | | | | | | | | | | WhiteSpace 3529..3530 -| | | | | | | | | | | | | WhiteSpace 3529..3530 -| | | | | | | | | | | | | | WhiteSpace 3529..3530 " " -| | | | | | | | | | | | Expression 3530..3535 -| | | | | | | | | | | | | Add 3530..3535 -| | | | | | | | | | | | | | Identifier 3530..3532 -| | | | | | | | | | | | | | | Identifier 3530..3532 -| | | | | | | | | | | | | | | | Identifier 3530..3532 "e2" -| | | | | | | | | | | | | | Add 3532..3533 -| | | | | | | | | | | | | | | Add 3532..3533 "+" -| | | | | | | | | | | | | | Identifier 3533..3535 -| | | | | | | | | | | | | | | Identifier 3533..3535 -| | | | | | | | | | | | | | | | Identifier 3533..3535 "e2" -| | | | | | | | | | | Semicolon 3535..3536 -| | | | | | | | | | | | Semicolon 3535..3536 ";" -| | | | | | | | | | EndLine 3536..3537 -| | | | | | | | | | | EndLine 3536..3537 -| | | | | | | | | | | | EndLine 3536..3537 "\n" -| | | | | | | | | | WhiteSpace 3537..3545 -| | | | | | | | | | | WhiteSpace 3537..3545 -| | | | | | | | | | | | WhiteSpace 3537..3545 " " -| | | | | | | | | RCurly 3545..3546 -| | | | | | | | | | RCurly 3545..3546 "}" -| | | | | | | EndLine 3546..3547 -| | | | | | | | EndLine 3546..3547 -| | | | | | | | | EndLine 3546..3547 "\n" -| | | | | | | WhiteSpace 3547..3551 -| | | | | | | | WhiteSpace 3547..3551 -| | | | | | | | | WhiteSpace 3547..3551 " " -| | | | | | | EndLine 3551..3552 -| | | | | | | | EndLine 3551..3552 -| | | | | | | | | EndLine 3551..3552 "\n" -| | | | | | | WhiteSpace 3552..3560 -| | | | | | | | WhiteSpace 3552..3560 -| | | | | | | | | WhiteSpace 3552..3560 " " -| | | | | | | CommentLine 3560..3578 -| | | | | | | | CommentLine 3560..3578 -| | | | | | | | | CommentLine 3560..3578 "// Ensure the sum;" -| | | | | | | EndLine 3578..3579 -| | | | | | | | EndLine 3578..3579 -| | | | | | | | | EndLine 3578..3579 "\n" -| | | | | | | WhiteSpace 3579..3583 -| | | | | | | | WhiteSpace 3579..3583 -| | | | | | | | | WhiteSpace 3579..3583 " " -| | | | | | | EndLine 3583..3584 -| | | | | | | | EndLine 3583..3584 -| | | | | | | | | EndLine 3583..3584 "\n" -| | | | | | | WhiteSpace 3584..3592 -| | | | | | | | WhiteSpace 3584..3592 -| | | | | | | | | WhiteSpace 3584..3592 " " -| | | | | | | Statement 3592..3605 -| | | | | | | | AssignStatement 3592..3604 -| | | | | | | | | Expression 3592..3596 -| | | | | | | | | | ComponentIdentifier 3592..3595 -| | | | | | | | | | | Identifier 3592..3595 -| | | | | | | | | | | | Identifier 3592..3595 "lin" -| | | | | | | | | | WhiteSpace 3595..3596 -| | | | | | | | | | | WhiteSpace 3595..3596 -| | | | | | | | | | | | WhiteSpace 3595..3596 " " -| | | | | | | | | EqualSignal 3596..3599 -| | | | | | | | | | EqualSignal 3596..3599 "===" -| | | | | | | | | WhiteSpace 3599..3600 -| | | | | | | | | | WhiteSpace 3599..3600 -| | | | | | | | | | | WhiteSpace 3599..3600 " " -| | | | | | | | | Expression 3600..3604 -| | | | | | | | | | Identifier 3600..3604 -| | | | | | | | | | | Identifier 3600..3604 -| | | | | | | | | | | | Identifier 3600..3604 "lout" -| | | | | | | | Semicolon 3604..3605 -| | | | | | | | | Semicolon 3604..3605 ";" -| | | | | | | EndLine 3605..3606 -| | | | | | | | EndLine 3605..3606 -| | | | | | | | | EndLine 3605..3606 "\n" -| | | | | | | WhiteSpace 3606..3610 -| | | | | | | | WhiteSpace 3606..3610 -| | | | | | | | | WhiteSpace 3606..3610 " " -| | | | | | RCurly 3610..3611 -| | | | | | | RCurly 3610..3611 "}" -| | | | EndLine 3611..3612 -| | | | | EndLine 3611..3612 -| | | | | | EndLine 3611..3612 "\n" -| | | Error 3612..3637 -| | | | Error 3612..3637 -| | | | | Error 3612..3637 "expect RCurly but got EOF" +| | | | OutputSignalDecl 1840..1863 +| | | | | SignalHeader 1840..1854 +| | | | | | SignalKw 1840..1846 +| | | | | | | SignalKw 1840..1846 "signal" +| | | | | | WhiteSpace 1846..1847 +| | | | | | | WhiteSpace 1846..1847 " " +| | | | | | OutputKw 1847..1853 +| | | | | | | OutputKw 1847..1853 "output" +| | | | | | WhiteSpace 1853..1854 +| | | | | | | WhiteSpace 1853..1854 " " +| | | | | SignalIdentifier 1854..1863 +| | | | | | Identifier 1854..1857 +| | | | | | | Identifier 1854..1857 "out" +| | | | | | LBracket 1857..1858 +| | | | | | | LBracket 1857..1858 "[" +| | | | | | Expression 1858..1862 +| | | | | | | ExpressionAtom 1858..1862 +| | | | | | | | Identifier 1858..1862 +| | | | | | | | | Identifier 1858..1862 "nout" +| | | | | | RBracket 1862..1863 +| | | | | | | RBracket 1862..1863 "]" +| | | | Semicolon 1863..1864 +| | | | | Semicolon 1863..1864 ";" +| | | | EndLine 1864..1866 +| | | | | EndLine 1864..1866 "\r\n" +| | | | EndLine 1866..1868 +| | | | | EndLine 1866..1868 "\r\n" +| | | | WhiteSpace 1868..1872 +| | | | | WhiteSpace 1868..1872 " " +| | | | VarDecl 1872..1883 +| | | | | VarKw 1872..1875 +| | | | | | VarKw 1872..1875 "var" +| | | | | WhiteSpace 1875..1876 +| | | | | | WhiteSpace 1875..1876 " " +| | | | | VarIdentifier 1876..1880 +| | | | | | Identifier 1876..1879 +| | | | | | | Identifier 1876..1879 "lin" +| | | | | | WhiteSpace 1879..1880 +| | | | | | | WhiteSpace 1879..1880 " " +| | | | | Assign 1880..1881 +| | | | | | Assign 1880..1881 "=" +| | | | | WhiteSpace 1881..1882 +| | | | | | WhiteSpace 1881..1882 " " +| | | | | Expression 1882..1883 +| | | | | | ExpressionAtom 1882..1883 +| | | | | | | Number 1882..1883 +| | | | | | | | Number 1882..1883 "0" +| | | | Semicolon 1883..1884 +| | | | | Semicolon 1883..1884 ";" +| | | | EndLine 1884..1886 +| | | | | EndLine 1884..1886 "\r\n" +| | | | WhiteSpace 1886..1890 +| | | | | WhiteSpace 1886..1890 " " +| | | | VarDecl 1890..1902 +| | | | | VarKw 1890..1893 +| | | | | | VarKw 1890..1893 "var" +| | | | | WhiteSpace 1893..1894 +| | | | | | WhiteSpace 1893..1894 " " +| | | | | VarIdentifier 1894..1899 +| | | | | | Identifier 1894..1898 +| | | | | | | Identifier 1894..1898 "lout" +| | | | | | WhiteSpace 1898..1899 +| | | | | | | WhiteSpace 1898..1899 " " +| | | | | Assign 1899..1900 +| | | | | | Assign 1899..1900 "=" +| | | | | WhiteSpace 1900..1901 +| | | | | | WhiteSpace 1900..1901 " " +| | | | | Expression 1901..1902 +| | | | | | ExpressionAtom 1901..1902 +| | | | | | | Number 1901..1902 +| | | | | | | | Number 1901..1902 "0" +| | | | Semicolon 1902..1903 +| | | | | Semicolon 1902..1903 ";" +| | | | EndLine 1903..1905 +| | | | | EndLine 1903..1905 "\r\n" +| | | | EndLine 1905..1907 +| | | | | EndLine 1905..1907 "\r\n" +| | | | WhiteSpace 1907..1911 +| | | | | WhiteSpace 1907..1911 " " +| | | | VarDecl 1911..1916 +| | | | | VarKw 1911..1914 +| | | | | | VarKw 1911..1914 "var" +| | | | | WhiteSpace 1914..1915 +| | | | | | WhiteSpace 1914..1915 " " +| | | | | VarIdentifier 1915..1916 +| | | | | | Identifier 1915..1916 +| | | | | | | Identifier 1915..1916 "k" +| | | | Semicolon 1916..1917 +| | | | | Semicolon 1916..1917 ";" +| | | | EndLine 1917..1919 +| | | | | EndLine 1917..1919 "\r\n" +| | | | WhiteSpace 1919..1923 +| | | | | WhiteSpace 1919..1923 " " +| | | | VarDecl 1923..1928 +| | | | | VarKw 1923..1926 +| | | | | | VarKw 1923..1926 "var" +| | | | | WhiteSpace 1926..1927 +| | | | | | WhiteSpace 1926..1927 " " +| | | | | VarIdentifier 1927..1928 +| | | | | | Identifier 1927..1928 +| | | | | | | Identifier 1927..1928 "j" +| | | | Semicolon 1928..1929 +| | | | | Semicolon 1928..1929 ";" +| | | | EndLine 1929..1931 +| | | | | EndLine 1929..1931 "\r\n" +| | | | EndLine 1931..1933 +| | | | | EndLine 1931..1933 "\r\n" +| | | | WhiteSpace 1933..1937 +| | | | | WhiteSpace 1933..1937 " " +| | | | VarDecl 1937..1943 +| | | | | VarKw 1937..1940 +| | | | | | VarKw 1937..1940 "var" +| | | | | WhiteSpace 1940..1941 +| | | | | | WhiteSpace 1940..1941 " " +| | | | | VarIdentifier 1941..1943 +| | | | | | Identifier 1941..1943 +| | | | | | | Identifier 1941..1943 "e2" +| | | | Semicolon 1943..1944 +| | | | | Semicolon 1943..1944 ";" +| | | | EndLine 1944..1946 +| | | | | EndLine 1944..1946 "\r\n" +| | | | EndLine 1946..1948 +| | | | | EndLine 1946..1948 "\r\n" +| | | | WhiteSpace 1948..1952 +| | | | | WhiteSpace 1948..1952 " " +| | | | Statement 1952..1959 +| | | | | AssignStatement 1952..1958 +| | | | | | Expression 1952..1955 +| | | | | | | ComponentIdentifier 1952..1954 +| | | | | | | | Identifier 1952..1954 +| | | | | | | | | Identifier 1952..1954 "e2" +| | | | | | | WhiteSpace 1954..1955 +| | | | | | | | WhiteSpace 1954..1955 " " +| | | | | | Assign 1955..1956 +| | | | | | | Assign 1955..1956 "=" +| | | | | | WhiteSpace 1956..1957 +| | | | | | | WhiteSpace 1956..1957 " " +| | | | | | Expression 1957..1958 +| | | | | | | ExpressionAtom 1957..1958 +| | | | | | | | Number 1957..1958 +| | | | | | | | | Number 1957..1958 "1" +| | | | | Semicolon 1958..1959 +| | | | | | Semicolon 1958..1959 ";" +| | | | EndLine 1959..1961 +| | | | | EndLine 1959..1961 "\r\n" +| | | | WhiteSpace 1961..1965 +| | | | | WhiteSpace 1961..1965 " " +| | | | Statement 1965..2481 +| | | | | ForLoop 1965..2481 +| | | | | | ForKw 1965..1968 +| | | | | | | ForKw 1965..1968 "for" +| | | | | | WhiteSpace 1968..1969 +| | | | | | | WhiteSpace 1968..1969 " " +| | | | | | LParen 1969..1970 +| | | | | | | LParen 1969..1970 "(" +| | | | | | AssignStatement 1970..1973 +| | | | | | | Expression 1970..1971 +| | | | | | | | ComponentIdentifier 1970..1971 +| | | | | | | | | Identifier 1970..1971 +| | | | | | | | | | Identifier 1970..1971 "k" +| | | | | | | Assign 1971..1972 +| | | | | | | | Assign 1971..1972 "=" +| | | | | | | Expression 1972..1973 +| | | | | | | | ExpressionAtom 1972..1973 +| | | | | | | | | Number 1972..1973 +| | | | | | | | | | Number 1972..1973 "0" +| | | | | | Semicolon 1973..1974 +| | | | | | | Semicolon 1973..1974 ";" +| | | | | | WhiteSpace 1974..1975 +| | | | | | | WhiteSpace 1974..1975 " " +| | | | | | Expression 1975..1978 +| | | | | | | LessThan 1975..1978 +| | | | | | | | ExpressionAtom 1975..1976 +| | | | | | | | | Identifier 1975..1976 +| | | | | | | | | | Identifier 1975..1976 "k" +| | | | | | | | LessThan 1976..1977 +| | | | | | | | | LessThan 1976..1977 "<" +| | | | | | | | ExpressionAtom 1977..1978 +| | | | | | | | | Identifier 1977..1978 +| | | | | | | | | | Identifier 1977..1978 "n" +| | | | | | Semicolon 1978..1979 +| | | | | | | Semicolon 1978..1979 ";" +| | | | | | WhiteSpace 1979..1980 +| | | | | | | WhiteSpace 1979..1980 " " +| | | | | | AssignStatement 1980..1983 +| | | | | | | Expression 1980..1981 +| | | | | | | | ComponentIdentifier 1980..1981 +| | | | | | | | | Identifier 1980..1981 +| | | | | | | | | | Identifier 1980..1981 "k" +| | | | | | | UnitInc 1981..1983 +| | | | | | | | UnitInc 1981..1983 "++" +| | | | | | RParen 1983..1984 +| | | | | | | RParen 1983..1984 ")" +| | | | | | WhiteSpace 1984..1985 +| | | | | | | WhiteSpace 1984..1985 " " +| | | | | | Statement 1985..2481 +| | | | | | | Block 1985..2481 +| | | | | | | | LCurly 1985..1986 +| | | | | | | | | LCurly 1985..1986 "{" +| | | | | | | | EndLine 1986..1988 +| | | | | | | | | EndLine 1986..1988 "\r\n" +| | | | | | | | WhiteSpace 1988..1996 +| | | | | | | | | WhiteSpace 1988..1996 " " +| | | | | | | | StatementList 1996..2480 +| | | | | | | | | Statement 1996..2065 +| | | | | | | | | | ForLoop 1996..2065 +| | | | | | | | | | | ForKw 1996..1999 +| | | | | | | | | | | | ForKw 1996..1999 "for" +| | | | | | | | | | | WhiteSpace 1999..2000 +| | | | | | | | | | | | WhiteSpace 1999..2000 " " +| | | | | | | | | | | LParen 2000..2001 +| | | | | | | | | | | | LParen 2000..2001 "(" +| | | | | | | | | | | AssignStatement 2001..2004 +| | | | | | | | | | | | Expression 2001..2002 +| | | | | | | | | | | | | ComponentIdentifier 2001..2002 +| | | | | | | | | | | | | | Identifier 2001..2002 +| | | | | | | | | | | | | | | Identifier 2001..2002 "j" +| | | | | | | | | | | | Assign 2002..2003 +| | | | | | | | | | | | | Assign 2002..2003 "=" +| | | | | | | | | | | | Expression 2003..2004 +| | | | | | | | | | | | | ExpressionAtom 2003..2004 +| | | | | | | | | | | | | | Number 2003..2004 +| | | | | | | | | | | | | | | Number 2003..2004 "0" +| | | | | | | | | | | Semicolon 2004..2005 +| | | | | | | | | | | | Semicolon 2004..2005 ";" +| | | | | | | | | | | WhiteSpace 2005..2006 +| | | | | | | | | | | | WhiteSpace 2005..2006 " " +| | | | | | | | | | | Expression 2006..2011 +| | | | | | | | | | | | LessThan 2006..2011 +| | | | | | | | | | | | | ExpressionAtom 2006..2007 +| | | | | | | | | | | | | | Identifier 2006..2007 +| | | | | | | | | | | | | | | Identifier 2006..2007 "j" +| | | | | | | | | | | | | LessThan 2007..2008 +| | | | | | | | | | | | | | LessThan 2007..2008 "<" +| | | | | | | | | | | | | ExpressionAtom 2008..2011 +| | | | | | | | | | | | | | Identifier 2008..2011 +| | | | | | | | | | | | | | | Identifier 2008..2011 "ops" +| | | | | | | | | | | Semicolon 2011..2012 +| | | | | | | | | | | | Semicolon 2011..2012 ";" +| | | | | | | | | | | WhiteSpace 2012..2013 +| | | | | | | | | | | | WhiteSpace 2012..2013 " " +| | | | | | | | | | | AssignStatement 2013..2016 +| | | | | | | | | | | | Expression 2013..2014 +| | | | | | | | | | | | | ComponentIdentifier 2013..2014 +| | | | | | | | | | | | | | Identifier 2013..2014 +| | | | | | | | | | | | | | | Identifier 2013..2014 "j" +| | | | | | | | | | | | UnitInc 2014..2016 +| | | | | | | | | | | | | UnitInc 2014..2016 "++" +| | | | | | | | | | | RParen 2016..2017 +| | | | | | | | | | | | RParen 2016..2017 ")" +| | | | | | | | | | | WhiteSpace 2017..2018 +| | | | | | | | | | | | WhiteSpace 2017..2018 " " +| | | | | | | | | | | Statement 2018..2065 +| | | | | | | | | | | | Block 2018..2065 +| | | | | | | | | | | | | LCurly 2018..2019 +| | | | | | | | | | | | | | LCurly 2018..2019 "{" +| | | | | | | | | | | | | EndLine 2019..2021 +| | | | | | | | | | | | | | EndLine 2019..2021 "\r\n" +| | | | | | | | | | | | | WhiteSpace 2021..2033 +| | | | | | | | | | | | | | WhiteSpace 2021..2033 " " +| | | | | | | | | | | | | StatementList 2033..2064 +| | | | | | | | | | | | | | Statement 2033..2054 +| | | | | | | | | | | | | | | AssignStatement 2033..2053 +| | | | | | | | | | | | | | | | Expression 2033..2037 +| | | | | | | | | | | | | | | | | ComponentIdentifier 2033..2036 +| | | | | | | | | | | | | | | | | | Identifier 2033..2036 +| | | | | | | | | | | | | | | | | | | Identifier 2033..2036 "lin" +| | | | | | | | | | | | | | | | | WhiteSpace 2036..2037 +| | | | | | | | | | | | | | | | | | WhiteSpace 2036..2037 " " +| | | | | | | | | | | | | | | | AddAssign 2037..2039 +| | | | | | | | | | | | | | | | | AddAssign 2037..2039 "+=" +| | | | | | | | | | | | | | | | WhiteSpace 2039..2040 +| | | | | | | | | | | | | | | | | WhiteSpace 2039..2040 " " +| | | | | | | | | | | | | | | | Expression 2040..2053 +| | | | | | | | | | | | | | | | | Mul 2040..2053 +| | | | | | | | | | | | | | | | | | ArrayQuery 2040..2048 +| | | | | | | | | | | | | | | | | | | ArrayQuery 2040..2045 +| | | | | | | | | | | | | | | | | | | | ExpressionAtom 2040..2042 +| | | | | | | | | | | | | | | | | | | | | Identifier 2040..2042 +| | | | | | | | | | | | | | | | | | | | | | Identifier 2040..2042 "in" +| | | | | | | | | | | | | | | | | | | | LBracket 2042..2043 +| | | | | | | | | | | | | | | | | | | | | LBracket 2042..2043 "[" +| | | | | | | | | | | | | | | | | | | | ExpressionAtom 2043..2044 +| | | | | | | | | | | | | | | | | | | | | Identifier 2043..2044 +| | | | | | | | | | | | | | | | | | | | | | Identifier 2043..2044 "j" +| | | | | | | | | | | | | | | | | | | | RBracket 2044..2045 +| | | | | | | | | | | | | | | | | | | | | RBracket 2044..2045 "]" +| | | | | | | | | | | | | | | | | | | LBracket 2045..2046 +| | | | | | | | | | | | | | | | | | | | LBracket 2045..2046 "[" +| | | | | | | | | | | | | | | | | | | ExpressionAtom 2046..2047 +| | | | | | | | | | | | | | | | | | | | Identifier 2046..2047 +| | | | | | | | | | | | | | | | | | | | | Identifier 2046..2047 "k" +| | | | | | | | | | | | | | | | | | | RBracket 2047..2048 +| | | | | | | | | | | | | | | | | | | | RBracket 2047..2048 "]" +| | | | | | | | | | | | | | | | | | WhiteSpace 2048..2049 +| | | | | | | | | | | | | | | | | | | WhiteSpace 2048..2049 " " +| | | | | | | | | | | | | | | | | | Mul 2049..2050 +| | | | | | | | | | | | | | | | | | | Mul 2049..2050 "*" +| | | | | | | | | | | | | | | | | | WhiteSpace 2050..2051 +| | | | | | | | | | | | | | | | | | | WhiteSpace 2050..2051 " " +| | | | | | | | | | | | | | | | | | ExpressionAtom 2051..2053 +| | | | | | | | | | | | | | | | | | | Identifier 2051..2053 +| | | | | | | | | | | | | | | | | | | | Identifier 2051..2053 "e2" +| | | | | | | | | | | | | | | Semicolon 2053..2054 +| | | | | | | | | | | | | | | | Semicolon 2053..2054 ";" +| | | | | | | | | | | | | | EndLine 2054..2056 +| | | | | | | | | | | | | | | EndLine 2054..2056 "\r\n" +| | | | | | | | | | | | | | WhiteSpace 2056..2064 +| | | | | | | | | | | | | | | WhiteSpace 2056..2064 " " +| | | | | | | | | | | | | RCurly 2064..2065 +| | | | | | | | | | | | | | RCurly 2064..2065 "}" +| | | | | | | | | EndLine 2065..2067 +| | | | | | | | | | EndLine 2065..2067 "\r\n" +| | | | | | | | | WhiteSpace 2067..2075 +| | | | | | | | | | WhiteSpace 2067..2075 " " +| | | | | | | | | Statement 2075..2088 +| | | | | | | | | | AssignStatement 2075..2087 +| | | | | | | | | | | Expression 2075..2078 +| | | | | | | | | | | | ComponentIdentifier 2075..2077 +| | | | | | | | | | | | | Identifier 2075..2077 +| | | | | | | | | | | | | | Identifier 2075..2077 "e2" +| | | | | | | | | | | | WhiteSpace 2077..2078 +| | | | | | | | | | | | | WhiteSpace 2077..2078 " " +| | | | | | | | | | | Assign 2078..2079 +| | | | | | | | | | | | Assign 2078..2079 "=" +| | | | | | | | | | | WhiteSpace 2079..2080 +| | | | | | | | | | | | WhiteSpace 2079..2080 " " +| | | | | | | | | | | Expression 2080..2087 +| | | | | | | | | | | | Add 2080..2087 +| | | | | | | | | | | | | ExpressionAtom 2080..2082 +| | | | | | | | | | | | | | Identifier 2080..2082 +| | | | | | | | | | | | | | | Identifier 2080..2082 "e2" +| | | | | | | | | | | | | WhiteSpace 2082..2083 +| | | | | | | | | | | | | | WhiteSpace 2082..2083 " " +| | | | | | | | | | | | | Add 2083..2084 +| | | | | | | | | | | | | | Add 2083..2084 "+" +| | | | | | | | | | | | | WhiteSpace 2084..2085 +| | | | | | | | | | | | | | WhiteSpace 2084..2085 " " +| | | | | | | | | | | | | ExpressionAtom 2085..2087 +| | | | | | | | | | | | | | Identifier 2085..2087 +| | | | | | | | | | | | | | | Identifier 2085..2087 "e2" +| | | | | | | | | | Semicolon 2087..2088 +| | | | | | | | | | | Semicolon 2087..2088 ";" +| | | | | | | | | EndLine 2088..2090 +| | | | | | | | | | EndLine 2088..2090 "\r\n" +| | | | | | | | | WhiteSpace 2090..2094 +| | | | | | | | | | WhiteSpace 2090..2094 " " +| | | | | | | | | EndLine 2094..2096 +| | | | | | | | | | EndLine 2094..2096 "\r\n" +| | | | | | | | | WhiteSpace 2096..2104 +| | | | | | | | | | WhiteSpace 2096..2104 " " +| | | | | | | | | Statement 2104..2111 +| | | | | | | | | | AssignStatement 2104..2110 +| | | | | | | | | | | Expression 2104..2107 +| | | | | | | | | | | | ComponentIdentifier 2104..2106 +| | | | | | | | | | | | | Identifier 2104..2106 +| | | | | | | | | | | | | | Identifier 2104..2106 "e2" +| | | | | | | | | | | | WhiteSpace 2106..2107 +| | | | | | | | | | | | | WhiteSpace 2106..2107 " " +| | | | | | | | | | | Assign 2107..2108 +| | | | | | | | | | | | Assign 2107..2108 "=" +| | | | | | | | | | | WhiteSpace 2108..2109 +| | | | | | | | | | | | WhiteSpace 2108..2109 " " +| | | | | | | | | | | Expression 2109..2110 +| | | | | | | | | | | | ExpressionAtom 2109..2110 +| | | | | | | | | | | | | Number 2109..2110 +| | | | | | | | | | | | | | Number 2109..2110 "1" +| | | | | | | | | | Semicolon 2110..2111 +| | | | | | | | | | | Semicolon 2110..2111 ";" +| | | | | | | | | EndLine 2111..2113 +| | | | | | | | | | EndLine 2111..2113 "\r\n" +| | | | | | | | | WhiteSpace 2113..2121 +| | | | | | | | | | WhiteSpace 2113..2121 " " +| | | | | | | | | Statement 2121..2411 +| | | | | | | | | | ForLoop 2121..2411 +| | | | | | | | | | | ForKw 2121..2124 +| | | | | | | | | | | | ForKw 2121..2124 "for" +| | | | | | | | | | | WhiteSpace 2124..2125 +| | | | | | | | | | | | WhiteSpace 2124..2125 " " +| | | | | | | | | | | LParen 2125..2126 +| | | | | | | | | | | | LParen 2125..2126 "(" +| | | | | | | | | | | AssignStatement 2126..2129 +| | | | | | | | | | | | Expression 2126..2127 +| | | | | | | | | | | | | ComponentIdentifier 2126..2127 +| | | | | | | | | | | | | | Identifier 2126..2127 +| | | | | | | | | | | | | | | Identifier 2126..2127 "k" +| | | | | | | | | | | | Assign 2127..2128 +| | | | | | | | | | | | | Assign 2127..2128 "=" +| | | | | | | | | | | | Expression 2128..2129 +| | | | | | | | | | | | | ExpressionAtom 2128..2129 +| | | | | | | | | | | | | | Number 2128..2129 +| | | | | | | | | | | | | | | Number 2128..2129 "0" +| | | | | | | | | | | Semicolon 2129..2130 +| | | | | | | | | | | | Semicolon 2129..2130 ";" +| | | | | | | | | | | WhiteSpace 2130..2131 +| | | | | | | | | | | | WhiteSpace 2130..2131 " " +| | | | | | | | | | | Expression 2131..2137 +| | | | | | | | | | | | LessThan 2131..2137 +| | | | | | | | | | | | | ExpressionAtom 2131..2132 +| | | | | | | | | | | | | | Identifier 2131..2132 +| | | | | | | | | | | | | | | Identifier 2131..2132 "k" +| | | | | | | | | | | | | LessThan 2132..2133 +| | | | | | | | | | | | | | LessThan 2132..2133 "<" +| | | | | | | | | | | | | ExpressionAtom 2133..2137 +| | | | | | | | | | | | | | Identifier 2133..2137 +| | | | | | | | | | | | | | | Identifier 2133..2137 "nout" +| | | | | | | | | | | Semicolon 2137..2138 +| | | | | | | | | | | | Semicolon 2137..2138 ";" +| | | | | | | | | | | WhiteSpace 2138..2139 +| | | | | | | | | | | | WhiteSpace 2138..2139 " " +| | | | | | | | | | | AssignStatement 2139..2142 +| | | | | | | | | | | | Expression 2139..2140 +| | | | | | | | | | | | | ComponentIdentifier 2139..2140 +| | | | | | | | | | | | | | Identifier 2139..2140 +| | | | | | | | | | | | | | | Identifier 2139..2140 "k" +| | | | | | | | | | | | UnitInc 2140..2142 +| | | | | | | | | | | | | UnitInc 2140..2142 "++" +| | | | | | | | | | | RParen 2142..2143 +| | | | | | | | | | | | RParen 2142..2143 ")" +| | | | | | | | | | | WhiteSpace 2143..2144 +| | | | | | | | | | | | WhiteSpace 2143..2144 " " +| | | | | | | | | | | Statement 2144..2411 +| | | | | | | | | | | | Block 2144..2411 +| | | | | | | | | | | | | LCurly 2144..2145 +| | | | | | | | | | | | | | LCurly 2144..2145 "{" +| | | | | | | | | | | | | EndLine 2145..2147 +| | | | | | | | | | | | | | EndLine 2145..2147 "\r\n" +| | | | | | | | | | | | | WhiteSpace 2147..2159 +| | | | | | | | | | | | | | WhiteSpace 2147..2159 " " +| | | | | | | | | | | | | StatementList 2159..2410 +| | | | | | | | | | | | | | Statement 2159..2185 +| | | | | | | | | | | | | | | AssignStatement 2159..2184 +| | | | | | | | | | | | | | | | Expression 2159..2166 +| | | | | | | | | | | | | | | | | ComponentIdentifier 2159..2162 +| | | | | | | | | | | | | | | | | | Identifier 2159..2162 +| | | | | | | | | | | | | | | | | | | Identifier 2159..2162 "out" +| | | | | | | | | | | | | | | | | LBracket 2162..2163 +| | | | | | | | | | | | | | | | | | LBracket 2162..2163 "[" +| | | | | | | | | | | | | | | | | Expression 2163..2164 +| | | | | | | | | | | | | | | | | | ExpressionAtom 2163..2164 +| | | | | | | | | | | | | | | | | | | Identifier 2163..2164 +| | | | | | | | | | | | | | | | | | | | Identifier 2163..2164 "k" +| | | | | | | | | | | | | | | | | RBracket 2164..2165 +| | | | | | | | | | | | | | | | | | RBracket 2164..2165 "]" +| | | | | | | | | | | | | | | | | WhiteSpace 2165..2166 +| | | | | | | | | | | | | | | | | | WhiteSpace 2165..2166 " " +| | | | | | | | | | | | | | | | RAssignSignal 2166..2169 +| | | | | | | | | | | | | | | | | RAssignSignal 2166..2169 "<--" +| | | | | | | | | | | | | | | | WhiteSpace 2169..2170 +| | | | | | | | | | | | | | | | | WhiteSpace 2169..2170 " " +| | | | | | | | | | | | | | | | Expression 2170..2184 +| | | | | | | | | | | | | | | | | BitAnd 2170..2184 +| | | | | | | | | | | | | | | | | | Tuple 2170..2180 +| | | | | | | | | | | | | | | | | | | LParen 2170..2171 +| | | | | | | | | | | | | | | | | | | | LParen 2170..2171 "(" +| | | | | | | | | | | | | | | | | | | ShiftR 2171..2179 +| | | | | | | | | | | | | | | | | | | | ExpressionAtom 2171..2174 +| | | | | | | | | | | | | | | | | | | | | Identifier 2171..2174 +| | | | | | | | | | | | | | | | | | | | | | Identifier 2171..2174 "lin" +| | | | | | | | | | | | | | | | | | | | WhiteSpace 2174..2175 +| | | | | | | | | | | | | | | | | | | | | WhiteSpace 2174..2175 " " +| | | | | | | | | | | | | | | | | | | | ShiftR 2175..2177 +| | | | | | | | | | | | | | | | | | | | | ShiftR 2175..2177 ">>" +| | | | | | | | | | | | | | | | | | | | WhiteSpace 2177..2178 +| | | | | | | | | | | | | | | | | | | | | WhiteSpace 2177..2178 " " +| | | | | | | | | | | | | | | | | | | | ExpressionAtom 2178..2179 +| | | | | | | | | | | | | | | | | | | | | Identifier 2178..2179 +| | | | | | | | | | | | | | | | | | | | | | Identifier 2178..2179 "k" +| | | | | | | | | | | | | | | | | | | RParen 2179..2180 +| | | | | | | | | | | | | | | | | | | | RParen 2179..2180 ")" +| | | | | | | | | | | | | | | | | | WhiteSpace 2180..2181 +| | | | | | | | | | | | | | | | | | | WhiteSpace 2180..2181 " " +| | | | | | | | | | | | | | | | | | BitAnd 2181..2182 +| | | | | | | | | | | | | | | | | | | BitAnd 2181..2182 "&" +| | | | | | | | | | | | | | | | | | WhiteSpace 2182..2183 +| | | | | | | | | | | | | | | | | | | WhiteSpace 2182..2183 " " +| | | | | | | | | | | | | | | | | | ExpressionAtom 2183..2184 +| | | | | | | | | | | | | | | | | | | Number 2183..2184 +| | | | | | | | | | | | | | | | | | | | Number 2183..2184 "1" +| | | | | | | | | | | | | | | Semicolon 2184..2185 +| | | | | | | | | | | | | | | | Semicolon 2184..2185 ";" +| | | | | | | | | | | | | | EndLine 2185..2187 +| | | | | | | | | | | | | | | EndLine 2185..2187 "\r\n" +| | | | | | | | | | | | | | WhiteSpace 2187..2191 +| | | | | | | | | | | | | | | WhiteSpace 2187..2191 " " +| | | | | | | | | | | | | | EndLine 2191..2193 +| | | | | | | | | | | | | | | EndLine 2191..2193 "\r\n" +| | | | | | | | | | | | | | WhiteSpace 2193..2205 +| | | | | | | | | | | | | | | WhiteSpace 2193..2205 " " +| | | | | | | | | | | | | | CommentLine 2205..2228 +| | | | | | | | | | | | | | | CommentLine 2205..2228 "// Ensure out is binary" +| | | | | | | | | | | | | | EndLine 2228..2230 +| | | | | | | | | | | | | | | EndLine 2228..2230 "\r\n" +| | | | | | | | | | | | | | WhiteSpace 2230..2242 +| | | | | | | | | | | | | | | WhiteSpace 2230..2242 " " +| | | | | | | | | | | | | | Statement 2242..2277 +| | | | | | | | | | | | | | | Error 2242..2249 +| | | | | | | | | | | | | | | | Expression 2242..2249 +| | | | | | | | | | | | | | | | | ComponentIdentifier 2242..2245 +| | | | | | | | | | | | | | | | | | Identifier 2242..2245 +| | | | | | | | | | | | | | | | | | | Identifier 2242..2245 "out" +| | | | | | | | | | | | | | | | | LBracket 2245..2246 +| | | | | | | | | | | | | | | | | | LBracket 2245..2246 "[" +| | | | | | | | | | | | | | | | | Expression 2246..2247 +| | | | | | | | | | | | | | | | | | ExpressionAtom 2246..2247 +| | | | | | | | | | | | | | | | | | | Identifier 2246..2247 +| | | | | | | | | | | | | | | | | | | | Identifier 2246..2247 "k" +| | | | | | | | | | | | | | | | | RBracket 2247..2248 +| | | | | | | | | | | | | | | | | | RBracket 2247..2248 "]" +| | | | | | | | | | | | | | | | | WhiteSpace 2248..2249 +| | | | | | | | | | | | | | | | | | WhiteSpace 2248..2249 " " +| | | | | | | | | | | | | | | Error 2249..2277 +| | | | | | | | | | | | | | | | Error 2249..2277 +| | | | | | | | | | | | | | | | | Error 2249..2277 "expect Semicolon but got Mul" +| | | | | | | | | | | | | | Statement 2277..2310 +| | | | | | | | | | | | | | | Error 2277..2279 +| | | | | | | | | | | | | | | | Expression 2277..2278 +| | | | | | | | | | | | | | | | | Error 2277..2278 +| | | | | | | | | | | | | | | | | | Mul 2277..2278 +| | | | | | | | | | | | | | | | | | | Mul 2277..2278 "*" +| | | | | | | | | | | | | | | | WhiteSpace 2278..2279 +| | | | | | | | | | | | | | | | | WhiteSpace 2278..2279 " " +| | | | | | | | | | | | | | | Error 2279..2310 +| | | | | | | | | | | | | | | | Error 2279..2310 +| | | | | | | | | | | | | | | | | Error 2279..2310 "expect Semicolon but got LParen" +| | | | | | | | | | | | | | Statement 2310..2329 +| | | | | | | | | | | | | | | Error 2310..2328 +| | | | | | | | | | | | | | | | Expression 2310..2328 +| | | | | | | | | | | | | | | | | EqualSignal 2310..2328 +| | | | | | | | | | | | | | | | | | Tuple 2310..2322 +| | | | | | | | | | | | | | | | | | | LParen 2310..2311 +| | | | | | | | | | | | | | | | | | | | LParen 2310..2311 "(" +| | | | | | | | | | | | | | | | | | | Sub 2311..2321 +| | | | | | | | | | | | | | | | | | | | ArrayQuery 2311..2317 +| | | | | | | | | | | | | | | | | | | | | ExpressionAtom 2311..2314 +| | | | | | | | | | | | | | | | | | | | | | Identifier 2311..2314 +| | | | | | | | | | | | | | | | | | | | | | | Identifier 2311..2314 "out" +| | | | | | | | | | | | | | | | | | | | | LBracket 2314..2315 +| | | | | | | | | | | | | | | | | | | | | | LBracket 2314..2315 "[" +| | | | | | | | | | | | | | | | | | | | | ExpressionAtom 2315..2316 +| | | | | | | | | | | | | | | | | | | | | | Identifier 2315..2316 +| | | | | | | | | | | | | | | | | | | | | | | Identifier 2315..2316 "k" +| | | | | | | | | | | | | | | | | | | | | RBracket 2316..2317 +| | | | | | | | | | | | | | | | | | | | | | RBracket 2316..2317 "]" +| | | | | | | | | | | | | | | | | | | | WhiteSpace 2317..2318 +| | | | | | | | | | | | | | | | | | | | | WhiteSpace 2317..2318 " " +| | | | | | | | | | | | | | | | | | | | Sub 2318..2319 +| | | | | | | | | | | | | | | | | | | | | Sub 2318..2319 "-" +| | | | | | | | | | | | | | | | | | | | WhiteSpace 2319..2320 +| | | | | | | | | | | | | | | | | | | | | WhiteSpace 2319..2320 " " +| | | | | | | | | | | | | | | | | | | | ExpressionAtom 2320..2321 +| | | | | | | | | | | | | | | | | | | | | Number 2320..2321 +| | | | | | | | | | | | | | | | | | | | | | Number 2320..2321 "1" +| | | | | | | | | | | | | | | | | | | RParen 2321..2322 +| | | | | | | | | | | | | | | | | | | | RParen 2321..2322 ")" +| | | | | | | | | | | | | | | | | | WhiteSpace 2322..2323 +| | | | | | | | | | | | | | | | | | | WhiteSpace 2322..2323 " " +| | | | | | | | | | | | | | | | | | EqualSignal 2323..2326 +| | | | | | | | | | | | | | | | | | | EqualSignal 2323..2326 "===" +| | | | | | | | | | | | | | | | | | WhiteSpace 2326..2327 +| | | | | | | | | | | | | | | | | | | WhiteSpace 2326..2327 " " +| | | | | | | | | | | | | | | | | | ExpressionAtom 2327..2328 +| | | | | | | | | | | | | | | | | | | Number 2327..2328 +| | | | | | | | | | | | | | | | | | | | Number 2327..2328 "0" +| | | | | | | | | | | | | | | Semicolon 2328..2329 +| | | | | | | | | | | | | | | | Semicolon 2328..2329 ";" +| | | | | | | | | | | | | | EndLine 2329..2331 +| | | | | | | | | | | | | | | EndLine 2329..2331 "\r\n" +| | | | | | | | | | | | | | WhiteSpace 2331..2335 +| | | | | | | | | | | | | | | WhiteSpace 2331..2335 " " +| | | | | | | | | | | | | | EndLine 2335..2337 +| | | | | | | | | | | | | | | EndLine 2335..2337 "\r\n" +| | | | | | | | | | | | | | WhiteSpace 2337..2349 +| | | | | | | | | | | | | | | WhiteSpace 2337..2349 " " +| | | | | | | | | | | | | | Statement 2349..2369 +| | | | | | | | | | | | | | | AssignStatement 2349..2368 +| | | | | | | | | | | | | | | | Expression 2349..2354 +| | | | | | | | | | | | | | | | | ComponentIdentifier 2349..2353 +| | | | | | | | | | | | | | | | | | Identifier 2349..2353 +| | | | | | | | | | | | | | | | | | | Identifier 2349..2353 "lout" +| | | | | | | | | | | | | | | | | WhiteSpace 2353..2354 +| | | | | | | | | | | | | | | | | | WhiteSpace 2353..2354 " " +| | | | | | | | | | | | | | | | AddAssign 2354..2356 +| | | | | | | | | | | | | | | | | AddAssign 2354..2356 "+=" +| | | | | | | | | | | | | | | | WhiteSpace 2356..2357 +| | | | | | | | | | | | | | | | | WhiteSpace 2356..2357 " " +| | | | | | | | | | | | | | | | Expression 2357..2368 +| | | | | | | | | | | | | | | | | Mul 2357..2368 +| | | | | | | | | | | | | | | | | | ArrayQuery 2357..2363 +| | | | | | | | | | | | | | | | | | | ExpressionAtom 2357..2360 +| | | | | | | | | | | | | | | | | | | | Identifier 2357..2360 +| | | | | | | | | | | | | | | | | | | | | Identifier 2357..2360 "out" +| | | | | | | | | | | | | | | | | | | LBracket 2360..2361 +| | | | | | | | | | | | | | | | | | | | LBracket 2360..2361 "[" +| | | | | | | | | | | | | | | | | | | ExpressionAtom 2361..2362 +| | | | | | | | | | | | | | | | | | | | Identifier 2361..2362 +| | | | | | | | | | | | | | | | | | | | | Identifier 2361..2362 "k" +| | | | | | | | | | | | | | | | | | | RBracket 2362..2363 +| | | | | | | | | | | | | | | | | | | | RBracket 2362..2363 "]" +| | | | | | | | | | | | | | | | | | WhiteSpace 2363..2364 +| | | | | | | | | | | | | | | | | | | WhiteSpace 2363..2364 " " +| | | | | | | | | | | | | | | | | | Mul 2364..2365 +| | | | | | | | | | | | | | | | | | | Mul 2364..2365 "*" +| | | | | | | | | | | | | | | | | | WhiteSpace 2365..2366 +| | | | | | | | | | | | | | | | | | | WhiteSpace 2365..2366 " " +| | | | | | | | | | | | | | | | | | ExpressionAtom 2366..2368 +| | | | | | | | | | | | | | | | | | | Identifier 2366..2368 +| | | | | | | | | | | | | | | | | | | | Identifier 2366..2368 "e2" +| | | | | | | | | | | | | | | Semicolon 2368..2369 +| | | | | | | | | | | | | | | | Semicolon 2368..2369 ";" +| | | | | | | | | | | | | | EndLine 2369..2371 +| | | | | | | | | | | | | | | EndLine 2369..2371 "\r\n" +| | | | | | | | | | | | | | WhiteSpace 2371..2375 +| | | | | | | | | | | | | | | WhiteSpace 2371..2375 " " +| | | | | | | | | | | | | | EndLine 2375..2377 +| | | | | | | | | | | | | | | EndLine 2375..2377 "\r\n" +| | | | | | | | | | | | | | WhiteSpace 2377..2389 +| | | | | | | | | | | | | | | WhiteSpace 2377..2389 " " +| | | | | | | | | | | | | | Statement 2389..2400 +| | | | | | | | | | | | | | | AssignStatement 2389..2399 +| | | | | | | | | | | | | | | | Expression 2389..2392 +| | | | | | | | | | | | | | | | | ComponentIdentifier 2389..2391 +| | | | | | | | | | | | | | | | | | Identifier 2389..2391 +| | | | | | | | | | | | | | | | | | | Identifier 2389..2391 "e2" +| | | | | | | | | | | | | | | | | WhiteSpace 2391..2392 +| | | | | | | | | | | | | | | | | | WhiteSpace 2391..2392 " " +| | | | | | | | | | | | | | | | Assign 2392..2393 +| | | | | | | | | | | | | | | | | Assign 2392..2393 "=" +| | | | | | | | | | | | | | | | WhiteSpace 2393..2394 +| | | | | | | | | | | | | | | | | WhiteSpace 2393..2394 " " +| | | | | | | | | | | | | | | | Expression 2394..2399 +| | | | | | | | | | | | | | | | | Add 2394..2399 +| | | | | | | | | | | | | | | | | | ExpressionAtom 2394..2396 +| | | | | | | | | | | | | | | | | | | Identifier 2394..2396 +| | | | | | | | | | | | | | | | | | | | Identifier 2394..2396 "e2" +| | | | | | | | | | | | | | | | | | Add 2396..2397 +| | | | | | | | | | | | | | | | | | | Add 2396..2397 "+" +| | | | | | | | | | | | | | | | | | ExpressionAtom 2397..2399 +| | | | | | | | | | | | | | | | | | | Identifier 2397..2399 +| | | | | | | | | | | | | | | | | | | | Identifier 2397..2399 "e2" +| | | | | | | | | | | | | | | Semicolon 2399..2400 +| | | | | | | | | | | | | | | | Semicolon 2399..2400 ";" +| | | | | | | | | | | | | | EndLine 2400..2402 +| | | | | | | | | | | | | | | EndLine 2400..2402 "\r\n" +| | | | | | | | | | | | | | WhiteSpace 2402..2410 +| | | | | | | | | | | | | | | WhiteSpace 2402..2410 " " +| | | | | | | | | | | | | RCurly 2410..2411 +| | | | | | | | | | | | | | RCurly 2410..2411 "}" +| | | | | | | | | EndLine 2411..2413 +| | | | | | | | | | EndLine 2411..2413 "\r\n" +| | | | | | | | | WhiteSpace 2413..2417 +| | | | | | | | | | WhiteSpace 2413..2417 " " +| | | | | | | | | EndLine 2417..2419 +| | | | | | | | | | EndLine 2417..2419 "\r\n" +| | | | | | | | | WhiteSpace 2419..2427 +| | | | | | | | | | WhiteSpace 2419..2427 " " +| | | | | | | | | CommentLine 2427..2445 +| | | | | | | | | | CommentLine 2427..2445 "// Ensure the sum;" +| | | | | | | | | EndLine 2445..2447 +| | | | | | | | | | EndLine 2445..2447 "\r\n" +| | | | | | | | | WhiteSpace 2447..2451 +| | | | | | | | | | WhiteSpace 2447..2451 " " +| | | | | | | | | EndLine 2451..2453 +| | | | | | | | | | EndLine 2451..2453 "\r\n" +| | | | | | | | | WhiteSpace 2453..2461 +| | | | | | | | | | WhiteSpace 2453..2461 " " +| | | | | | | | | Statement 2461..2474 +| | | | | | | | | | AssignStatement 2461..2473 +| | | | | | | | | | | Expression 2461..2465 +| | | | | | | | | | | | ComponentIdentifier 2461..2464 +| | | | | | | | | | | | | Identifier 2461..2464 +| | | | | | | | | | | | | | Identifier 2461..2464 "lin" +| | | | | | | | | | | | WhiteSpace 2464..2465 +| | | | | | | | | | | | | WhiteSpace 2464..2465 " " +| | | | | | | | | | | EqualSignal 2465..2468 +| | | | | | | | | | | | EqualSignal 2465..2468 "===" +| | | | | | | | | | | WhiteSpace 2468..2469 +| | | | | | | | | | | | WhiteSpace 2468..2469 " " +| | | | | | | | | | | Expression 2469..2473 +| | | | | | | | | | | | ExpressionAtom 2469..2473 +| | | | | | | | | | | | | Identifier 2469..2473 +| | | | | | | | | | | | | | Identifier 2469..2473 "lout" +| | | | | | | | | | Semicolon 2473..2474 +| | | | | | | | | | | Semicolon 2473..2474 ";" +| | | | | | | | | EndLine 2474..2476 +| | | | | | | | | | EndLine 2474..2476 "\r\n" +| | | | | | | | | WhiteSpace 2476..2480 +| | | | | | | | | | WhiteSpace 2476..2480 " " +| | | | | | | | RCurly 2480..2481 +| | | | | | | | | RCurly 2480..2481 "}" +| | | | EndLine 2481..2483 +| | | | | EndLine 2481..2483 "\r\n" +| | | Error 2483..2508 +| | | | Error 2483..2508 +| | | | | Error 2483..2508 "expect RCurly but got EOF" diff --git a/crates/syntax/src/snapshots/syntax__syntax__tests____src__test_files__happy__line_comment.circom.snap b/crates/syntax/src/snapshots/syntax__syntax__tests____src__test_files__happy__line_comment.circom.snap index cb78791..5239a09 100644 --- a/crates/syntax/src/snapshots/syntax__syntax__tests____src__test_files__happy__line_comment.circom.snap +++ b/crates/syntax/src/snapshots/syntax__syntax__tests____src__test_files__happy__line_comment.circom.snap @@ -1,38 +1,30 @@ --- source: crates/syntax/src/syntax.rs -expression: "crate::view_syntax::view_ast(&syntax)" +expression: "crate :: view_syntax :: view_ast(& syntax)" --- - CircomProgram 0..41 -| EndLine 0..1 -| | EndLine 0..1 -| | | EndLine 0..1 "\n" -| CommentLine 1..14 -| | CommentLine 1..14 -| | | CommentLine 1..14 "// comment :>" -| EndLine 14..15 -| | EndLine 14..15 -| | | EndLine 14..15 "\n" -| EndLine 15..16 -| | EndLine 15..16 -| | | EndLine 15..16 "\n" -| WhiteSpace 16..20 -| | WhiteSpace 16..20 -| | | WhiteSpace 16..20 " " -| Pragma 20..40 -| | Pragma 20..26 -| | | Pragma 20..26 "pragma" -| | WhiteSpace 26..27 -| | | WhiteSpace 26..27 -| | | | WhiteSpace 26..27 " " -| | Circom 27..33 -| | | Circom 27..33 "circom" -| | WhiteSpace 33..34 -| | | WhiteSpace 33..34 -| | | | WhiteSpace 33..34 " " -| | Version 34..39 -| | | Version 34..39 "2.0.0" -| | Semicolon 39..40 -| | | Semicolon 39..40 ";" -| EndLine 40..41 -| | EndLine 40..41 -| | | EndLine 40..41 "\n" + CircomProgram 0..45 +| EndLine 0..2 +| | EndLine 0..2 "\r\n" +| CommentLine 2..15 +| | CommentLine 2..15 "// comment :>" +| EndLine 15..17 +| | EndLine 15..17 "\r\n" +| EndLine 17..19 +| | EndLine 17..19 "\r\n" +| WhiteSpace 19..23 +| | WhiteSpace 19..23 " " +| Pragma 23..43 +| | PragmaKw 23..29 +| | | PragmaKw 23..29 "pragma" +| | WhiteSpace 29..30 +| | | WhiteSpace 29..30 " " +| | Circom 30..36 +| | | Circom 30..36 "circom" +| | WhiteSpace 36..37 +| | | WhiteSpace 36..37 " " +| | Version 37..42 +| | | Version 37..42 "2.0.0" +| | Semicolon 42..43 +| | | Semicolon 42..43 ";" +| EndLine 43..45 +| | EndLine 43..45 "\r\n" diff --git a/crates/syntax/src/snapshots/syntax__syntax__tests____src__test_files__happy__pragma.circom.snap b/crates/syntax/src/snapshots/syntax__syntax__tests____src__test_files__happy__pragma.circom.snap index f84ef6f..4bd2120 100644 --- a/crates/syntax/src/snapshots/syntax__syntax__tests____src__test_files__happy__pragma.circom.snap +++ b/crates/syntax/src/snapshots/syntax__syntax__tests____src__test_files__happy__pragma.circom.snap @@ -1,18 +1,16 @@ --- source: crates/syntax/src/syntax.rs -expression: "crate::view_syntax::view_ast(&syntax)" +expression: "crate :: view_syntax :: view_ast(& syntax)" --- Pragma 0..20 -| Pragma 0..6 -| | Pragma 0..6 "pragma" +| PragmaKw 0..6 +| | PragmaKw 0..6 "pragma" | WhiteSpace 6..7 -| | WhiteSpace 6..7 -| | | WhiteSpace 6..7 " " +| | WhiteSpace 6..7 " " | Circom 7..13 | | Circom 7..13 "circom" | WhiteSpace 13..14 -| | WhiteSpace 13..14 -| | | WhiteSpace 13..14 " " +| | WhiteSpace 13..14 " " | Version 14..19 | | Version 14..19 "2.0.0" | Semicolon 19..20 diff --git a/crates/syntax/src/snapshots/syntax__syntax__tests____src__test_files__happy__template.circom.snap b/crates/syntax/src/snapshots/syntax__syntax__tests____src__test_files__happy__template.circom.snap index 6d1a073..63ed6b0 100644 --- a/crates/syntax/src/snapshots/syntax__syntax__tests____src__test_files__happy__template.circom.snap +++ b/crates/syntax/src/snapshots/syntax__syntax__tests____src__test_files__happy__template.circom.snap @@ -1,19 +1,17 @@ --- source: crates/syntax/src/syntax.rs -expression: "crate::view_syntax::view_ast(&syntax)" +expression: "crate :: view_syntax :: view_ast(& syntax)" --- - TemplateDef 0..784 + TemplateDef 0..349 | TemplateKw 0..8 | | TemplateKw 0..8 "template" | WhiteSpace 8..9 -| | WhiteSpace 8..9 -| | | WhiteSpace 8..9 " " +| | WhiteSpace 8..9 " " | TemplateName 9..20 | | Identifier 9..20 | | | Identifier 9..20 "MultiplierN" | WhiteSpace 20..21 -| | WhiteSpace 20..21 -| | | WhiteSpace 20..21 " " +| | WhiteSpace 20..21 " " | LParen 21..22 | | LParen 21..22 "(" | ParameterList 22..30 @@ -22,337 +20,230 @@ expression: "crate::view_syntax::view_ast(&syntax)" | | Comma 23..24 | | | Comma 23..24 "," | | WhiteSpace 24..25 -| | | WhiteSpace 24..25 -| | | | WhiteSpace 24..25 " " +| | | WhiteSpace 24..25 " " | | Identifier 25..26 | | | Identifier 25..26 "P" | | Comma 26..27 | | | Comma 26..27 "," | | WhiteSpace 27..28 -| | | WhiteSpace 27..28 -| | | | WhiteSpace 27..28 " " +| | | WhiteSpace 27..28 " " | | Identifier 28..30 | | | Identifier 28..30 "QQ" | RParen 30..31 | | RParen 30..31 ")" | WhiteSpace 31..32 -| | WhiteSpace 31..32 -| | | WhiteSpace 31..32 " " -| Block 32..784 +| | WhiteSpace 31..32 " " +| Block 32..349 | | LCurly 32..33 | | | LCurly 32..33 "{" -| | EndLine 33..34 -| | | EndLine 33..34 -| | | | EndLine 33..34 "\n" -| | WhiteSpace 34..46 -| | | WhiteSpace 34..46 -| | | | WhiteSpace 34..46 " " -| | CommentLine 46..86 -| | | CommentLine 46..86 -| | | | CommentLine 46..86 "//Declaration of signals and components." -| | EndLine 86..87 -| | | EndLine 86..87 -| | | | EndLine 86..87 "\n" -| | WhiteSpace 87..99 -| | | WhiteSpace 87..99 -| | | | WhiteSpace 87..99 " " -| | StatementList 99..783 -| | | InputSignalDecl 99..114 -| | | | SignalHeader 99..112 -| | | | | SignalKw 99..105 -| | | | | | SignalKw 99..105 "signal" -| | | | | WhiteSpace 105..106 -| | | | | | WhiteSpace 105..106 -| | | | | | | WhiteSpace 105..106 " " -| | | | | InputKw 106..111 -| | | | | | InputKw 106..111 "input" -| | | | | WhiteSpace 111..112 -| | | | | | WhiteSpace 111..112 -| | | | | | | WhiteSpace 111..112 " " -| | | | Identifier 112..114 -| | | | | Identifier 112..114 "in" -| | | Error 114..147 -| | | | Error 114..147 -| | | | | Error 114..147 "expect Semicolon but got LBracket" -| | | Statement 147..183 -| | | | Error 147..148 -| | | | | Expression 147..148 -| | | | | | Error 147..148 -| | | | | | | LBracket 147..148 -| | | | | | | | LBracket 147..148 "[" -| | | | Error 148..183 -| | | | | Error 148..183 -| | | | | | Error 148..183 "expect Semicolon but got Identifier" -| | | Statement 183..217 -| | | | Error 183..184 -| | | | | Expression 183..184 -| | | | | | ComponentIdentifier 183..184 -| | | | | | | Identifier 183..184 -| | | | | | | | Identifier 183..184 "N" -| | | | Error 184..217 -| | | | | Error 184..217 -| | | | | | Error 184..217 "expect Semicolon but got RBracket" -| | | Statement 217..219 -| | | | Error 217..218 -| | | | | Expression 217..218 -| | | | | | Error 217..218 -| | | | | | | RBracket 217..218 -| | | | | | | | RBracket 217..218 "]" -| | | | Semicolon 218..219 -| | | | | Semicolon 218..219 ";" -| | | EndLine 219..220 -| | | | EndLine 219..220 -| | | | | EndLine 219..220 "\n" -| | | WhiteSpace 220..232 -| | | | WhiteSpace 220..232 -| | | | | WhiteSpace 220..232 " " -| | | OutputSignalDecl 232..249 -| | | | SignalHeader 232..246 -| | | | | SignalKw 232..238 -| | | | | | SignalKw 232..238 "signal" -| | | | | WhiteSpace 238..239 -| | | | | | WhiteSpace 238..239 -| | | | | | | WhiteSpace 238..239 " " -| | | | | OutputKw 239..245 -| | | | | | OutputKw 239..245 "output" -| | | | | WhiteSpace 245..246 -| | | | | | WhiteSpace 245..246 -| | | | | | | WhiteSpace 245..246 " " -| | | | Identifier 246..249 -| | | | | Identifier 246..249 "out" -| | | Semicolon 249..250 -| | | | Semicolon 249..250 ";" -| | | EndLine 250..251 -| | | | EndLine 250..251 -| | | | | EndLine 250..251 "\n" -| | | WhiteSpace 251..263 -| | | | WhiteSpace 251..263 -| | | | | WhiteSpace 251..263 " " -| | | ComponentDecl 263..401 -| | | | ComponentKw 263..272 -| | | | | ComponentKw 263..272 "component" -| | | | WhiteSpace 272..273 -| | | | | WhiteSpace 272..273 -| | | | | | WhiteSpace 272..273 " " -| | | | ComponentIdentifier 273..277 -| | | | | Identifier 273..277 -| | | | | | Identifier 273..277 "comp" -| | | | Error 277..307 -| | | | | Error 277..307 -| | | | | | Error 277..307 "expect Assign but got LBracket" -| | | | TemplateName 307..341 -| | | | | Error 307..341 -| | | | | | Error 307..341 -| | | | | | | Error 307..341 "expect Identifier but got LBracket" -| | | | Error 341..371 -| | | | | Error 341..371 -| | | | | | Error 341..371 "expect LParen but got LBracket" -| | | | Error 371..401 -| | | | | Error 371..401 -| | | | | | Error 371..401 "expect RParen but got LBracket" -| | | Error 401..434 -| | | | Error 401..434 -| | | | | Error 401..434 "expect Semicolon but got LBracket" -| | | Statement 434..470 -| | | | Error 434..435 -| | | | | Expression 434..435 -| | | | | | Error 434..435 -| | | | | | | LBracket 434..435 -| | | | | | | | LBracket 434..435 "[" -| | | | Error 435..470 -| | | | | Error 435..470 -| | | | | | Error 435..470 "expect Semicolon but got Identifier" -| | | Statement 470..499 -| | | | Error 470..471 -| | | | | Expression 470..471 -| | | | | | ComponentIdentifier 470..471 -| | | | | | | Identifier 470..471 -| | | | | | | | Identifier 470..471 "N" -| | | | Error 471..499 -| | | | | Error 471..499 -| | | | | | Error 471..499 "expect Semicolon but got Sub" -| | | Statement 499..534 -| | | | Error 499..501 -| | | | | Expression 499..501 -| | | | | | Sub 499..501 -| | | | | | | Sub 499..500 -| | | | | | | | Sub 499..500 "-" -| | | | | | | Number 500..501 -| | | | | | | | Number 500..501 -| | | | | | | | | Number 500..501 "1" -| | | | Error 501..534 -| | | | | Error 501..534 -| | | | | | Error 501..534 "expect Semicolon but got RBracket" -| | | Statement 534..536 -| | | | Error 534..535 -| | | | | Expression 534..535 -| | | | | | Error 534..535 -| | | | | | | RBracket 534..535 -| | | | | | | | RBracket 534..535 "]" -| | | | Semicolon 535..536 -| | | | | Semicolon 535..536 ";" -| | | EndLine 536..537 -| | | | EndLine 536..537 -| | | | | EndLine 536..537 "\n" -| | | WhiteSpace 537..550 -| | | | WhiteSpace 537..550 -| | | | | WhiteSpace 537..550 " " -| | | EndLine 550..551 -| | | | EndLine 550..551 -| | | | | EndLine 550..551 "\n" -| | | WhiteSpace 551..563 -| | | | WhiteSpace 551..563 -| | | | | WhiteSpace 551..563 " " -| | | CommentLine 563..576 -| | | | CommentLine 563..576 -| | | | | CommentLine 563..576 "//Statements." -| | | EndLine 576..577 -| | | | EndLine 576..577 -| | | | | EndLine 576..577 "\n" -| | | WhiteSpace 577..589 -| | | | WhiteSpace 577..589 -| | | | | WhiteSpace 577..589 " " -| | | Statement 589..677 -| | | | ForLoop 589..677 -| | | | | ForKw 589..592 -| | | | | | ForKw 589..592 "for" -| | | | | LParen 592..593 -| | | | | | LParen 592..593 "(" -| | | | | VarDecl 593..602 -| | | | | | VarKw 593..596 -| | | | | | | VarKw 593..596 "var" -| | | | | | WhiteSpace 596..597 -| | | | | | | WhiteSpace 596..597 -| | | | | | | | WhiteSpace 596..597 " " -| | | | | | Identifier 597..598 -| | | | | | | Identifier 597..598 "i" -| | | | | | WhiteSpace 598..599 -| | | | | | | WhiteSpace 598..599 -| | | | | | | | WhiteSpace 598..599 " " -| | | | | | Assign 599..600 -| | | | | | | Assign 599..600 "=" -| | | | | | WhiteSpace 600..601 -| | | | | | | WhiteSpace 600..601 -| | | | | | | | WhiteSpace 600..601 " " -| | | | | | Expression 601..602 -| | | | | | | Number 601..602 -| | | | | | | | Number 601..602 -| | | | | | | | | Number 601..602 "0" -| | | | | Semicolon 602..603 -| | | | | | Semicolon 602..603 ";" -| | | | | WhiteSpace 603..604 -| | | | | | WhiteSpace 603..604 -| | | | | | | WhiteSpace 603..604 " " -| | | | | Expression 604..611 -| | | | | | LessThan 604..611 -| | | | | | | Identifier 604..605 -| | | | | | | | Identifier 604..605 -| | | | | | | | | Identifier 604..605 "i" -| | | | | | | WhiteSpace 605..606 -| | | | | | | | WhiteSpace 605..606 -| | | | | | | | | WhiteSpace 605..606 " " -| | | | | | | LessThan 606..607 -| | | | | | | | LessThan 606..607 "<" -| | | | | | | WhiteSpace 607..608 -| | | | | | | | WhiteSpace 607..608 -| | | | | | | | | WhiteSpace 607..608 " " -| | | | | | | Sub 608..611 -| | | | | | | | Identifier 608..609 -| | | | | | | | | Identifier 608..609 -| | | | | | | | | | Identifier 608..609 "N" -| | | | | | | | Sub 609..610 -| | | | | | | | | Sub 609..610 "-" -| | | | | | | | Number 610..611 -| | | | | | | | | Number 610..611 -| | | | | | | | | | Number 610..611 "1" -| | | | | Semicolon 611..612 -| | | | | | Semicolon 611..612 ";" -| | | | | WhiteSpace 612..613 -| | | | | | WhiteSpace 612..613 -| | | | | | | WhiteSpace 612..613 " " -| | | | | Error 613..614 -| | | | | | Expression 613..614 -| | | | | | | ComponentIdentifier 613..614 -| | | | | | | | Identifier 613..614 -| | | | | | | | | Identifier 613..614 "i" -| | | | | Error 614..643 -| | | | | | Error 614..643 -| | | | | | | Error 614..643 "expect RParen but got UnitInc" -| | | | | Error 643..646 -| | | | | | Expression 643..646 -| | | | | | | UnitInc 643..646 -| | | | | | | | UnitInc 643..645 -| | | | | | | | | UnitInc 643..645 "++" -| | | | | | | | Error 645..646 -| | | | | | | | | RParen 645..646 -| | | | | | | | | | RParen 645..646 ")" -| | | | | Error 646..677 -| | | | | | Error 646..677 -| | | | | | | Error 646..677 "expect Semicolon but got LCurly" -| | | Statement 677..765 -| | | | Block 677..765 -| | | | | LCurly 677..678 -| | | | | | LCurly 677..678 "{" -| | | | | EndLine 678..679 -| | | | | | EndLine 678..679 -| | | | | | | EndLine 678..679 "\n" -| | | | | WhiteSpace 679..695 -| | | | | | WhiteSpace 679..695 -| | | | | | | WhiteSpace 679..695 " " -| | | | | StatementList 695..764 -| | | | | | Statement 695..751 -| | | | | | | AssignStatement 695..750 -| | | | | | | | Expression 695..703 -| | | | | | | | | ComponentIdentifier 695..699 -| | | | | | | | | | Identifier 695..699 -| | | | | | | | | | | Identifier 695..699 "comp" -| | | | | | | | | LBracket 699..700 -| | | | | | | | | | LBracket 699..700 "[" -| | | | | | | | | Expression 700..701 -| | | | | | | | | | Identifier 700..701 -| | | | | | | | | | | Identifier 700..701 -| | | | | | | | | | | | Identifier 700..701 "i" -| | | | | | | | | RBracket 701..702 -| | | | | | | | | | RBracket 701..702 "]" -| | | | | | | | | WhiteSpace 702..703 -| | | | | | | | | | WhiteSpace 702..703 -| | | | | | | | | | | WhiteSpace 702..703 " " -| | | | | | | | Assign 703..704 -| | | | | | | | | Assign 703..704 "=" -| | | | | | | | WhiteSpace 704..705 -| | | | | | | | | WhiteSpace 704..705 -| | | | | | | | | | WhiteSpace 704..705 " " -| | | | | | | | Expression 705..750 -| | | | | | | | | Call 705..750 -| | | | | | | | | | Identifier 705..716 -| | | | | | | | | | | Identifier 705..716 -| | | | | | | | | | | | Identifier 705..716 "Multiplier2" -| | | | | | | | | | Tuple 716..750 -| | | | | | | | | | | LParen 716..717 -| | | | | | | | | | | | LParen 716..717 "(" -| | | | | | | | | | | Error 717..749 -| | | | | | | | | | | | Error 717..749 -| | | | | | | | | | | | | Error 717..749 "expect Identifier but got RParen" -| | | | | | | | | | | RParen 749..750 -| | | | | | | | | | | | RParen 749..750 ")" -| | | | | | | Semicolon 750..751 -| | | | | | | | Semicolon 750..751 ";" -| | | | | | EndLine 751..752 -| | | | | | | EndLine 751..752 -| | | | | | | | EndLine 751..752 "\n" -| | | | | | WhiteSpace 752..764 -| | | | | | | WhiteSpace 752..764 -| | | | | | | | WhiteSpace 752..764 " " -| | | | | RCurly 764..765 -| | | | | | RCurly 764..765 "}" -| | | EndLine 765..766 -| | | | EndLine 765..766 -| | | | | EndLine 765..766 "\n" -| | | WhiteSpace 766..782 -| | | | WhiteSpace 766..782 -| | | | | WhiteSpace 766..782 " " -| | | EndLine 782..783 -| | | | EndLine 782..783 -| | | | | EndLine 782..783 "\n" -| | RCurly 783..784 -| | | RCurly 783..784 "}" +| | EndLine 33..35 +| | | EndLine 33..35 "\r\n" +| | WhiteSpace 35..47 +| | | WhiteSpace 35..47 " " +| | CommentLine 47..87 +| | | CommentLine 47..87 "//Declaration of signals and components." +| | EndLine 87..89 +| | | EndLine 87..89 "\r\n" +| | WhiteSpace 89..101 +| | | WhiteSpace 89..101 " " +| | StatementList 101..348 +| | | InputSignalDecl 101..119 +| | | | SignalHeader 101..114 +| | | | | SignalKw 101..107 +| | | | | | SignalKw 101..107 "signal" +| | | | | WhiteSpace 107..108 +| | | | | | WhiteSpace 107..108 " " +| | | | | InputKw 108..113 +| | | | | | InputKw 108..113 "input" +| | | | | WhiteSpace 113..114 +| | | | | | WhiteSpace 113..114 " " +| | | | SignalIdentifier 114..119 +| | | | | Identifier 114..116 +| | | | | | Identifier 114..116 "in" +| | | | | LBracket 116..117 +| | | | | | LBracket 116..117 "[" +| | | | | Expression 117..118 +| | | | | | ExpressionAtom 117..118 +| | | | | | | Identifier 117..118 +| | | | | | | | Identifier 117..118 "N" +| | | | | RBracket 118..119 +| | | | | | RBracket 118..119 "]" +| | | Semicolon 119..120 +| | | | Semicolon 119..120 ";" +| | | EndLine 120..122 +| | | | EndLine 120..122 "\r\n" +| | | WhiteSpace 122..134 +| | | | WhiteSpace 122..134 " " +| | | OutputSignalDecl 134..151 +| | | | SignalHeader 134..148 +| | | | | SignalKw 134..140 +| | | | | | SignalKw 134..140 "signal" +| | | | | WhiteSpace 140..141 +| | | | | | WhiteSpace 140..141 " " +| | | | | OutputKw 141..147 +| | | | | | OutputKw 141..147 "output" +| | | | | WhiteSpace 147..148 +| | | | | | WhiteSpace 147..148 " " +| | | | SignalIdentifier 148..151 +| | | | | Identifier 148..151 +| | | | | | Identifier 148..151 "out" +| | | Semicolon 151..152 +| | | | Semicolon 151..152 ";" +| | | EndLine 152..154 +| | | | EndLine 152..154 "\r\n" +| | | WhiteSpace 154..166 +| | | | WhiteSpace 154..166 " " +| | | ComponentDecl 166..185 +| | | | ComponentKw 166..175 +| | | | | ComponentKw 166..175 "component" +| | | | WhiteSpace 175..176 +| | | | | WhiteSpace 175..176 " " +| | | | ComponentIdentifier 176..185 +| | | | | Identifier 176..180 +| | | | | | Identifier 176..180 "comp" +| | | | | LBracket 180..181 +| | | | | | LBracket 180..181 "[" +| | | | | Expression 181..184 +| | | | | | Sub 181..184 +| | | | | | | ExpressionAtom 181..182 +| | | | | | | | Identifier 181..182 +| | | | | | | | | Identifier 181..182 "N" +| | | | | | | Sub 182..183 +| | | | | | | | Sub 182..183 "-" +| | | | | | | ExpressionAtom 183..184 +| | | | | | | | Number 183..184 +| | | | | | | | | Number 183..184 "1" +| | | | | RBracket 184..185 +| | | | | | RBracket 184..185 "]" +| | | Semicolon 185..186 +| | | | Semicolon 185..186 ";" +| | | EndLine 186..188 +| | | | EndLine 186..188 "\r\n" +| | | WhiteSpace 188..201 +| | | | WhiteSpace 188..201 " " +| | | EndLine 201..203 +| | | | EndLine 201..203 "\r\n" +| | | WhiteSpace 203..215 +| | | | WhiteSpace 203..215 " " +| | | CommentLine 215..228 +| | | | CommentLine 215..228 "//Statements." +| | | EndLine 228..230 +| | | | EndLine 228..230 "\r\n" +| | | WhiteSpace 230..242 +| | | | WhiteSpace 230..242 " " +| | | Statement 242..328 +| | | | ForLoop 242..328 +| | | | | ForKw 242..245 +| | | | | | ForKw 242..245 "for" +| | | | | LParen 245..246 +| | | | | | LParen 245..246 "(" +| | | | | VarDecl 246..255 +| | | | | | VarKw 246..249 +| | | | | | | VarKw 246..249 "var" +| | | | | | WhiteSpace 249..250 +| | | | | | | WhiteSpace 249..250 " " +| | | | | | VarIdentifier 250..252 +| | | | | | | Identifier 250..251 +| | | | | | | | Identifier 250..251 "i" +| | | | | | | WhiteSpace 251..252 +| | | | | | | | WhiteSpace 251..252 " " +| | | | | | Assign 252..253 +| | | | | | | Assign 252..253 "=" +| | | | | | WhiteSpace 253..254 +| | | | | | | WhiteSpace 253..254 " " +| | | | | | Expression 254..255 +| | | | | | | ExpressionAtom 254..255 +| | | | | | | | Number 254..255 +| | | | | | | | | Number 254..255 "0" +| | | | | Semicolon 255..256 +| | | | | | Semicolon 255..256 ";" +| | | | | WhiteSpace 256..257 +| | | | | | WhiteSpace 256..257 " " +| | | | | Expression 257..264 +| | | | | | LessThan 257..264 +| | | | | | | ExpressionAtom 257..258 +| | | | | | | | Identifier 257..258 +| | | | | | | | | Identifier 257..258 "i" +| | | | | | | WhiteSpace 258..259 +| | | | | | | | WhiteSpace 258..259 " " +| | | | | | | LessThan 259..260 +| | | | | | | | LessThan 259..260 "<" +| | | | | | | WhiteSpace 260..261 +| | | | | | | | WhiteSpace 260..261 " " +| | | | | | | Sub 261..264 +| | | | | | | | ExpressionAtom 261..262 +| | | | | | | | | Identifier 261..262 +| | | | | | | | | | Identifier 261..262 "N" +| | | | | | | | Sub 262..263 +| | | | | | | | | Sub 262..263 "-" +| | | | | | | | ExpressionAtom 263..264 +| | | | | | | | | Number 263..264 +| | | | | | | | | | Number 263..264 "1" +| | | | | Semicolon 264..265 +| | | | | | Semicolon 264..265 ";" +| | | | | WhiteSpace 265..266 +| | | | | | WhiteSpace 265..266 " " +| | | | | AssignStatement 266..269 +| | | | | | Expression 266..267 +| | | | | | | ComponentIdentifier 266..267 +| | | | | | | | Identifier 266..267 +| | | | | | | | | Identifier 266..267 "i" +| | | | | | UnitInc 267..269 +| | | | | | | UnitInc 267..269 "++" +| | | | | RParen 269..270 +| | | | | | RParen 269..270 ")" +| | | | | Statement 270..328 +| | | | | | Block 270..328 +| | | | | | | LCurly 270..271 +| | | | | | | | LCurly 270..271 "{" +| | | | | | | EndLine 271..273 +| | | | | | | | EndLine 271..273 "\r\n" +| | | | | | | WhiteSpace 273..289 +| | | | | | | | WhiteSpace 273..289 " " +| | | | | | | StatementList 289..327 +| | | | | | | | Statement 289..313 +| | | | | | | | | AssignStatement 289..312 +| | | | | | | | | | Expression 289..297 +| | | | | | | | | | | ComponentIdentifier 289..293 +| | | | | | | | | | | | Identifier 289..293 +| | | | | | | | | | | | | Identifier 289..293 "comp" +| | | | | | | | | | | LBracket 293..294 +| | | | | | | | | | | | LBracket 293..294 "[" +| | | | | | | | | | | Expression 294..295 +| | | | | | | | | | | | ExpressionAtom 294..295 +| | | | | | | | | | | | | Identifier 294..295 +| | | | | | | | | | | | | | Identifier 294..295 "i" +| | | | | | | | | | | RBracket 295..296 +| | | | | | | | | | | | RBracket 295..296 "]" +| | | | | | | | | | | WhiteSpace 296..297 +| | | | | | | | | | | | WhiteSpace 296..297 " " +| | | | | | | | | | Assign 297..298 +| | | | | | | | | | | Assign 297..298 "=" +| | | | | | | | | | WhiteSpace 298..299 +| | | | | | | | | | | WhiteSpace 298..299 " " +| | | | | | | | | | Expression 299..312 +| | | | | | | | | | | Call 299..312 +| | | | | | | | | | | | ExpressionAtom 299..310 +| | | | | | | | | | | | | Identifier 299..310 +| | | | | | | | | | | | | | Identifier 299..310 "Multiplier2" +| | | | | | | | | | | | Tuple 310..312 +| | | | | | | | | | | | | LParen 310..311 +| | | | | | | | | | | | | | LParen 310..311 "(" +| | | | | | | | | | | | | RParen 311..312 +| | | | | | | | | | | | | | RParen 311..312 ")" +| | | | | | | | | Semicolon 312..313 +| | | | | | | | | | Semicolon 312..313 ";" +| | | | | | | | EndLine 313..315 +| | | | | | | | | EndLine 313..315 "\r\n" +| | | | | | | | WhiteSpace 315..327 +| | | | | | | | | WhiteSpace 315..327 " " +| | | | | | | RCurly 327..328 +| | | | | | | | RCurly 327..328 "}" +| | | EndLine 328..330 +| | | | EndLine 328..330 "\r\n" +| | | WhiteSpace 330..346 +| | | | WhiteSpace 330..346 " " +| | | EndLine 346..348 +| | | | EndLine 346..348 "\r\n" +| | RCurly 348..349 +| | | RCurly 348..349 "}" diff --git a/crates/syntax/src/snapshots/syntax__syntax__tests__syntax_test_1_children.snap b/crates/syntax/src/snapshots/syntax__syntax__tests__syntax_test_1_children.snap deleted file mode 100644 index b1feddb..0000000 --- a/crates/syntax/src/snapshots/syntax__syntax__tests__syntax_test_1_children.snap +++ /dev/null @@ -1,17 +0,0 @@ ---- -source: crates/syntax/src/syntax.rs -expression: children_string ---- -- pragma circom 2.0.0; -- "\n" -- "\n" -- " " -- "\n" -- " " -- "template Multiplier2 () {}" -- "\n" -- " " -- "template Multiplier2 () {}" -- " " -- "\n" -- " " diff --git a/crates/syntax/src/snapshots/syntax__syntax__tests__syntax_test_2_functions.snap b/crates/syntax/src/snapshots/syntax__syntax__tests__syntax_test_2_functions.snap deleted file mode 100644 index 0913804..0000000 --- a/crates/syntax/src/snapshots/syntax__syntax__tests__syntax_test_2_functions.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: crates/syntax/src/syntax.rs -expression: function_names ---- -- nbits diff --git a/crates/syntax/src/snapshots/syntax__syntax__tests__syntax_test_2_templates.snap b/crates/syntax/src/snapshots/syntax__syntax__tests__syntax_test_2_templates.snap deleted file mode 100644 index db61c87..0000000 --- a/crates/syntax/src/snapshots/syntax__syntax__tests__syntax_test_2_templates.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: crates/syntax/src/syntax.rs -expression: template_names ---- -- BinSum diff --git a/crates/syntax/src/snapshots/syntax__syntax__tests__syntax_test_5_templates.snap b/crates/syntax/src/snapshots/syntax__syntax__tests__syntax_test_5_templates.snap deleted file mode 100644 index 8050901..0000000 --- a/crates/syntax/src/snapshots/syntax__syntax__tests__syntax_test_5_templates.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: crates/syntax/src/syntax.rs -expression: template_names ---- -- Multiplier2 diff --git a/crates/syntax/src/snapshots/syntax__syntax__tests__syntax_test_6_templates.snap b/crates/syntax/src/snapshots/syntax__syntax__tests__syntax_test_6_templates.snap deleted file mode 100644 index 8050901..0000000 --- a/crates/syntax/src/snapshots/syntax__syntax__tests__syntax_test_6_templates.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: crates/syntax/src/syntax.rs -expression: template_names ---- -- Multiplier2 diff --git a/crates/syntax/src/syntax.rs b/crates/syntax/src/syntax.rs index 08acdf5..4b8c46c 100644 --- a/crates/syntax/src/syntax.rs +++ b/crates/syntax/src/syntax.rs @@ -1,130 +1,130 @@ -use parser::grammar::entry::Scope; -use parser::input::Input; -use parser::output::{Child, Output}; -use parser::parser::Parser; -use parser::token_kind::TokenKind; -use rowan::{GreenNode, GreenNodeBuilder}; - -pub use rowan::{ - api::Preorder, Direction, NodeOrToken, SyntaxText, TextRange, TextSize, TokenAtOffset, - WalkEvent, -}; - -use crate::syntax_node::SyntaxNode; - -pub struct SyntaxTreeBuilder<'a> { - builder: GreenNodeBuilder<'static>, - input: &'a Input<'a>, -} - -impl<'a> SyntaxTreeBuilder<'a> { - pub fn new(input: &'a Input) -> Self { - Self { - builder: GreenNodeBuilder::new(), - input, - } - } - pub fn build_rec(&mut self, tree: &Output) { - self.builder.start_node(tree.kind().into()); - for child in tree.children() { - match child { - Child::Token(token_id) => { - let token_kind = self.input.kind_of(*token_id); - // TODO: return Error to replace .unwrap() - let token_value = self.input.token_value(*token_id).unwrap(); - self.builder.start_node(token_kind.into()); - self.builder.token(token_kind.into(), token_value); - self.builder.finish_node(); - } - Child::Tree(child_tree) => self.build_rec(child_tree), - Child::Error(error) => { - let token_kind = TokenKind::Error; - let token_value = error.as_str(); - - self.builder.start_node(token_kind.into()); - self.builder.token(token_kind.into(), token_value); - self.builder.finish_node(); - } - } - } - - self.builder.finish_node(); - } - - pub fn build(&mut self, tree: Output) { - self.build_rec(&tree); - } - - pub fn finish(self) -> GreenNode { - self.builder.finish() - } - - pub fn syntax_tree(source: &str) -> SyntaxNode { - let input = Input::new(source); - - let output = Parser::parsing(&input); - - let mut builder = SyntaxTreeBuilder::new(&input); - builder.build(output); - let green = builder.finish(); - SyntaxNode::new_root(green) - } -} - -pub fn syntax_node_from_source(source: &str, scope: Scope) -> SyntaxNode { - let input = Input::new(&source); - let output = Parser::parsing_with_scope(&input, scope); - - // output is a tree whose node is index of token, no content of token - // convert output into green node - let mut builder = SyntaxTreeBuilder::new(&input); - builder.build(output); - let green = builder.finish(); - - // then cast green node into syntax node - let syntax = SyntaxNode::new_root(green); - - syntax -} - -#[cfg(test)] -mod tests { - use crate::test_syntax; - use parser::grammar::entry::Scope; - - #[test] - fn pragma_happy_test() { - test_syntax!("/src/test_files/happy/pragma.circom", Scope::Pragma); - } - - #[test] - fn template_happy_test() { - // SOURCE & EXPECTED RESULT - test_syntax!("/src/test_files/happy/template.circom", Scope::Template); - } - - #[test] - fn block_happy_test() { - test_syntax!("/src/test_files/happy/block.circom", Scope::Block); - } - - #[test] - fn comment_happy_test() { - test_syntax!( - "/src/test_files/happy/block_comment.circom", - Scope::CircomProgram - ); - test_syntax!( - "/src/test_files/happy/line_comment.circom", - Scope::CircomProgram - ); - } - - #[test] - fn full_circom_program() { - test_syntax!( - "/src/test_files/happy/full_circom_program.circom", - Scope::CircomProgram - ); - } -} +use parser::grammar::entry::Scope; +use parser::input::Input; +use parser::output::{Child, Output}; +use parser::parser::Parser; +use parser::token_kind::TokenKind; +use rowan::{GreenNode, GreenNodeBuilder}; + +pub use rowan::{ + api::Preorder, Direction, NodeOrToken, SyntaxText, TextRange, TextSize, TokenAtOffset, + WalkEvent, +}; + +use crate::syntax_node::SyntaxNode; + +pub struct SyntaxTreeBuilder<'a> { + builder: GreenNodeBuilder<'static>, + input: &'a Input<'a>, +} + +impl<'a> SyntaxTreeBuilder<'a> { + pub fn new(input: &'a Input) -> Self { + Self { + builder: GreenNodeBuilder::new(), + input, + } + } + pub fn build_rec(&mut self, tree: &Output) { + self.builder.start_node(tree.kind().into()); + for child in tree.children() { + match child { + Child::Token(token_id) => { + let token_kind = self.input.kind_of(*token_id); + // TODO: return Error to replace .unwrap() + let token_value = self.input.token_value(*token_id).unwrap(); + self.builder.start_node(token_kind.into()); + self.builder.token(token_kind.into(), token_value); + self.builder.finish_node(); + } + Child::Tree(child_tree) => self.build_rec(child_tree), + Child::Error(error) => { + let token_kind = TokenKind::Error; + let token_value = error.as_str(); + + self.builder.start_node(token_kind.into()); + self.builder.token(token_kind.into(), token_value); + self.builder.finish_node(); + } + } + } + + self.builder.finish_node(); + } + + pub fn build(&mut self, tree: Output) { + self.build_rec(&tree); + } + + pub fn finish(self) -> GreenNode { + self.builder.finish() + } + + pub fn syntax_tree(source: &str) -> SyntaxNode { + let input = Input::new(source); + + let output = Parser::parsing(&input); + + let mut builder = SyntaxTreeBuilder::new(&input); + builder.build(output); + let green = builder.finish(); + SyntaxNode::new_root(green) + } +} + +pub fn syntax_node_from_source(source: &str, scope: Scope) -> SyntaxNode { + let input = Input::new(&source); + let output = Parser::parsing_with_scope(&input, scope); + + // output is a tree whose node is index of token, no content of token + // convert output into green node + let mut builder = SyntaxTreeBuilder::new(&input); + builder.build(output); + let green = builder.finish(); + + // then cast green node into syntax node + let syntax = SyntaxNode::new_root(green); + + syntax +} + +#[cfg(test)] +mod tests { + use crate::test_syntax; + use parser::grammar::entry::Scope; + + #[test] + fn pragma_happy_test() { + test_syntax!("/src/test_files/happy/pragma.circom", Scope::Pragma); + } + + #[test] + fn template_happy_test() { + // SOURCE & EXPECTED RESULT + test_syntax!("/src/test_files/happy/template.circom", Scope::Template); + } + + #[test] + fn block_happy_test() { + test_syntax!("/src/test_files/happy/block.circom", Scope::Block); + } + + #[test] + fn comment_happy_test() { + test_syntax!( + "/src/test_files/happy/block_comment.circom", + Scope::CircomProgram + ); + test_syntax!( + "/src/test_files/happy/line_comment.circom", + Scope::CircomProgram + ); + } + + #[test] + fn full_circom_program() { + test_syntax!( + "/src/test_files/happy/full_circom_program.circom", + Scope::CircomProgram + ); + } +} diff --git a/crates/syntax/src/test_files/happy/block.circom b/crates/syntax/src/test_files/happy/block.circom index fdfa1a7..31ba343 100644 --- a/crates/syntax/src/test_files/happy/block.circom +++ b/crates/syntax/src/test_files/happy/block.circom @@ -1,19 +1,19 @@ -{ - //Declaration of signals. - signal input in[N]; - signal output out; - component comp[N-1]; - - //Statements. - for(var i = 0; i < N-1; i++){ - comp[i] = Multiplier2(); - } - comp[0].in1 <== in[0]; - comp[0].in2 <== in[1]; - for(var i = 0; i < N-2; i++){ - comp[i+1].in1 <== comp[i].out; - comp[i+1].in2 <== in[i+2]; - - } - out <== comp[N-2].out; +{ + //Declaration of signals. + signal input in[N]; + signal output out; + component comp[N-1]; + + //Statements. + for(var i = 0; i < N-1; i++){ + comp[i] = Multiplier2(); + } + comp[0].in1 <== in[0]; + comp[0].in2 <== in[1]; + for(var i = 0; i < N-2; i++){ + comp[i+1].in1 <== comp[i].out; + comp[i+1].in2 <== in[i+2]; + + } + out <== comp[N-2].out; } \ No newline at end of file diff --git a/crates/syntax/src/test_files/happy/block_comment.circom b/crates/syntax/src/test_files/happy/block_comment.circom index 603f889..3946f7a 100644 --- a/crates/syntax/src/test_files/happy/block_comment.circom +++ b/crates/syntax/src/test_files/happy/block_comment.circom @@ -1,6 +1,6 @@ - -/* -comment -blocks -*/ + +/* +comment +blocks +*/ pragma circom 2.0.0; \ No newline at end of file diff --git a/crates/syntax/src/test_files/happy/full_circom_program.circom b/crates/syntax/src/test_files/happy/full_circom_program.circom index d2a7757..95d1d88 100644 --- a/crates/syntax/src/test_files/happy/full_circom_program.circom +++ b/crates/syntax/src/test_files/happy/full_circom_program.circom @@ -1,99 +1,99 @@ -/* - Copyright 2018 0KIMS association. - - This file is part of circom (Zero Knowledge Circuit Compiler). - - circom is a 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. - - circom 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 circom. If not, see . -*/ -/* - -Binary Sum -========== - -This component creates a binary sum componet of ops operands and n bits each operand. - -e is Number of carries: Depends on the number of operands in the input. - -Main Constraint: - in[0][0] * 2^0 + in[0][1] * 2^1 + ..... + in[0][n-1] * 2^(n-1) + - + in[1][0] * 2^0 + in[1][1] * 2^1 + ..... + in[1][n-1] * 2^(n-1) + - + .. - + in[ops-1][0] * 2^0 + in[ops-1][1] * 2^1 + ..... + in[ops-1][n-1] * 2^(n-1) + - === - out[0] * 2^0 + out[1] * 2^1 + + out[n+e-1] *2(n+e-1) - -To waranty binary outputs: - - out[0] * (out[0] - 1) === 0 - out[1] * (out[0] - 1) === 0 - . - . - . - out[n+e-1] * (out[n+e-1] - 1) == 0 - - */ - - -/* - This function calculates the number of extra bits in the output to do the full sum. - */ - pragma circom 2.0.0; - -function nbits(a) { - var n = 1; - var r = 0; - while (n-1> k) & 1; - - // Ensure out is binary - out[k] * (out[k] - 1) === 0; - - lout += out[k] * e2; - - e2 = e2+e2; - } - - // Ensure the sum; - - lin === lout; - } +/* + Copyright 2018 0KIMS association. + + This file is part of circom (Zero Knowledge Circuit Compiler). + + circom is a 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. + + circom 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 circom. If not, see . +*/ +/* + +Binary Sum +========== + +This component creates a binary sum componet of ops operands and n bits each operand. + +e is Number of carries: Depends on the number of operands in the input. + +Main Constraint: + in[0][0] * 2^0 + in[0][1] * 2^1 + ..... + in[0][n-1] * 2^(n-1) + + + in[1][0] * 2^0 + in[1][1] * 2^1 + ..... + in[1][n-1] * 2^(n-1) + + + .. + + in[ops-1][0] * 2^0 + in[ops-1][1] * 2^1 + ..... + in[ops-1][n-1] * 2^(n-1) + + === + out[0] * 2^0 + out[1] * 2^1 + + out[n+e-1] *2(n+e-1) + +To waranty binary outputs: + + out[0] * (out[0] - 1) === 0 + out[1] * (out[0] - 1) === 0 + . + . + . + out[n+e-1] * (out[n+e-1] - 1) == 0 + + */ + + +/* + This function calculates the number of extra bits in the output to do the full sum. + */ + pragma circom 2.0.0; + +function nbits(a) { + var n = 1; + var r = 0; + while (n-1> k) & 1; + + // Ensure out is binary + out[k] * (out[k] - 1) === 0; + + lout += out[k] * e2; + + e2 = e2+e2; + } + + // Ensure the sum; + + lin === lout; + } diff --git a/crates/syntax/src/test_files/happy/line_comment.circom b/crates/syntax/src/test_files/happy/line_comment.circom index d293753..5458e32 100644 --- a/crates/syntax/src/test_files/happy/line_comment.circom +++ b/crates/syntax/src/test_files/happy/line_comment.circom @@ -1,4 +1,4 @@ - -// comment :> - - pragma circom 2.0.0; + +// comment :> + + pragma circom 2.0.0; diff --git a/crates/syntax/src/test_files/happy/no_pragma.circom b/crates/syntax/src/test_files/happy/no_pragma.circom index 678dd3d..0e46b54 100644 --- a/crates/syntax/src/test_files/happy/no_pragma.circom +++ b/crates/syntax/src/test_files/happy/no_pragma.circom @@ -1,2 +1,2 @@ -// no pragma here +// no pragma here template Multiplier2 () {} \ No newline at end of file diff --git a/crates/syntax/src/test_files/happy/pragma.circom b/crates/syntax/src/test_files/happy/pragma.circom index 8a5d3da..8aa217d 100644 --- a/crates/syntax/src/test_files/happy/pragma.circom +++ b/crates/syntax/src/test_files/happy/pragma.circom @@ -1 +1 @@ -pragma circom 2.0.0; +pragma circom 2.0.0; diff --git a/crates/syntax/src/test_files/happy/template.circom b/crates/syntax/src/test_files/happy/template.circom index ad25810..c39d42d 100644 --- a/crates/syntax/src/test_files/happy/template.circom +++ b/crates/syntax/src/test_files/happy/template.circom @@ -1,13 +1,13 @@ -template MultiplierN (N, P, QQ) { - //Declaration of signals and components. - signal input in[N]; - signal output out; - component comp[N-1]; - - //Statements. - for(var i = 0; i < N-1; i++){ - comp[i] = Multiplier2(); - } - -} +template MultiplierN (N, P, QQ) { + //Declaration of signals and components. + signal input in[N]; + signal output out; + component comp[N-1]; + + //Statements. + for(var i = 0; i < N-1; i++){ + comp[i] = Multiplier2(); + } + +} \ No newline at end of file diff --git a/crates/syntax/src/utils.rs b/crates/syntax/src/utils.rs index 76de9f3..f173682 100644 --- a/crates/syntax/src/utils.rs +++ b/crates/syntax/src/utils.rs @@ -1,10 +1,10 @@ -#[macro_export] -macro_rules! test_syntax { - ($file_path:expr, $scope: expr) => { - let crate_path = std::env::var("CARGO_MANIFEST_DIR").unwrap(); - let full_path = format!("{}{}", crate_path, $file_path); - let source = std::fs::read_to_string(full_path).expect("Should not failed"); - let syntax = crate::syntax::syntax_node_from_source(&source, $scope); - insta::assert_snapshot!($file_path, crate::view_syntax::view_ast(&syntax)); - }; -} +#[macro_export] +macro_rules! test_syntax { + ($file_path:expr, $scope: expr) => { + let crate_path = std::env::var("CARGO_MANIFEST_DIR").unwrap(); + let full_path = format!("{}{}", crate_path, $file_path); + let source = std::fs::read_to_string(full_path).expect("Should not failed"); + let syntax = crate::syntax::syntax_node_from_source(&source, $scope); + insta::assert_snapshot!($file_path, crate::view_syntax::view_ast(&syntax)); + }; +} diff --git a/crates/syntax/src/view_syntax.rs b/crates/syntax/src/view_syntax.rs index 35edfb6..270c710 100644 --- a/crates/syntax/src/view_syntax.rs +++ b/crates/syntax/src/view_syntax.rs @@ -1,52 +1,49 @@ -use crate::syntax_node::{SyntaxNode, SyntaxToken}; - -pub use rowan::{ - api::Preorder, Direction, GreenNode, NodeOrToken, SyntaxText, TextRange, TextSize, - TokenAtOffset, WalkEvent, -}; - -fn level_str(level: u32) -> String { - let mut ans = String::from(""); - - for _i in 0..level { - ans.push_str("| "); - } - ans -} - -pub(crate) fn view_ast(node: &SyntaxNode) -> String { - let mut level = 0; - let mut result = String::new(); - for event in node.preorder_with_tokens() { - match event { - WalkEvent::Enter(it) => { - match it { - NodeOrToken::Node(node) => { - result.push_str(&format!( - "{} {:?} {:?}", - level_str(level), - node.kind(), - node.text_range() - )); - } - NodeOrToken::Token(token) => { - result.push_str(&format!( - "{} {:?} {:?} {:?}", - level_str(level), - token.kind(), - token.text_range(), - token.text() - )); - } - } - result.push('\n'); - level = level + 1; - } - - WalkEvent::Leave(_it) => { - level = level - 1; - } - } - } - return result; -} +use crate::syntax_node::SyntaxNode; + +pub use rowan::{NodeOrToken, WalkEvent}; + +fn level_str(level: u32) -> String { + let mut ans = String::from(""); + + for _i in 0..level { + ans.push_str("| "); + } + ans +} + +pub(crate) fn view_ast(node: &SyntaxNode) -> String { + let mut level = 0; + let mut result = String::new(); + for event in node.preorder_with_tokens() { + match event { + WalkEvent::Enter(it) => { + match it { + NodeOrToken::Node(node) => { + result.push_str(&format!( + "{} {:?} {:?}", + level_str(level), + node.kind(), + node.text_range() + )); + } + NodeOrToken::Token(token) => { + result.push_str(&format!( + "{} {:?} {:?} {:?}", + level_str(level), + token.kind(), + token.text_range(), + token.text() + )); + } + } + result.push('\n'); + level = level + 1; + } + + WalkEvent::Leave(_it) => { + level = level - 1; + } + } + } + return result; +}