Skip to content

Commit

Permalink
Remove crufty comments and erroneously commmited file
Browse files Browse the repository at this point in the history
  • Loading branch information
jlapeyre committed Jan 20, 2024
1 parent 035def4 commit 2f0bba2
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 331 deletions.
27 changes: 1 addition & 26 deletions crates/oq3_syntax/src/ast/expr_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ impl ast::IfStmt {
}

// FIXME: this may have supported more than what is below.
// OQ3 appears not to have `elif`-like construct. So this is not useful.
// pub fn else_branch(&self) -> Option<ElseBranch> {
// match support::children(self.syntax()).nth(2)? {
// ast::Expr::BlockExpr(block) => Some(ElseBranch::Block(block)),
Expand Down Expand Up @@ -146,17 +147,6 @@ impl ast::IfStmt {
// assert_eq!(else_.syntax().text(), r#"{ "else" }"#);
// }

// FIXME: use fn lhs instead. This was for testing GJL
// impl ast::BinExpr {
// pub fn get_lhs(&self) -> Option<ast::Expr> {
// let c1 = self.syntax().first_child();
// match c1 {
// Some(c1) => ast::Expr::cast(c1),
// None => None
// }
// }
// }

impl ast::BinExpr {
pub fn op_details(&self) -> Option<(SyntaxToken, BinaryOp)> {
self.syntax().children_with_tokens().filter_map(|it| it.into_token()).find_map(|c| {
Expand Down Expand Up @@ -291,8 +281,6 @@ pub enum LiteralKind {
Bool(bool),
}

// only for OQ3
// This is not for use in the expression tree.
// Literal strings in OQ3 occur only in a few contexts.
impl ast::FilePath {
pub fn token(&self) -> SyntaxToken {
Expand Down Expand Up @@ -408,25 +396,12 @@ impl ast::ArgList {
}
}

// ? is this used?
// #[derive(Debug, Clone, PartialEq, Eq)]
// pub enum IndexedIdentifier {
// Param(ast::Param),
// IndexExpr(ast::IndexExpr),
// }

impl ast::IndexedIdentifier {
pub fn identifier(&self) -> Option<ast::Identifier> {
support::child(&self.syntax)
}
}

// impl ast::AssignmentStmt {
// pub fn indexed_identifier(&self) -> Option<ast::IndexedIdentifier> {
// support::child(&self.syntax)
// }
// }

impl ast::AssignmentStmt {
pub fn rhs(&self) -> Option<ast::Expr> {
let mut children: AstChildren<ast::Expr> = support::children(self.syntax());
Expand Down
40 changes: 2 additions & 38 deletions crates/oq3_syntax/src/ast/node_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,14 @@
//! These methods should only do simple, shallow tasks related to the syntax of the node itself.

use std::borrow::Cow;

//use parser::SyntaxKind;
use rowan::{GreenNodeData, GreenTokenData};

use crate::{
ast::{self, support, AstNode, SyntaxNode},
NodeOrToken, TokenText,
};
// SyntaxElement, HasAttrs, HasName,

// This function, `text` is borrowe frm r-a (may still be commented out below.
// This function, `text` is borrowed from r-a (may still be commented out below.)
// There is another method, also called `text` implemented for `SyntaxNode`.
// The present function differs in that it returns the text of the first token
// rather than the text of all tokens in the subtree.
Expand All @@ -31,7 +28,7 @@ pub trait HasTextName: AstNode {
}

// FIXME: is this ok? The name of the function does not seem idiomatic
// Nor is returning and owned string. but in practice, at the moment, we always,
// Nor is returning an owned string. but in practice, at the moment, we always,
// convert text immediately to a `String`.
fn string(&self) -> String {
self.text().to_string()
Expand All @@ -51,18 +48,6 @@ impl HasTextName for ast::Identifier {}
// }
// }

// impl ast::Identifier {
// pub fn text(&self) -> TokenText<'_> {
// text_of_first_token(self.syntax())
// }
// }

// impl ast::Param {
// pub fn text(&self) -> TokenText<'_> {
// text_of_first_token(self.syntax())
// }
// }

fn text_of_first_token(node: &SyntaxNode) -> TokenText<'_> {
fn first_token(green_ref: &GreenNodeData) -> &GreenTokenData {
green_ref
Expand All @@ -78,27 +63,6 @@ fn text_of_first_token(node: &SyntaxNode) -> TokenText<'_> {
}
}

// FIXME. rename `fn statments` in nodes.rs and then
// rename get_statements to statements.
// impl ast::BlockExpr {
// pub fn get_statements(&self) -> impl Iterator<Item = ast::Stmt> {
// self.statements().into_iter().flat_map(|it| it.statements())
// self.statements().into_iter().flat_map(|it| it.statements())
// }
// only in rust
// pub fn tail_expr(&self) -> Option<ast::Expr> {
// self.stmt_list()?.tail_expr()
// }
// }

// impl ast::HasModuleItem for ast::BlockExpr {}

// impl ast::BlockExpr {
// pub fn get_statements(&self) -> impl Iterator<Item = ast::Stmt> {
// self.into_iter().flat_map(|it| it.statements())
// }
// }

impl ast::ForStmt {
pub fn iterable(&self) -> Option<ast::Expr> {
// If the iterable is a BlockExpr, check if the body is missing.
Expand Down
252 changes: 0 additions & 252 deletions crates/oq3_syntax/src/ast/prec.rs.new

This file was deleted.

Loading

0 comments on commit 2f0bba2

Please sign in to comment.