mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-07 21:25:31 +00:00
Update cspell for compiler
This commit is contained in:
parent
ef38eb6b1a
commit
f9b5469642
27 changed files with 158 additions and 213 deletions
|
@ -48,10 +48,10 @@ impl<'a> Unparser<'a> {
|
|||
}
|
||||
|
||||
fn unparse_expr<U>(&mut self, ast: &Expr<U>, level: u8) -> fmt::Result {
|
||||
macro_rules! opprec {
|
||||
($opty:ident, $x:expr, $enu:path, $($var:ident($op:literal, $prec:ident)),*$(,)?) => {
|
||||
macro_rules! op_prec {
|
||||
($op_ty:ident, $x:expr, $enu:path, $($var:ident($op:literal, $prec:ident)),*$(,)?) => {
|
||||
match $x {
|
||||
$(<$enu>::$var => (opprec!(@space $opty, $op), precedence::$prec),)*
|
||||
$(<$enu>::$var => (op_prec!(@space $op_ty, $op), precedence::$prec),)*
|
||||
}
|
||||
};
|
||||
(@space bin, $op:literal) => {
|
||||
|
@ -72,7 +72,7 @@ impl<'a> Unparser<'a> {
|
|||
}
|
||||
match &ast.node {
|
||||
ExprKind::BoolOp { op, values } => {
|
||||
let (op, prec) = opprec!(bin, op, Boolop, And("and", AND), Or("or", OR));
|
||||
let (op, prec) = op_prec!(bin, op, Boolop, And("and", AND), Or("or", OR));
|
||||
group_if!(prec, {
|
||||
let mut first = true;
|
||||
for val in values {
|
||||
|
@ -89,8 +89,8 @@ impl<'a> Unparser<'a> {
|
|||
})
|
||||
}
|
||||
ExprKind::BinOp { left, op, right } => {
|
||||
let rassoc = matches!(op, Operator::Pow);
|
||||
let (op, prec) = opprec!(
|
||||
let right_associative = matches!(op, Operator::Pow);
|
||||
let (op, prec) = op_prec!(
|
||||
bin,
|
||||
op,
|
||||
Operator,
|
||||
|
@ -109,13 +109,13 @@ impl<'a> Unparser<'a> {
|
|||
FloorDiv("//", TERM),
|
||||
);
|
||||
group_if!(prec, {
|
||||
self.unparse_expr(left, prec + rassoc as u8)?;
|
||||
self.unparse_expr(left, prec + right_associative as u8)?;
|
||||
self.p(op)?;
|
||||
self.unparse_expr(right, prec + !rassoc as u8)?;
|
||||
self.unparse_expr(right, prec + !right_associative as u8)?;
|
||||
})
|
||||
}
|
||||
ExprKind::UnaryOp { op, operand } => {
|
||||
let (op, prec) = opprec!(
|
||||
let (op, prec) = op_prec!(
|
||||
un,
|
||||
op,
|
||||
crate::Unaryop,
|
||||
|
@ -131,8 +131,8 @@ impl<'a> Unparser<'a> {
|
|||
}
|
||||
ExprKind::Lambda { args, body } => {
|
||||
group_if!(precedence::TEST, {
|
||||
let npos = args.args.len() + args.posonlyargs.len();
|
||||
self.p(if npos > 0 { "lambda " } else { "lambda" })?;
|
||||
let pos = args.args.len() + args.posonlyargs.len();
|
||||
self.p(if pos > 0 { "lambda " } else { "lambda" })?;
|
||||
self.unparse_args(args)?;
|
||||
write!(self, ": {}", **body)?;
|
||||
})
|
||||
|
@ -260,7 +260,7 @@ impl<'a> Unparser<'a> {
|
|||
[],
|
||||
) = (&**args, &**keywords)
|
||||
{
|
||||
// make sure a single genexp doesn't get double parens
|
||||
// make sure a single genexpr doesn't get double parens
|
||||
self.unparse_expr(elt, precedence::TEST)?;
|
||||
self.unparse_comp(generators)?;
|
||||
} else {
|
||||
|
@ -287,7 +287,7 @@ impl<'a> Unparser<'a> {
|
|||
conversion,
|
||||
format_spec,
|
||||
} => self.unparse_formatted(value, *conversion, format_spec.as_deref())?,
|
||||
ExprKind::JoinedStr { values } => self.unparse_joinedstr(values, false)?,
|
||||
ExprKind::JoinedStr { values } => self.unparse_joined_str(values, false)?,
|
||||
ExprKind::Constant { value, kind } => {
|
||||
if let Some(kind) = kind {
|
||||
self.p(kind)?;
|
||||
|
@ -490,7 +490,7 @@ impl<'a> Unparser<'a> {
|
|||
unreachable!()
|
||||
}
|
||||
}
|
||||
ExprKind::JoinedStr { values } => self.unparse_joinedstr(values, is_spec),
|
||||
ExprKind::JoinedStr { values } => self.unparse_joined_str(values, is_spec),
|
||||
ExprKind::FormattedValue {
|
||||
value,
|
||||
conversion,
|
||||
|
@ -505,7 +505,7 @@ impl<'a> Unparser<'a> {
|
|||
self.p(&s)
|
||||
}
|
||||
|
||||
fn unparse_joinedstr<U>(&mut self, values: &[Expr<U>], is_spec: bool) -> fmt::Result {
|
||||
fn unparse_joined_str<U>(&mut self, values: &[Expr<U>], is_spec: bool) -> fmt::Result {
|
||||
if is_spec {
|
||||
self.unparse_fstring_body(values, is_spec)
|
||||
} else {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//! Implement python as a virtual machine with bytecodes. This module
|
||||
//! Implement python as a virtual machine with bytecode. This module
|
||||
//! implements bytecode structure.
|
||||
|
||||
use crate::{marshal, Location};
|
||||
|
@ -85,7 +85,7 @@ impl ConstantBag for BasicBag {
|
|||
}
|
||||
|
||||
/// Primary container of a single code object. Each python function has
|
||||
/// a codeobject. Also a module has a codeobject.
|
||||
/// a code object. Also a module has a code object.
|
||||
#[derive(Clone)]
|
||||
pub struct CodeObject<C: Constant = ConstantData> {
|
||||
pub instructions: Box<[CodeUnit]>,
|
||||
|
@ -147,7 +147,7 @@ impl fmt::Debug for OpArgByte {
|
|||
}
|
||||
}
|
||||
|
||||
/// a full 32-bit oparg, including any possible ExtendedArg extension
|
||||
/// a full 32-bit op_arg, including any possible ExtendedArg extension
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
#[repr(transparent)]
|
||||
pub struct OpArg(pub u32);
|
||||
|
@ -156,7 +156,7 @@ impl OpArg {
|
|||
OpArg(0)
|
||||
}
|
||||
|
||||
/// Returns how many CodeUnits a instruction with this oparg will be encoded as
|
||||
/// Returns how many CodeUnits a instruction with this op_arg will be encoded as
|
||||
#[inline]
|
||||
pub fn instr_size(self) -> usize {
|
||||
(self.0 > 0xff) as usize + (self.0 > 0xff_ff) as usize + (self.0 > 0xff_ff_ff) as usize + 1
|
||||
|
@ -204,46 +204,46 @@ impl OpArgState {
|
|||
}
|
||||
|
||||
pub trait OpArgType: Copy {
|
||||
fn from_oparg(x: u32) -> Option<Self>;
|
||||
fn to_oparg(self) -> u32;
|
||||
fn from_op_arg(x: u32) -> Option<Self>;
|
||||
fn to_op_arg(self) -> u32;
|
||||
}
|
||||
|
||||
impl OpArgType for u32 {
|
||||
#[inline(always)]
|
||||
fn from_oparg(x: u32) -> Option<Self> {
|
||||
fn from_op_arg(x: u32) -> Option<Self> {
|
||||
Some(x)
|
||||
}
|
||||
#[inline(always)]
|
||||
fn to_oparg(self) -> u32 {
|
||||
fn to_op_arg(self) -> u32 {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl OpArgType for bool {
|
||||
#[inline(always)]
|
||||
fn from_oparg(x: u32) -> Option<Self> {
|
||||
fn from_op_arg(x: u32) -> Option<Self> {
|
||||
Some(x != 0)
|
||||
}
|
||||
#[inline(always)]
|
||||
fn to_oparg(self) -> u32 {
|
||||
fn to_op_arg(self) -> u32 {
|
||||
self as u32
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! oparg_enum {
|
||||
($(#[$attr:meta])* $vis:vis enum $name:ident { $($(#[$var_attr:meta])* $var:ident = $discr:literal,)* }) => {
|
||||
macro_rules! op_arg_enum {
|
||||
($(#[$attr:meta])* $vis:vis enum $name:ident { $($(#[$var_attr:meta])* $var:ident = $value:literal,)* }) => {
|
||||
$(#[$attr])*
|
||||
$vis enum $name {
|
||||
$($(#[$var_attr])* $var = $discr,)*
|
||||
$($(#[$var_attr])* $var = $value,)*
|
||||
}
|
||||
|
||||
impl OpArgType for $name {
|
||||
fn to_oparg(self) -> u32 {
|
||||
fn to_op_arg(self) -> u32 {
|
||||
self as u32
|
||||
}
|
||||
fn from_oparg(x: u32) -> Option<Self> {
|
||||
fn from_op_arg(x: u32) -> Option<Self> {
|
||||
Some(match u8::try_from(x).ok()? {
|
||||
$($discr => Self::$var,)*
|
||||
$($value => Self::$var,)*
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
|
@ -261,7 +261,7 @@ impl<T: OpArgType> Arg<T> {
|
|||
}
|
||||
#[inline]
|
||||
pub fn new(arg: T) -> (Self, OpArg) {
|
||||
(Self(PhantomData), OpArg(arg.to_oparg()))
|
||||
(Self(PhantomData), OpArg(arg.to_op_arg()))
|
||||
}
|
||||
#[inline]
|
||||
pub fn new_single(arg: T) -> (Self, OpArgByte)
|
||||
|
@ -276,13 +276,13 @@ impl<T: OpArgType> Arg<T> {
|
|||
}
|
||||
#[inline(always)]
|
||||
pub fn try_get(self, arg: OpArg) -> Option<T> {
|
||||
T::from_oparg(arg.0)
|
||||
T::from_op_arg(arg.0)
|
||||
}
|
||||
#[inline(always)]
|
||||
/// # Safety
|
||||
/// T::from_oparg(self) must succeed
|
||||
/// T::from_op_arg(self) must succeed
|
||||
pub unsafe fn get_unchecked(self, arg: OpArg) -> T {
|
||||
match T::from_oparg(arg.0) {
|
||||
match T::from_op_arg(arg.0) {
|
||||
Some(t) => t,
|
||||
None => std::hint::unreachable_unchecked(),
|
||||
}
|
||||
|
@ -310,11 +310,11 @@ pub struct Label(pub u32);
|
|||
|
||||
impl OpArgType for Label {
|
||||
#[inline(always)]
|
||||
fn from_oparg(x: u32) -> Option<Self> {
|
||||
fn from_op_arg(x: u32) -> Option<Self> {
|
||||
Some(Label(x))
|
||||
}
|
||||
#[inline(always)]
|
||||
fn to_oparg(self) -> u32 {
|
||||
fn to_op_arg(self) -> u32 {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
@ -325,7 +325,7 @@ impl fmt::Display for Label {
|
|||
}
|
||||
}
|
||||
|
||||
oparg_enum!(
|
||||
op_arg_enum!(
|
||||
/// Transforms a value prior to formatting it.
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
#[repr(u8)]
|
||||
|
@ -344,11 +344,11 @@ oparg_enum!(
|
|||
impl TryFrom<usize> for ConversionFlag {
|
||||
type Error = usize;
|
||||
fn try_from(b: usize) -> Result<Self, Self::Error> {
|
||||
u32::try_from(b).ok().and_then(Self::from_oparg).ok_or(b)
|
||||
u32::try_from(b).ok().and_then(Self::from_op_arg).ok_or(b)
|
||||
}
|
||||
}
|
||||
|
||||
oparg_enum!(
|
||||
op_arg_enum!(
|
||||
/// The kind of Raise that occurred.
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
#[repr(u8)]
|
||||
|
@ -634,11 +634,11 @@ bitflags! {
|
|||
}
|
||||
impl OpArgType for MakeFunctionFlags {
|
||||
#[inline(always)]
|
||||
fn from_oparg(x: u32) -> Option<Self> {
|
||||
fn from_op_arg(x: u32) -> Option<Self> {
|
||||
Some(unsafe { MakeFunctionFlags::from_bits_unchecked(x as u8) })
|
||||
}
|
||||
#[inline(always)]
|
||||
fn to_oparg(self) -> u32 {
|
||||
fn to_op_arg(self) -> u32 {
|
||||
self.bits().into()
|
||||
}
|
||||
}
|
||||
|
@ -793,7 +793,7 @@ impl<C: Constant> BorrowedConstant<'_, C> {
|
|||
}
|
||||
}
|
||||
|
||||
oparg_enum!(
|
||||
op_arg_enum!(
|
||||
/// The possible comparison operators
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
#[repr(u8)]
|
||||
|
@ -809,7 +809,7 @@ oparg_enum!(
|
|||
}
|
||||
);
|
||||
|
||||
oparg_enum!(
|
||||
op_arg_enum!(
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
#[repr(u8)]
|
||||
pub enum TestOperator {
|
||||
|
@ -822,7 +822,7 @@ oparg_enum!(
|
|||
}
|
||||
);
|
||||
|
||||
oparg_enum!(
|
||||
op_arg_enum!(
|
||||
/// The possible Binary operators
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -850,7 +850,7 @@ oparg_enum!(
|
|||
}
|
||||
);
|
||||
|
||||
oparg_enum!(
|
||||
op_arg_enum!(
|
||||
/// The possible unary operators
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
#[repr(u8)]
|
||||
|
@ -870,12 +870,12 @@ pub struct UnpackExArgs {
|
|||
|
||||
impl OpArgType for UnpackExArgs {
|
||||
#[inline(always)]
|
||||
fn from_oparg(x: u32) -> Option<Self> {
|
||||
fn from_op_arg(x: u32) -> Option<Self> {
|
||||
let [before, after, ..] = x.to_le_bytes();
|
||||
Some(Self { before, after })
|
||||
}
|
||||
#[inline(always)]
|
||||
fn to_oparg(self) -> u32 {
|
||||
fn to_op_arg(self) -> u32 {
|
||||
u32::from_le_bytes([self.before, self.after, 0, 0])
|
||||
}
|
||||
}
|
||||
|
@ -925,20 +925,20 @@ impl<C: Constant> CodeObject<C> {
|
|||
pub fn arg_names(&self) -> Arguments<C::Name> {
|
||||
let nargs = self.arg_count as usize;
|
||||
let nkwargs = self.kwonlyarg_count as usize;
|
||||
let mut varargspos = nargs + nkwargs;
|
||||
let mut varargs_pos = nargs + nkwargs;
|
||||
let posonlyargs = &self.varnames[..self.posonlyarg_count as usize];
|
||||
let args = &self.varnames[..nargs];
|
||||
let kwonlyargs = &self.varnames[nargs..varargspos];
|
||||
let kwonlyargs = &self.varnames[nargs..varargs_pos];
|
||||
|
||||
let vararg = if self.flags.contains(CodeFlags::HAS_VARARGS) {
|
||||
let vararg = &self.varnames[varargspos];
|
||||
varargspos += 1;
|
||||
let vararg = &self.varnames[varargs_pos];
|
||||
varargs_pos += 1;
|
||||
Some(vararg)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let varkwarg = if self.flags.contains(CodeFlags::HAS_VARKEYWORDS) {
|
||||
Some(&self.varnames[varargspos])
|
||||
Some(&self.varnames[varargs_pos])
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
@ -968,7 +968,7 @@ impl<C: Constant> CodeObject<C> {
|
|||
fn display_inner(
|
||||
&self,
|
||||
f: &mut fmt::Formatter,
|
||||
expand_codeobjects: bool,
|
||||
expand_code_objects: bool,
|
||||
level: usize,
|
||||
) -> fmt::Result {
|
||||
let label_targets = self.label_targets();
|
||||
|
@ -1007,14 +1007,14 @@ impl<C: Constant> CodeObject<C> {
|
|||
write!(f, "{arrow} {offset:offset_digits$} ")?;
|
||||
|
||||
// instruction
|
||||
instruction.fmt_dis(arg, f, self, expand_codeobjects, 21, level)?;
|
||||
instruction.fmt_dis(arg, f, self, expand_code_objects, 21, level)?;
|
||||
writeln!(f)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Recursively display this CodeObject
|
||||
pub fn display_expand_codeobjects(&self) -> impl fmt::Display + '_ {
|
||||
pub fn display_expand_code_objects(&self) -> impl fmt::Display + '_ {
|
||||
struct Display<'a, C: Constant>(&'a CodeObject<C>);
|
||||
impl<C: Constant> fmt::Display for Display<'_, C> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
|
@ -1287,7 +1287,7 @@ impl Instruction {
|
|||
arg: OpArg,
|
||||
f: &mut fmt::Formatter,
|
||||
ctx: &impl InstrDisplayContext,
|
||||
expand_codeobjects: bool,
|
||||
expand_code_objects: bool,
|
||||
pad: usize,
|
||||
level: usize,
|
||||
) -> fmt::Result {
|
||||
|
@ -1295,26 +1295,26 @@ impl Instruction {
|
|||
($variant:ident) => {
|
||||
write!(f, stringify!($variant))
|
||||
};
|
||||
($variant:ident, $map:ident = $argmarker:expr) => {{
|
||||
let arg = $argmarker.get(arg);
|
||||
($variant:ident, $map:ident = $arg_marker:expr) => {{
|
||||
let arg = $arg_marker.get(arg);
|
||||
write!(f, "{:pad$}({}, {})", stringify!($variant), arg, $map(arg))
|
||||
}};
|
||||
($variant:ident, $argmarker:expr) => {
|
||||
write!(f, "{:pad$}({})", stringify!($variant), $argmarker.get(arg))
|
||||
($variant:ident, $arg_marker:expr) => {
|
||||
write!(f, "{:pad$}({})", stringify!($variant), $arg_marker.get(arg))
|
||||
};
|
||||
($variant:ident, ?$argmarker:expr) => {
|
||||
($variant:ident, ?$arg_marker:expr) => {
|
||||
write!(
|
||||
f,
|
||||
"{:pad$}({:?})",
|
||||
stringify!($variant),
|
||||
$argmarker.get(arg)
|
||||
$arg_marker.get(arg)
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
let varname = |i: u32| ctx.get_varname(i as usize);
|
||||
let name = |i: u32| ctx.get_name(i as usize);
|
||||
let cellname = |i: u32| ctx.get_cellname(i as usize);
|
||||
let cell_name = |i: u32| ctx.get_cell_name(i as usize);
|
||||
|
||||
match self {
|
||||
ImportName { idx } => w!(ImportName, name = idx),
|
||||
|
@ -1324,17 +1324,17 @@ impl Instruction {
|
|||
LoadFast(idx) => w!(LoadFast, varname = idx),
|
||||
LoadNameAny(idx) => w!(LoadNameAny, name = idx),
|
||||
LoadGlobal(idx) => w!(LoadGlobal, name = idx),
|
||||
LoadDeref(idx) => w!(LoadDeref, cellname = idx),
|
||||
LoadClassDeref(idx) => w!(LoadClassDeref, cellname = idx),
|
||||
LoadDeref(idx) => w!(LoadDeref, cell_name = idx),
|
||||
LoadClassDeref(idx) => w!(LoadClassDeref, cell_name = idx),
|
||||
StoreFast(idx) => w!(StoreFast, varname = idx),
|
||||
StoreLocal(idx) => w!(StoreLocal, name = idx),
|
||||
StoreGlobal(idx) => w!(StoreGlobal, name = idx),
|
||||
StoreDeref(idx) => w!(StoreDeref, cellname = idx),
|
||||
StoreDeref(idx) => w!(StoreDeref, cell_name = idx),
|
||||
DeleteFast(idx) => w!(DeleteFast, varname = idx),
|
||||
DeleteLocal(idx) => w!(DeleteLocal, name = idx),
|
||||
DeleteGlobal(idx) => w!(DeleteGlobal, name = idx),
|
||||
DeleteDeref(idx) => w!(DeleteDeref, cellname = idx),
|
||||
LoadClosure(i) => w!(LoadClosure, cellname = i),
|
||||
DeleteDeref(idx) => w!(DeleteDeref, cell_name = idx),
|
||||
LoadClosure(i) => w!(LoadClosure, cell_name = i),
|
||||
Subscript => w!(Subscript),
|
||||
StoreSubscript => w!(StoreSubscript),
|
||||
DeleteSubscript => w!(DeleteSubscript),
|
||||
|
@ -1343,7 +1343,7 @@ impl Instruction {
|
|||
LoadConst { idx } => {
|
||||
let value = ctx.get_constant(idx.get(arg) as usize);
|
||||
match value.borrow_constant() {
|
||||
BorrowedConstant::Code { code } if expand_codeobjects => {
|
||||
BorrowedConstant::Code { code } if expand_code_objects => {
|
||||
write!(f, "{:pad$}({:?}):", "LoadConst", code)?;
|
||||
code.display_inner(f, true, level + 1)?;
|
||||
Ok(())
|
||||
|
@ -1434,7 +1434,7 @@ pub trait InstrDisplayContext {
|
|||
fn get_constant(&self, i: usize) -> &Self::Constant;
|
||||
fn get_name(&self, i: usize) -> &str;
|
||||
fn get_varname(&self, i: usize) -> &str;
|
||||
fn get_cellname(&self, i: usize) -> &str;
|
||||
fn get_cell_name(&self, i: usize) -> &str;
|
||||
}
|
||||
|
||||
impl<C: Constant> InstrDisplayContext for CodeObject<C> {
|
||||
|
@ -1448,7 +1448,7 @@ impl<C: Constant> InstrDisplayContext for CodeObject<C> {
|
|||
fn get_varname(&self, i: usize) -> &str {
|
||||
self.varnames[i].as_ref()
|
||||
}
|
||||
fn get_cellname(&self, i: usize) -> &str {
|
||||
fn get_cell_name(&self, i: usize) -> &str {
|
||||
self.cellvars
|
||||
.get(i)
|
||||
.unwrap_or_else(|| &self.freevars[i - self.cellvars.len()])
|
||||
|
@ -1491,7 +1491,7 @@ pub mod frozen_lib {
|
|||
}
|
||||
|
||||
impl<B: AsRef<[u8]>> FrozenCodeObject<B> {
|
||||
/// Decode a frozen codeobject
|
||||
/// Decode a frozen code object
|
||||
#[inline]
|
||||
pub fn decode<Bag: AsBag>(
|
||||
&self,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Sourcecode location.
|
||||
/// Source code location.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct Location {
|
||||
|
|
|
@ -112,7 +112,7 @@ fn gen_phf(out_dir: &Path) {
|
|||
.entry("False", "Tok::False")
|
||||
.entry("None", "Tok::None")
|
||||
.entry("True", "Tok::True")
|
||||
// moreso "standard" keywords
|
||||
// more so "standard" keywords
|
||||
.entry("and", "Tok::And")
|
||||
.entry("as", "Tok::As")
|
||||
.entry("assert", "Tok::Assert")
|
||||
|
|
|
@ -241,6 +241,7 @@ where
|
|||
lxr.window.slide();
|
||||
lxr.window.slide();
|
||||
// TODO: Handle possible mismatch between BOM and explicit encoding declaration.
|
||||
// spell-checker:ignore feff
|
||||
if let Some('\u{feff}') = lxr.window[0] {
|
||||
lxr.window.slide();
|
||||
}
|
||||
|
@ -1085,7 +1086,7 @@ where
|
|||
}
|
||||
}
|
||||
' ' | '\t' | '\x0C' => {
|
||||
// Skip whitespaces
|
||||
// Skip white-spaces
|
||||
self.next_char();
|
||||
while let Some(' ' | '\t' | '\x0C') = self.window[0] {
|
||||
self.next_char();
|
||||
|
@ -1327,7 +1328,7 @@ mod tests {
|
|||
lexer.map(|x| x.unwrap().1).collect()
|
||||
}
|
||||
|
||||
fn stok(s: &str) -> Tok {
|
||||
fn str_tok(s: &str) -> Tok {
|
||||
Tok::String {
|
||||
value: s.to_owned(),
|
||||
kind: StringKind::String,
|
||||
|
@ -1335,7 +1336,7 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
fn raw_stok(s: &str) -> Tok {
|
||||
fn raw_str_tok(s: &str) -> Tok {
|
||||
Tok::String {
|
||||
value: s.to_owned(),
|
||||
kind: StringKind::RawString,
|
||||
|
@ -1434,13 +1435,13 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_assignment() {
|
||||
let source = r"avariable = 99 + 2-0";
|
||||
let source = r"a_variable = 99 + 2-0";
|
||||
let tokens = lex_source(source);
|
||||
assert_eq!(
|
||||
tokens,
|
||||
vec![
|
||||
Tok::Name {
|
||||
name: String::from("avariable"),
|
||||
name: String::from("a_variable"),
|
||||
},
|
||||
Tok::Equal,
|
||||
Tok::Int {
|
||||
|
@ -1663,13 +1664,13 @@ mod tests {
|
|||
vec![
|
||||
Tok::Lpar,
|
||||
Tok::NonLogicalNewline,
|
||||
stok("a"),
|
||||
str_tok("a"),
|
||||
Tok::NonLogicalNewline,
|
||||
stok("b"),
|
||||
str_tok("b"),
|
||||
Tok::NonLogicalNewline,
|
||||
Tok::NonLogicalNewline,
|
||||
stok("c"),
|
||||
stok("d"),
|
||||
str_tok("c"),
|
||||
str_tok("d"),
|
||||
Tok::NonLogicalNewline,
|
||||
Tok::Rpar,
|
||||
Tok::Newline,
|
||||
|
@ -1716,15 +1717,15 @@ mod tests {
|
|||
assert_eq!(
|
||||
tokens,
|
||||
vec![
|
||||
stok("double"),
|
||||
stok("single"),
|
||||
stok(r"can\'t"),
|
||||
stok(r#"\\\""#),
|
||||
stok(r"\t\r\n"),
|
||||
stok(r"\g"),
|
||||
raw_stok(r"raw\'"),
|
||||
stok(r"\420"),
|
||||
stok(r"\200\0a"),
|
||||
str_tok("double"),
|
||||
str_tok("single"),
|
||||
str_tok(r"can\'t"),
|
||||
str_tok(r#"\\\""#),
|
||||
str_tok(r"\t\r\n"),
|
||||
str_tok(r"\g"),
|
||||
raw_str_tok(r"raw\'"),
|
||||
str_tok(r"\420"),
|
||||
str_tok(r"\200\0a"),
|
||||
Tok::Newline,
|
||||
]
|
||||
);
|
||||
|
@ -1740,7 +1741,7 @@ mod tests {
|
|||
assert_eq!(
|
||||
tokens,
|
||||
vec![
|
||||
stok("abc\\\ndef"),
|
||||
str_tok("abc\\\ndef"),
|
||||
Tok::Newline,
|
||||
]
|
||||
)
|
||||
|
@ -1759,7 +1760,7 @@ mod tests {
|
|||
fn test_escape_unicode_name() {
|
||||
let source = r#""\N{EN SPACE}""#;
|
||||
let tokens = lex_source(source);
|
||||
assert_eq!(tokens, vec![stok(r"\N{EN SPACE}"), Tok::Newline])
|
||||
assert_eq!(tokens, vec![str_tok(r"\N{EN SPACE}"), Tok::Newline])
|
||||
}
|
||||
|
||||
macro_rules! test_triple_quoted {
|
||||
|
|
|
@ -433,14 +433,14 @@ class Foo(A, B):
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_boolop_or() {
|
||||
fn test_parse_bool_op_or() {
|
||||
let source = "x or y";
|
||||
let parse_ast = parse_expression(source, "<test>").unwrap();
|
||||
insta::assert_debug_snapshot!(parse_ast);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_boolop_and() {
|
||||
fn test_parse_bool_op_and() {
|
||||
let source = "x and y";
|
||||
let parse_ast = parse_expression(source, "<test>").unwrap();
|
||||
insta::assert_debug_snapshot!(parse_ast);
|
||||
|
@ -513,10 +513,10 @@ with (0 as a, 1 as b,): pass
|
|||
#[test]
|
||||
fn test_star_index() {
|
||||
let source = "\
|
||||
array_slice = array[0, *idxs, -1]
|
||||
array[0, *idxs, -1] = array_slice
|
||||
array[*idxs_to_select, *idxs_to_select]
|
||||
array[3:5, *idxs_to_select]
|
||||
array_slice = array[0, *indexes, -1]
|
||||
array[0, *indexes, -1] = array_slice
|
||||
array[*indexes_to_select, *indexes_to_select]
|
||||
array[3:5, *indexes_to_select]
|
||||
";
|
||||
let parse_ast = parse_program(source, "<test>").unwrap();
|
||||
insta::assert_debug_snapshot!(parse_ast);
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
---
|
||||
source: compiler/parser/src/context.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
Located {
|
||||
location: Location {
|
||||
row: 1,
|
||||
column: 1,
|
||||
},
|
||||
custom: (),
|
||||
node: Assign {
|
||||
targets: [
|
||||
Located {
|
||||
location: Location {
|
||||
row: 1,
|
||||
column: 1,
|
||||
},
|
||||
custom: (),
|
||||
node: Name {
|
||||
id: "x",
|
||||
ctx: Store,
|
||||
},
|
||||
},
|
||||
],
|
||||
value: Located {
|
||||
location: Location {
|
||||
row: 1,
|
||||
column: 5,
|
||||
},
|
||||
custom: (),
|
||||
node: Constant {
|
||||
value: Int(
|
||||
1,
|
||||
),
|
||||
kind: None,
|
||||
},
|
||||
},
|
||||
type_comment: None,
|
||||
},
|
||||
},
|
||||
]
|
|
@ -1,6 +1,5 @@
|
|||
---
|
||||
source: compiler/parser/src/function.rs
|
||||
assertion_line: 165
|
||||
expression: parse_ast
|
||||
---
|
||||
Ok(
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
---
|
||||
source: compiler/parser/src/function.rs
|
||||
assertion_line: 165
|
||||
expression: parse_ast
|
||||
---
|
||||
Ok(
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
source: parser/src/parser.rs
|
||||
source: compiler/parser/src/parser.rs
|
||||
expression: parse_ast
|
||||
---
|
||||
[]
|
||||
|
|
|
@ -11,7 +11,7 @@ expression: parse_ast
|
|||
end_location: Some(
|
||||
Location {
|
||||
row: 1,
|
||||
column: 33,
|
||||
column: 36,
|
||||
},
|
||||
),
|
||||
custom: (),
|
||||
|
@ -43,7 +43,7 @@ expression: parse_ast
|
|||
end_location: Some(
|
||||
Location {
|
||||
row: 1,
|
||||
column: 33,
|
||||
column: 36,
|
||||
},
|
||||
),
|
||||
custom: (),
|
||||
|
@ -73,7 +73,7 @@ expression: parse_ast
|
|||
end_location: Some(
|
||||
Location {
|
||||
row: 1,
|
||||
column: 32,
|
||||
column: 35,
|
||||
},
|
||||
),
|
||||
custom: (),
|
||||
|
@ -106,7 +106,7 @@ expression: parse_ast
|
|||
end_location: Some(
|
||||
Location {
|
||||
row: 1,
|
||||
column: 28,
|
||||
column: 31,
|
||||
},
|
||||
),
|
||||
custom: (),
|
||||
|
@ -119,12 +119,12 @@ expression: parse_ast
|
|||
end_location: Some(
|
||||
Location {
|
||||
row: 1,
|
||||
column: 28,
|
||||
column: 31,
|
||||
},
|
||||
),
|
||||
custom: (),
|
||||
node: Name {
|
||||
id: "idxs",
|
||||
id: "indexes",
|
||||
ctx: Load,
|
||||
},
|
||||
},
|
||||
|
@ -134,12 +134,12 @@ expression: parse_ast
|
|||
Located {
|
||||
location: Location {
|
||||
row: 1,
|
||||
column: 30,
|
||||
column: 33,
|
||||
},
|
||||
end_location: Some(
|
||||
Location {
|
||||
row: 1,
|
||||
column: 32,
|
||||
column: 35,
|
||||
},
|
||||
),
|
||||
custom: (),
|
||||
|
@ -148,12 +148,12 @@ expression: parse_ast
|
|||
operand: Located {
|
||||
location: Location {
|
||||
row: 1,
|
||||
column: 31,
|
||||
column: 34,
|
||||
},
|
||||
end_location: Some(
|
||||
Location {
|
||||
row: 1,
|
||||
column: 32,
|
||||
column: 35,
|
||||
},
|
||||
),
|
||||
custom: (),
|
||||
|
@ -184,7 +184,7 @@ expression: parse_ast
|
|||
end_location: Some(
|
||||
Location {
|
||||
row: 2,
|
||||
column: 33,
|
||||
column: 36,
|
||||
},
|
||||
),
|
||||
custom: (),
|
||||
|
@ -198,7 +198,7 @@ expression: parse_ast
|
|||
end_location: Some(
|
||||
Location {
|
||||
row: 2,
|
||||
column: 19,
|
||||
column: 22,
|
||||
},
|
||||
),
|
||||
custom: (),
|
||||
|
@ -228,7 +228,7 @@ expression: parse_ast
|
|||
end_location: Some(
|
||||
Location {
|
||||
row: 2,
|
||||
column: 18,
|
||||
column: 21,
|
||||
},
|
||||
),
|
||||
custom: (),
|
||||
|
@ -261,7 +261,7 @@ expression: parse_ast
|
|||
end_location: Some(
|
||||
Location {
|
||||
row: 2,
|
||||
column: 14,
|
||||
column: 17,
|
||||
},
|
||||
),
|
||||
custom: (),
|
||||
|
@ -274,12 +274,12 @@ expression: parse_ast
|
|||
end_location: Some(
|
||||
Location {
|
||||
row: 2,
|
||||
column: 14,
|
||||
column: 17,
|
||||
},
|
||||
),
|
||||
custom: (),
|
||||
node: Name {
|
||||
id: "idxs",
|
||||
id: "indexes",
|
||||
ctx: Load,
|
||||
},
|
||||
},
|
||||
|
@ -289,12 +289,12 @@ expression: parse_ast
|
|||
Located {
|
||||
location: Location {
|
||||
row: 2,
|
||||
column: 16,
|
||||
column: 19,
|
||||
},
|
||||
end_location: Some(
|
||||
Location {
|
||||
row: 2,
|
||||
column: 18,
|
||||
column: 21,
|
||||
},
|
||||
),
|
||||
custom: (),
|
||||
|
@ -303,12 +303,12 @@ expression: parse_ast
|
|||
operand: Located {
|
||||
location: Location {
|
||||
row: 2,
|
||||
column: 17,
|
||||
column: 20,
|
||||
},
|
||||
end_location: Some(
|
||||
Location {
|
||||
row: 2,
|
||||
column: 18,
|
||||
column: 21,
|
||||
},
|
||||
),
|
||||
custom: (),
|
||||
|
@ -332,12 +332,12 @@ expression: parse_ast
|
|||
value: Located {
|
||||
location: Location {
|
||||
row: 2,
|
||||
column: 22,
|
||||
column: 25,
|
||||
},
|
||||
end_location: Some(
|
||||
Location {
|
||||
row: 2,
|
||||
column: 33,
|
||||
column: 36,
|
||||
},
|
||||
),
|
||||
custom: (),
|
||||
|
@ -357,7 +357,7 @@ expression: parse_ast
|
|||
end_location: Some(
|
||||
Location {
|
||||
row: 3,
|
||||
column: 39,
|
||||
column: 45,
|
||||
},
|
||||
),
|
||||
custom: (),
|
||||
|
@ -370,7 +370,7 @@ expression: parse_ast
|
|||
end_location: Some(
|
||||
Location {
|
||||
row: 3,
|
||||
column: 39,
|
||||
column: 45,
|
||||
},
|
||||
),
|
||||
custom: (),
|
||||
|
@ -400,7 +400,7 @@ expression: parse_ast
|
|||
end_location: Some(
|
||||
Location {
|
||||
row: 3,
|
||||
column: 38,
|
||||
column: 44,
|
||||
},
|
||||
),
|
||||
custom: (),
|
||||
|
@ -414,7 +414,7 @@ expression: parse_ast
|
|||
end_location: Some(
|
||||
Location {
|
||||
row: 3,
|
||||
column: 21,
|
||||
column: 24,
|
||||
},
|
||||
),
|
||||
custom: (),
|
||||
|
@ -427,12 +427,12 @@ expression: parse_ast
|
|||
end_location: Some(
|
||||
Location {
|
||||
row: 3,
|
||||
column: 21,
|
||||
column: 24,
|
||||
},
|
||||
),
|
||||
custom: (),
|
||||
node: Name {
|
||||
id: "idxs_to_select",
|
||||
id: "indexes_to_select",
|
||||
ctx: Load,
|
||||
},
|
||||
},
|
||||
|
@ -442,12 +442,12 @@ expression: parse_ast
|
|||
Located {
|
||||
location: Location {
|
||||
row: 3,
|
||||
column: 23,
|
||||
column: 26,
|
||||
},
|
||||
end_location: Some(
|
||||
Location {
|
||||
row: 3,
|
||||
column: 38,
|
||||
column: 44,
|
||||
},
|
||||
),
|
||||
custom: (),
|
||||
|
@ -455,17 +455,17 @@ expression: parse_ast
|
|||
value: Located {
|
||||
location: Location {
|
||||
row: 3,
|
||||
column: 24,
|
||||
column: 27,
|
||||
},
|
||||
end_location: Some(
|
||||
Location {
|
||||
row: 3,
|
||||
column: 38,
|
||||
column: 44,
|
||||
},
|
||||
),
|
||||
custom: (),
|
||||
node: Name {
|
||||
id: "idxs_to_select",
|
||||
id: "indexes_to_select",
|
||||
ctx: Load,
|
||||
},
|
||||
},
|
||||
|
@ -489,7 +489,7 @@ expression: parse_ast
|
|||
end_location: Some(
|
||||
Location {
|
||||
row: 4,
|
||||
column: 27,
|
||||
column: 30,
|
||||
},
|
||||
),
|
||||
custom: (),
|
||||
|
@ -502,7 +502,7 @@ expression: parse_ast
|
|||
end_location: Some(
|
||||
Location {
|
||||
row: 4,
|
||||
column: 27,
|
||||
column: 30,
|
||||
},
|
||||
),
|
||||
custom: (),
|
||||
|
@ -532,7 +532,7 @@ expression: parse_ast
|
|||
end_location: Some(
|
||||
Location {
|
||||
row: 4,
|
||||
column: 26,
|
||||
column: 29,
|
||||
},
|
||||
),
|
||||
custom: (),
|
||||
|
@ -604,7 +604,7 @@ expression: parse_ast
|
|||
end_location: Some(
|
||||
Location {
|
||||
row: 4,
|
||||
column: 26,
|
||||
column: 29,
|
||||
},
|
||||
),
|
||||
custom: (),
|
||||
|
@ -617,12 +617,12 @@ expression: parse_ast
|
|||
end_location: Some(
|
||||
Location {
|
||||
row: 4,
|
||||
column: 26,
|
||||
column: 29,
|
||||
},
|
||||
),
|
||||
custom: (),
|
||||
node: Name {
|
||||
id: "idxs_to_select",
|
||||
id: "indexes_to_select",
|
||||
ctx: Load,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
---
|
||||
source: compiler/parser/src/string.rs
|
||||
assertion_line: 698
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
|
@ -1,6 +1,5 @@
|
|||
---
|
||||
source: compiler/parser/src/string.rs
|
||||
assertion_line: 706
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
|
@ -1,6 +1,5 @@
|
|||
---
|
||||
source: compiler/parser/src/string.rs
|
||||
assertion_line: 714
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
|
@ -1,6 +1,5 @@
|
|||
---
|
||||
source: compiler/parser/src/string.rs
|
||||
assertion_line: 690
|
||||
expression: "parse_fstring(\"\").unwrap()"
|
||||
---
|
||||
[]
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
---
|
||||
source: compiler/parser/src/string.rs
|
||||
assertion_line: 669
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
---
|
||||
source: compiler/parser/src/string.rs
|
||||
assertion_line: 766
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
---
|
||||
source: compiler/parser/src/string.rs
|
||||
assertion_line: 677
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
---
|
||||
source: compiler/parser/src/string.rs
|
||||
assertion_line: 759
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
---
|
||||
source: compiler/parser/src/string.rs
|
||||
assertion_line: 685
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
---
|
||||
source: compiler/parser/src/string.rs
|
||||
assertion_line: 773
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
|
@ -1,6 +1,5 @@
|
|||
---
|
||||
source: compiler/parser/src/string.rs
|
||||
assertion_line: 780
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
|
@ -1,6 +1,5 @@
|
|||
---
|
||||
source: compiler/parser/src/string.rs
|
||||
assertion_line: 787
|
||||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
|
|
|
@ -27,7 +27,7 @@ where
|
|||
{
|
||||
pub fn new(lexer: I, mode: Mode) -> Self {
|
||||
Self {
|
||||
underlying: lexer.multipeek(),
|
||||
underlying: lexer.multipeek(), // spell-checker:ignore multipeek
|
||||
start_of_line: matches!(mode, Mode::Interactive | Mode::Module),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -179,7 +179,7 @@ impl<'a> StringParser<'a> {
|
|||
|
||||
let mut expression = String::new();
|
||||
let mut spec = None;
|
||||
let mut delims = Vec::new();
|
||||
let mut delimiters = Vec::new();
|
||||
let mut conversion = ConversionFlag::None;
|
||||
let mut self_documenting = false;
|
||||
let mut trailing_seq = String::new();
|
||||
|
@ -194,7 +194,7 @@ impl<'a> StringParser<'a> {
|
|||
expression.push('=');
|
||||
self.next_char();
|
||||
}
|
||||
'!' if delims.is_empty() && self.peek() != Some(&'=') => {
|
||||
'!' if delimiters.is_empty() && self.peek() != Some(&'=') => {
|
||||
if expression.trim().is_empty() {
|
||||
return Err(FStringError::new(EmptyExpression, self.get_pos()).into());
|
||||
}
|
||||
|
@ -223,11 +223,11 @@ impl<'a> StringParser<'a> {
|
|||
|
||||
// match a python 3.8 self documenting expression
|
||||
// format '{' PYTHON_EXPRESSION '=' FORMAT_SPECIFIER? '}'
|
||||
'=' if self.peek() != Some(&'=') && delims.is_empty() => {
|
||||
'=' if self.peek() != Some(&'=') && delimiters.is_empty() => {
|
||||
self_documenting = true;
|
||||
}
|
||||
|
||||
':' if delims.is_empty() => {
|
||||
':' if delimiters.is_empty() => {
|
||||
let parsed_spec = self.parse_spec(nested)?;
|
||||
|
||||
spec = Some(Box::new(self.expr(ExprKind::JoinedStr {
|
||||
|
@ -236,10 +236,10 @@ impl<'a> StringParser<'a> {
|
|||
}
|
||||
'(' | '{' | '[' => {
|
||||
expression.push(ch);
|
||||
delims.push(ch);
|
||||
delimiters.push(ch);
|
||||
}
|
||||
')' => {
|
||||
let last_delim = delims.pop();
|
||||
let last_delim = delimiters.pop();
|
||||
match last_delim {
|
||||
Some('(') => {
|
||||
expression.push(ch);
|
||||
|
@ -257,7 +257,7 @@ impl<'a> StringParser<'a> {
|
|||
}
|
||||
}
|
||||
']' => {
|
||||
let last_delim = delims.pop();
|
||||
let last_delim = delimiters.pop();
|
||||
match last_delim {
|
||||
Some('[') => {
|
||||
expression.push(ch);
|
||||
|
@ -274,8 +274,8 @@ impl<'a> StringParser<'a> {
|
|||
}
|
||||
}
|
||||
}
|
||||
'}' if !delims.is_empty() => {
|
||||
let last_delim = delims.pop();
|
||||
'}' if !delimiters.is_empty() => {
|
||||
let last_delim = delimiters.pop();
|
||||
match last_delim {
|
||||
Some('{') => {
|
||||
expression.push(ch);
|
||||
|
@ -800,7 +800,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_fstring_parse_selfdocumenting_base() {
|
||||
fn test_fstring_parse_self_documenting_base() {
|
||||
let src = "{user=}";
|
||||
let parse_ast = parse_fstring(src).unwrap();
|
||||
|
||||
|
@ -808,7 +808,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_fstring_parse_selfdocumenting_base_more() {
|
||||
fn test_fstring_parse_self_documenting_base_more() {
|
||||
let src = "mix {user=} with text and {second=}";
|
||||
let parse_ast = parse_fstring(src).unwrap();
|
||||
|
||||
|
@ -816,7 +816,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_fstring_parse_selfdocumenting_format() {
|
||||
fn test_fstring_parse_self_documenting_format() {
|
||||
let src = "{user=:>10}";
|
||||
let parse_ast = parse_fstring(src).unwrap();
|
||||
|
||||
|
@ -877,14 +877,14 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_fstring_selfdoc_prec_space() {
|
||||
fn test_parse_fstring_self_doc_prec_space() {
|
||||
let source = "{x =}";
|
||||
let parse_ast = parse_fstring(source).unwrap();
|
||||
insta::assert_debug_snapshot!(parse_ast);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_fstring_selfdoc_trailing_space() {
|
||||
fn test_parse_fstring_self_doc_trailing_space() {
|
||||
let source = "{x= }";
|
||||
let parse_ast = parse_fstring(source).unwrap();
|
||||
insta::assert_debug_snapshot!(parse_ast);
|
||||
|
@ -979,7 +979,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_escape_char_in_byte_literal() {
|
||||
// backslash does not escape
|
||||
let source = r##"b"omkmok\Xaa""##;
|
||||
let source = r##"b"omkmok\Xaa""##; // spell-checker:ignore omkmok
|
||||
let parse_ast = parse_program(source, "<test>").unwrap();
|
||||
insta::assert_debug_snapshot!(parse_ast);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue