mirror of
https://github.com/danog/parser.git
synced 2025-01-23 05:21:22 +01:00
all: clippy
This commit is contained in:
parent
013e2403ad
commit
f5c3143468
@ -2,7 +2,7 @@ use std::fmt::Display;
|
||||
|
||||
pub type Span = (usize, usize);
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
#[derive(Debug, Eq, PartialEq, Clone)]
|
||||
pub enum OpenTagKind {
|
||||
Full,
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ use trunk_lexer::TokenKind;
|
||||
pub type Block = Vec<Statement>;
|
||||
pub type Program = Block;
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Serialize)]
|
||||
#[derive(Debug, Eq, PartialEq, Clone, Serialize)]
|
||||
pub enum Type {
|
||||
Plain(String),
|
||||
Nullable(String),
|
||||
@ -12,7 +12,7 @@ pub enum Type {
|
||||
Intersection(Vec<String>),
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Serialize)]
|
||||
#[derive(Debug, Eq, PartialEq, Clone, Serialize)]
|
||||
pub struct Identifier {
|
||||
name: String,
|
||||
}
|
||||
@ -61,7 +61,7 @@ impl From<&str> for Param {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
||||
#[derive(Debug, Clone, Eq, PartialEq, Serialize)]
|
||||
pub enum PropertyFlag {
|
||||
Public,
|
||||
Protected,
|
||||
@ -81,7 +81,7 @@ impl From<TokenKind> for PropertyFlag {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
||||
#[derive(Debug, Clone, Eq, PartialEq, Serialize)]
|
||||
pub enum MethodFlag {
|
||||
Final,
|
||||
Abstract,
|
||||
@ -105,7 +105,7 @@ impl From<TokenKind> for MethodFlag {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
||||
#[derive(Debug, Clone, Eq, PartialEq, Serialize)]
|
||||
pub enum ClassFlag {
|
||||
Final,
|
||||
Abstract,
|
||||
@ -203,7 +203,7 @@ pub enum Statement {
|
||||
Noop,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
||||
#[derive(Debug, Clone, Eq, PartialEq, Serialize)]
|
||||
pub enum ConstFlag {
|
||||
Final,
|
||||
Public,
|
||||
@ -223,7 +223,7 @@ impl From<TokenKind> for ConstFlag {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
||||
#[derive(Debug, Clone, Eq, PartialEq, Serialize)]
|
||||
pub struct Use {
|
||||
pub name: Identifier,
|
||||
pub alias: Option<Identifier>,
|
||||
@ -252,7 +252,7 @@ pub struct ArrayItem {
|
||||
pub value: Expression,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Serialize)]
|
||||
#[derive(Debug, Eq, PartialEq, Clone, Serialize)]
|
||||
pub enum InfixOp {
|
||||
Add,
|
||||
Sub,
|
||||
|
@ -1,6 +1,6 @@
|
||||
use std::{vec::IntoIter, fmt::{Display}};
|
||||
use trunk_lexer::{Token, TokenKind, Span};
|
||||
use crate::{Program, Statement, Block, Expression, ast::{ArrayItem, Use, MethodFlag, ClassFlag, ElseIf}, Identifier, Type, Param};
|
||||
use crate::{Program, Statement, Block, Expression, ast::{ArrayItem, Use, MethodFlag, ClassFlag, ElseIf}, Identifier, Type};
|
||||
|
||||
type ParseResult<T> = Result<T, ParseError>;
|
||||
|
||||
@ -338,7 +338,7 @@ impl Parser {
|
||||
|
||||
expect!(self, TokenKind::LeftBrace, "expected {");
|
||||
|
||||
let mut r#else = self.block(&TokenKind::RightBrace)?;
|
||||
let r#else = self.block(&TokenKind::RightBrace)?;
|
||||
|
||||
expect!(self, TokenKind::RightBrace, "expected }");
|
||||
|
||||
@ -415,7 +415,7 @@ impl Parser {
|
||||
|
||||
expect!(self, TokenKind::LeftBrace, "expected {");
|
||||
|
||||
let mut body = self.block(&TokenKind::RightBrace)?;
|
||||
let body = self.block(&TokenKind::RightBrace)?;
|
||||
|
||||
expect!(self, TokenKind::RightBrace, "expected }");
|
||||
|
||||
@ -626,7 +626,7 @@ impl Parser {
|
||||
}
|
||||
},
|
||||
// TODO: Support use statements.
|
||||
_ => return Err(ParseError::UnexpectedToken(format!("{}", self.current.kind), self.current.span))
|
||||
_ => Err(ParseError::UnexpectedToken(format!("{}", self.current.kind), self.current.span))
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user