mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-12 23:55:21 +00:00
Flatten rustpython_parser interface
This commit is contained in:
parent
8580e4ebb5
commit
cb8c6fb78d
7 changed files with 168 additions and 177 deletions
|
@ -7,10 +7,9 @@ use crate::{
|
|||
ast,
|
||||
lexer::{LexicalError, LexicalErrorType},
|
||||
function::{ArgumentList, parse_args, parse_params, validate_arguments},
|
||||
lexer,
|
||||
context::set_context,
|
||||
string::parse_strings,
|
||||
token::StringKind,
|
||||
token::{self, StringKind},
|
||||
};
|
||||
use num_bigint::BigInt;
|
||||
|
||||
|
@ -1937,106 +1936,106 @@ extern {
|
|||
type Location = ast::Location;
|
||||
type Error = LexicalError;
|
||||
|
||||
enum lexer::Tok {
|
||||
Indent => lexer::Tok::Indent,
|
||||
Dedent => lexer::Tok::Dedent,
|
||||
StartModule => lexer::Tok::StartModule,
|
||||
StartInteractive => lexer::Tok::StartInteractive,
|
||||
StartExpression => lexer::Tok::StartExpression,
|
||||
"+" => lexer::Tok::Plus,
|
||||
"-" => lexer::Tok::Minus,
|
||||
"~" => lexer::Tok::Tilde,
|
||||
":" => lexer::Tok::Colon,
|
||||
"." => lexer::Tok::Dot,
|
||||
"..." => lexer::Tok::Ellipsis,
|
||||
"," => lexer::Tok::Comma,
|
||||
"*" => lexer::Tok::Star,
|
||||
"**" => lexer::Tok::DoubleStar,
|
||||
"&" => lexer::Tok::Amper,
|
||||
"@" => lexer::Tok::At,
|
||||
"%" => lexer::Tok::Percent,
|
||||
"//" => lexer::Tok::DoubleSlash,
|
||||
"^" => lexer::Tok::CircumFlex,
|
||||
"|" => lexer::Tok::Vbar,
|
||||
"<<" => lexer::Tok::LeftShift,
|
||||
">>" => lexer::Tok::RightShift,
|
||||
"/" => lexer::Tok::Slash,
|
||||
"(" => lexer::Tok::Lpar,
|
||||
")" => lexer::Tok::Rpar,
|
||||
"[" => lexer::Tok::Lsqb,
|
||||
"]" => lexer::Tok::Rsqb,
|
||||
"{" => lexer::Tok::Lbrace,
|
||||
"}" => lexer::Tok::Rbrace,
|
||||
"=" => lexer::Tok::Equal,
|
||||
"+=" => lexer::Tok::PlusEqual,
|
||||
"-=" => lexer::Tok::MinusEqual,
|
||||
"*=" => lexer::Tok::StarEqual,
|
||||
"@=" => lexer::Tok::AtEqual,
|
||||
"/=" => lexer::Tok::SlashEqual,
|
||||
"%=" => lexer::Tok::PercentEqual,
|
||||
"&=" => lexer::Tok::AmperEqual,
|
||||
"|=" => lexer::Tok::VbarEqual,
|
||||
"^=" => lexer::Tok::CircumflexEqual,
|
||||
"<<=" => lexer::Tok::LeftShiftEqual,
|
||||
">>=" => lexer::Tok::RightShiftEqual,
|
||||
"**=" => lexer::Tok::DoubleStarEqual,
|
||||
"//=" => lexer::Tok::DoubleSlashEqual,
|
||||
":=" => lexer::Tok::ColonEqual,
|
||||
"==" => lexer::Tok::EqEqual,
|
||||
"!=" => lexer::Tok::NotEqual,
|
||||
"<" => lexer::Tok::Less,
|
||||
"<=" => lexer::Tok::LessEqual,
|
||||
">" => lexer::Tok::Greater,
|
||||
">=" => lexer::Tok::GreaterEqual,
|
||||
"->" => lexer::Tok::Rarrow,
|
||||
"and" => lexer::Tok::And,
|
||||
"as" => lexer::Tok::As,
|
||||
"assert" => lexer::Tok::Assert,
|
||||
"async" => lexer::Tok::Async,
|
||||
"await" => lexer::Tok::Await,
|
||||
"break" => lexer::Tok::Break,
|
||||
"class" => lexer::Tok::Class,
|
||||
"continue" => lexer::Tok::Continue,
|
||||
"def" => lexer::Tok::Def,
|
||||
"del" => lexer::Tok::Del,
|
||||
"elif" => lexer::Tok::Elif,
|
||||
"else" => lexer::Tok::Else,
|
||||
"except" => lexer::Tok::Except,
|
||||
"finally" => lexer::Tok::Finally,
|
||||
"for" => lexer::Tok::For,
|
||||
"from" => lexer::Tok::From,
|
||||
"global" => lexer::Tok::Global,
|
||||
"if" => lexer::Tok::If,
|
||||
"import" => lexer::Tok::Import,
|
||||
"in" => lexer::Tok::In,
|
||||
"is" => lexer::Tok::Is,
|
||||
"lambda" => lexer::Tok::Lambda,
|
||||
"nonlocal" => lexer::Tok::Nonlocal,
|
||||
"not" => lexer::Tok::Not,
|
||||
"or" => lexer::Tok::Or,
|
||||
"pass" => lexer::Tok::Pass,
|
||||
"raise" => lexer::Tok::Raise,
|
||||
"return" => lexer::Tok::Return,
|
||||
"try" => lexer::Tok::Try,
|
||||
"while" => lexer::Tok::While,
|
||||
"match" => lexer::Tok::Match,
|
||||
"case" => lexer::Tok::Case,
|
||||
"with" => lexer::Tok::With,
|
||||
"yield" => lexer::Tok::Yield,
|
||||
"True" => lexer::Tok::True,
|
||||
"False" => lexer::Tok::False,
|
||||
"None" => lexer::Tok::None,
|
||||
int => lexer::Tok::Int { value: <BigInt> },
|
||||
float => lexer::Tok::Float { value: <f64> },
|
||||
complex => lexer::Tok::Complex { real: <f64>, imag: <f64> },
|
||||
string => lexer::Tok::String {
|
||||
enum token::Tok {
|
||||
Indent => token::Tok::Indent,
|
||||
Dedent => token::Tok::Dedent,
|
||||
StartModule => token::Tok::StartModule,
|
||||
StartInteractive => token::Tok::StartInteractive,
|
||||
StartExpression => token::Tok::StartExpression,
|
||||
"+" => token::Tok::Plus,
|
||||
"-" => token::Tok::Minus,
|
||||
"~" => token::Tok::Tilde,
|
||||
":" => token::Tok::Colon,
|
||||
"." => token::Tok::Dot,
|
||||
"..." => token::Tok::Ellipsis,
|
||||
"," => token::Tok::Comma,
|
||||
"*" => token::Tok::Star,
|
||||
"**" => token::Tok::DoubleStar,
|
||||
"&" => token::Tok::Amper,
|
||||
"@" => token::Tok::At,
|
||||
"%" => token::Tok::Percent,
|
||||
"//" => token::Tok::DoubleSlash,
|
||||
"^" => token::Tok::CircumFlex,
|
||||
"|" => token::Tok::Vbar,
|
||||
"<<" => token::Tok::LeftShift,
|
||||
">>" => token::Tok::RightShift,
|
||||
"/" => token::Tok::Slash,
|
||||
"(" => token::Tok::Lpar,
|
||||
")" => token::Tok::Rpar,
|
||||
"[" => token::Tok::Lsqb,
|
||||
"]" => token::Tok::Rsqb,
|
||||
"{" => token::Tok::Lbrace,
|
||||
"}" => token::Tok::Rbrace,
|
||||
"=" => token::Tok::Equal,
|
||||
"+=" => token::Tok::PlusEqual,
|
||||
"-=" => token::Tok::MinusEqual,
|
||||
"*=" => token::Tok::StarEqual,
|
||||
"@=" => token::Tok::AtEqual,
|
||||
"/=" => token::Tok::SlashEqual,
|
||||
"%=" => token::Tok::PercentEqual,
|
||||
"&=" => token::Tok::AmperEqual,
|
||||
"|=" => token::Tok::VbarEqual,
|
||||
"^=" => token::Tok::CircumflexEqual,
|
||||
"<<=" => token::Tok::LeftShiftEqual,
|
||||
">>=" => token::Tok::RightShiftEqual,
|
||||
"**=" => token::Tok::DoubleStarEqual,
|
||||
"//=" => token::Tok::DoubleSlashEqual,
|
||||
":=" => token::Tok::ColonEqual,
|
||||
"==" => token::Tok::EqEqual,
|
||||
"!=" => token::Tok::NotEqual,
|
||||
"<" => token::Tok::Less,
|
||||
"<=" => token::Tok::LessEqual,
|
||||
">" => token::Tok::Greater,
|
||||
">=" => token::Tok::GreaterEqual,
|
||||
"->" => token::Tok::Rarrow,
|
||||
"and" => token::Tok::And,
|
||||
"as" => token::Tok::As,
|
||||
"assert" => token::Tok::Assert,
|
||||
"async" => token::Tok::Async,
|
||||
"await" => token::Tok::Await,
|
||||
"break" => token::Tok::Break,
|
||||
"class" => token::Tok::Class,
|
||||
"continue" => token::Tok::Continue,
|
||||
"def" => token::Tok::Def,
|
||||
"del" => token::Tok::Del,
|
||||
"elif" => token::Tok::Elif,
|
||||
"else" => token::Tok::Else,
|
||||
"except" => token::Tok::Except,
|
||||
"finally" => token::Tok::Finally,
|
||||
"for" => token::Tok::For,
|
||||
"from" => token::Tok::From,
|
||||
"global" => token::Tok::Global,
|
||||
"if" => token::Tok::If,
|
||||
"import" => token::Tok::Import,
|
||||
"in" => token::Tok::In,
|
||||
"is" => token::Tok::Is,
|
||||
"lambda" => token::Tok::Lambda,
|
||||
"nonlocal" => token::Tok::Nonlocal,
|
||||
"not" => token::Tok::Not,
|
||||
"or" => token::Tok::Or,
|
||||
"pass" => token::Tok::Pass,
|
||||
"raise" => token::Tok::Raise,
|
||||
"return" => token::Tok::Return,
|
||||
"try" => token::Tok::Try,
|
||||
"while" => token::Tok::While,
|
||||
"match" => token::Tok::Match,
|
||||
"case" => token::Tok::Case,
|
||||
"with" => token::Tok::With,
|
||||
"yield" => token::Tok::Yield,
|
||||
"True" => token::Tok::True,
|
||||
"False" => token::Tok::False,
|
||||
"None" => token::Tok::None,
|
||||
int => token::Tok::Int { value: <BigInt> },
|
||||
float => token::Tok::Float { value: <f64> },
|
||||
complex => token::Tok::Complex { real: <f64>, imag: <f64> },
|
||||
string => token::Tok::String {
|
||||
value: <String>,
|
||||
kind: <StringKind>,
|
||||
triple_quoted: <bool>
|
||||
},
|
||||
name => lexer::Tok::Name { name: <String> },
|
||||
"\n" => lexer::Tok::Newline,
|
||||
";" => lexer::Tok::Semi,
|
||||
"#" => lexer::Tok::Comment(_),
|
||||
name => token::Tok::Name { name: <String> },
|
||||
"\n" => token::Tok::Newline,
|
||||
";" => token::Tok::Semi,
|
||||
"#" => token::Tok::Comment(_),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue