repo stringlengths 6 65 | file_url stringlengths 81 311 | file_path stringlengths 6 227 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:31:58 2026-01-04 20:25:31 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_estree_ast/src/typescript.rs | crates/swc_estree_ast/src/typescript.rs | use serde::{Deserialize, Serialize};
use swc_atoms::Atom;
use swc_common::ast_serde;
use crate::{
class::ClassMethodKind,
common::{Access, BaseNode, Decorator, IdOrRest, IdOrString, Identifier, Noop, Param},
expr::Expression,
lit::{BigIntLiteral, BooleanLiteral, NumericLiteral, StringLiteral},
obje... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_estree_ast/src/class.rs | crates/swc_estree_ast/src/class.rs | use serde::{ser::SerializeMap, Deserialize, Serialize};
use serde_json::Value;
use swc_common::ast_serde;
use crate::{
common::{
Access, BaseNode, Decorator, Identifier, Param, PrivateName, SuperTypeParams,
TypeAnnotOrNoop, TypeParamDeclOrNoop,
},
expr::{ClassExpression, Expression},
fl... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_estree_ast/src/lit.rs | crates/swc_estree_ast/src/lit.rs | use std::borrow::Cow;
use serde::{ser::SerializeMap, Deserialize, Serialize};
use swc_atoms::{Atom, Wtf8Atom};
use swc_common::ast_serde;
use crate::{common::BaseNode, expr::Expression, flavor::Flavor, typescript::TSType};
#[derive(Debug, Clone, PartialEq)]
pub enum Literal {
String(StringLiteral),
Numeric(N... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_estree_ast/src/flat_map_serializer.rs | crates/swc_estree_ast/src/flat_map_serializer.rs | // FlatMapSerializer implementation copied from serde 1.0.219
// This is needed because serde::__private is not available in serde 1.0.220+
use serde::ser::{self, Serialize, SerializeMap, Serializer};
/// A serializer that delegates to a `SerializeMap` for serializing struct
/// fields. This allows flattening struct ... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_estree_ast/src/common.rs | crates/swc_estree_ast/src/common.rs | use serde::{Deserialize, Serialize};
use swc_atoms::Atom;
use swc_common::ast_serde;
use crate::{
class::*, comment::Comment, decl::*, expr::*, flow::*, jsx::*, lit::*, module::*, object::*,
pat::*, stmt::*, typescript::*,
};
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_estree_ast/src/jsx.rs | crates/swc_estree_ast/src/jsx.rs | use swc_atoms::Atom;
use swc_common::ast_serde;
use crate::{
common::{BaseNode, Identifier, SuperTypeParams},
expr::Expression,
lit::StringLiteral,
};
#[derive(Debug, Clone, PartialEq)]
#[ast_serde]
pub enum JSX {
#[tag("JSXAttribute")]
Attr(JSXAttribute),
#[tag("JSXClosingElement")]
Closi... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_estree_ast/src/comment.rs | crates/swc_estree_ast/src/comment.rs | use serde::{Deserialize, Serialize};
use swc_atoms::Atom;
use swc_common::ast_serde;
use crate::common::Loc;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum CommentType {
#[serde(rename = "CommentLine")]
Line,
#[serde(rename = "CommentBlock")]
Block,
}
#[derive(Debug, Clo... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_estree_ast/src/stmt.rs | crates/swc_estree_ast/src/stmt.rs | use serde::{Deserialize, Serialize};
use swc_common::ast_serde;
use crate::{
class::ClassDeclaration,
common::{BaseNode, Directive, Identifier, LVal},
decl::{EnumDeclaration, FunctionDeclaration, VariableDeclaration},
expr::Expression,
flow::{
DeclareClass, DeclareExportAllDeclaration, Decl... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/src/lib.rs | crates/swc_ecma_parser/src/lib.rs | //! EcmaScript/TypeScript parser for the rust programming language.
//!
//! # Features
//!
//! ## Heavily tested
//!
//! Passes almost all tests from [tc39/test262][].
//!
//! ## Error reporting
//!
//! ```sh
//! error: 'implements', 'interface', 'let', 'package', 'private', 'protected', 'public', 'static', or 'yield'... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/src/syntax.rs | crates/swc_ecma_parser/src/syntax.rs | use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize)]
#[serde(deny_unknown_fields, tag = "syntax")]
pub enum Syntax {
/// Standard
#[serde(rename = "ecmascript")]
Es(EsSyntax),
/// This variant requires the cargo feature `typescript` to be enabled.
... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/src/error.rs | crates/swc_ecma_parser/src/error.rs | #![allow(dead_code)]
use std::{borrow::Cow, fmt::Debug};
use swc_atoms::Atom;
use swc_common::{
errors::{DiagnosticBuilder, Handler},
Span, Spanned,
};
/// Note: this struct is 8 bytes.
#[derive(Debug, Clone, PartialEq)]
pub struct Error {
error: Box<(Span, SyntaxError)>,
}
impl Spanned for Error {
... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/src/legacy.rs | crates/swc_ecma_parser/src/legacy.rs | /// This module should only be used by [swc_ecma_lexer] for compatibility.
pub mod token {
use std::{
borrow::Cow,
fmt::{self, Debug, Display, Formatter},
};
use swc_atoms::{atom, Atom, AtomStore, Wtf8Atom};
use swc_common::{Span, Spanned};
use swc_ecma_ast::{AssignOp, BigIntValue, ... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/src/context.rs | crates/swc_ecma_parser/src/context.rs | use swc_atoms::Atom;
bitflags::bitflags! {
#[derive(Debug, Clone, Copy, Default)]
pub struct Context: u32 {
/// `true` while backtracking
const IgnoreError = 1 << 0;
/// Is in module code?
const Module = 1 << 1;
const CanBeModule = 1 << 2;
const Strict = 1 << 3;
const F... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/src/parser/object.rs | crates/swc_ecma_parser/src/parser/object.rs | use swc_common::{Span, Spanned, DUMMY_SP};
use swc_ecma_ast::*;
use crate::{
error::SyntaxError, input::Tokens, lexer::Token, parser::class_and_fn::is_not_this, Context,
PResult, Parser,
};
impl<I: Tokens> Parser<I> {
pub(crate) fn parse_object<Object, ObjectProp>(
&mut self,
parse_prop: i... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/src/parser/expr.rs | crates/swc_ecma_parser/src/parser/expr.rs | use either::Either;
use swc_atoms::atom;
use swc_common::{ast_node, util::take::Take, BytePos, Span, Spanned};
use super::*;
use crate::{
error::SyntaxError,
parser::{pat::PatType, util::IsSimpleParameterList, Parser},
};
#[ast_node]
pub(crate) enum AssignTargetOrSpread {
#[tag("ExprOrSpread")]
ExprOr... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | true |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/src/parser/class_and_fn.rs | crates/swc_ecma_parser/src/parser/class_and_fn.rs | use swc_atoms::atom;
use swc_common::{BytePos, Span, Spanned};
use swc_ecma_ast::*;
use crate::{
error::SyntaxError,
input::Tokens,
lexer::Token,
parser::{
state::State,
util::{IsInvalidClassName, IsSimpleParameterList},
},
Context, PResult, Parser,
};
struct MakeMethodArgs {
... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | true |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/src/parser/pat.rs | crates/swc_ecma_parser/src/parser/pat.rs | //! 13.3.3 Destructuring Binding Patterns
use swc_common::Spanned;
use super::*;
use crate::parser::{expr::AssignTargetOrSpread, Parser};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum PatType {
BindingPat,
BindingElement,
/// AssignmentPattern
AssignPat,
AssignElement,
}
impl PatT... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | true |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/src/parser/tests.rs | crates/swc_ecma_parser/src/parser/tests.rs | use std::hint::black_box;
use swc_atoms::atom;
use swc_common::{comments::SingleThreadedComments, BytePos, FileName, SourceMap, DUMMY_SP};
use swc_ecma_visit::assert_eq_ignore_span;
use super::*;
use crate::{parse_file_as_expr, EsSyntax, TsSyntax};
fn program(src: &'static str) -> Program {
test_parser(src, Defa... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/src/parser/typescript.rs | crates/swc_ecma_parser/src/parser/typescript.rs | use std::{fmt::Write, mem};
use either::Either;
use swc_atoms::{atom, Atom, Wtf8Atom};
use swc_common::{BytePos, Span, Spanned};
use swc_ecma_ast::*;
use crate::{
error::SyntaxError, input::Tokens, lexer::Token, parser::util::IsSimpleParameterList, Context,
PResult, Parser,
};
#[derive(Debug, Clone, Copy, Pa... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | true |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/src/parser/state.rs | crates/swc_ecma_parser/src/parser/state.rs | use std::ops::{Deref, DerefMut};
use rustc_hash::FxHashMap;
use swc_atoms::Atom;
use swc_common::{BytePos, Span};
use crate::{input::Tokens, Parser};
#[derive(Clone, Default)]
pub struct State {
pub labels: Vec<Atom>,
/// Start position of an assignment expression.
pub potential_arrow_start: Option<ByteP... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/src/parser/util.rs | crates/swc_ecma_parser/src/parser/util.rs | use swc_common::Span;
use swc_ecma_ast::*;
pub trait IsSimpleParameterList {
fn is_simple_parameter_list(&self) -> bool;
}
impl IsSimpleParameterList for Vec<Param> {
fn is_simple_parameter_list(&self) -> bool {
self.iter().all(|param| matches!(param.pat, Pat::Ident(_)))
}
}
impl IsSimpleParamete... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/src/parser/ident.rs | crates/swc_ecma_parser/src/parser/ident.rs | use either::Either;
use swc_atoms::atom;
use swc_common::BytePos;
use swc_ecma_ast::*;
use crate::{error::SyntaxError, input::Tokens, lexer::Token, Context, PResult, Parser};
impl<I: Tokens> Parser<I> {
// https://tc39.es/ecma262/#prod-ModuleExportName
pub(crate) fn parse_module_export_name(&mut self) -> PRes... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/src/parser/module_item.rs | crates/swc_ecma_parser/src/parser/module_item.rs | use swc_atoms::atom;
use swc_common::Span;
use swc_ecma_ast::*;
use crate::{error::SyntaxError, input::Tokens, lexer::Token, Context, PResult, Parser};
impl<I: Tokens> Parser<I> {
pub fn parse_module_item(&mut self) -> PResult<ModuleItem> {
self.do_inside_of_context(Context::TopLevel, |p| {
p.... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | true |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/src/parser/macros.rs | crates/swc_ecma_parser/src/parser/macros.rs | macro_rules! trace_cur {
($p:expr, $name:ident) => {{
if cfg!(feature = "debug") {
tracing::debug!("{}: {:?}", stringify!($name), $p.input.cur());
}
}};
}
macro_rules! syntax_error {
($p:expr, $err:expr) => {
syntax_error!($p, $p.input().cur_span(), $err)
};
($p:... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/src/parser/mod.rs | crates/swc_ecma_parser/src/parser/mod.rs | #![allow(clippy::let_unit_value)]
#![deny(non_snake_case)]
use swc_atoms::Atom;
use swc_common::{comments::Comments, input::StringInput, BytePos, Span, Spanned};
use swc_ecma_ast::*;
use crate::{
error::SyntaxError,
input::Buffer,
lexer::{Token, TokenAndSpan},
parser::{
input::Tokens,
... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/src/parser/jsx.rs | crates/swc_ecma_parser/src/parser/jsx.rs | use swc_atoms::Atom;
use swc_common::{BytePos, Span, Spanned};
use swc_ecma_ast::*;
use super::{input::Tokens, Parser};
use crate::{
error::SyntaxError,
lexer::{Token, TokenFlags},
Context, PResult,
};
impl<I: Tokens> Parser<I> {
/// Parses JSX expression enclosed into curly brackets.
fn parse_jsx... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/src/parser/verifier.rs | crates/swc_ecma_parser/src/parser/verifier.rs | use swc_common::{Span, Spanned};
use swc_ecma_ast::{AssignProp, Expr};
use swc_ecma_visit::{noop_visit_type, Visit, VisitWith};
use crate::error::SyntaxError;
pub struct Verifier {
pub errors: Vec<(Span, SyntaxError)>,
}
impl Visit for Verifier {
noop_visit_type!();
fn visit_assign_prop(&mut self, p: &A... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/src/parser/stmt.rs | crates/swc_ecma_parser/src/parser/stmt.rs | use swc_common::Spanned;
use super::*;
use crate::parser::{pat::PatType, Parser};
#[allow(clippy::enum_variant_names)]
enum TempForHead {
For {
init: Option<VarDeclOrExpr>,
test: Option<Box<Expr>>,
update: Option<Box<Expr>>,
},
ForIn {
left: ForHead,
right: Box<Expr... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | true |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/src/parser/input.rs | crates/swc_ecma_parser/src/parser/input.rs | use swc_atoms::{Atom, Wtf8Atom};
use swc_common::{BytePos, Span};
use swc_ecma_ast::EsVersion;
use crate::{
error::Error,
lexer::{LexResult, NextTokenAndSpan, Token, TokenAndSpan, TokenFlags, TokenValue},
syntax::SyntaxFlags,
Context,
};
/// Clone should be cheap if you are parsing typescript because ... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/src/lexer/number.rs | crates/swc_ecma_parser/src/lexer/number.rs | use swc_common::BytePos;
pub struct LazyInteger {
pub(super) start: BytePos,
pub(super) end: BytePos,
/// `true` if there was `8` or `9``
pub(super) not_octal: bool,
pub(super) has_underscore: bool,
}
const MAX_SAFE_INT: u64 = 9007199254740991;
pub(super) fn parse_integer<const RADIX: u8>(s: &str... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/src/lexer/char_ext.rs | crates/swc_ecma_parser/src/lexer/char_ext.rs | /// Implemented for `u8` and `char` - operates on bytes for performance.
pub trait CharExt: Copy {
fn to_char(self) -> Option<char>;
/// Test whether a given byte/character starts an identifier.
///
/// https://tc39.github.io/ecma262/#prod-IdentifierStart
#[inline]
fn is_ident_start(self) -> bo... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/src/lexer/table.rs | crates/swc_ecma_parser/src/lexer/table.rs | //! Lookup table for byte handlers.
//!
//! Idea is taken from ratel.
//!
//! https://github.com/ratel-rust/ratel-core/blob/e55a1310ba69a3f5ce2a9a6eef643feced02ac08/ratel/src/lexer/mod.rs#L665
use either::Either;
use swc_common::input::Input;
use super::{pos_span, LexResult, Lexer};
use crate::{
error::SyntaxErro... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/src/lexer/state.rs | crates/swc_ecma_parser/src/lexer/state.rs | use std::mem::take;
use swc_atoms::{wtf8::CodePoint, Atom};
use swc_common::{BytePos, Span};
use swc_ecma_ast::EsVersion;
use super::{Context, Input, Lexer};
use crate::{
byte_search,
error::{Error, SyntaxError},
input::Tokens,
lexer::{
char_ext::CharExt,
comments_buffer::{BufferedComm... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/src/lexer/search.rs | crates/swc_ecma_parser/src/lexer/search.rs | //! Utilities inspired by OXC lexer for fast byte-wise searching over source
//! text.
/// How many bytes we process per batch when scanning.
pub const SEARCH_BATCH_SIZE: usize = 32;
/// Compile-time lookup table guaranteeing UTF-8 boundary safety.
#[repr(C, align(64))]
pub struct SafeByteMatchTable([bool; 256]);
im... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/src/lexer/whitespace.rs | crates/swc_ecma_parser/src/lexer/whitespace.rs | use swc_common::input::Input;
use crate::{byte_search, lexer::search::SafeByteMatchTable, safe_byte_match_table, Lexer};
/// U+000B VERTICAL TAB, abbreviated `<VT>`.
const B_VT: u8 = 0x0b;
/// U+000C FORM FEED, abbreviated `<FF>`.
const B_FF: u8 = 0x0c;
// https://github.com/oxc-project/oxc/blob/ec6721c458d64c5b27b... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/src/lexer/mod.rs | crates/swc_ecma_parser/src/lexer/mod.rs | //! ECMAScript lexer.
use std::{borrow::Cow, char, rc::Rc};
use either::Either::{self, Left, Right};
use rustc_hash::FxHashMap;
use smartstring::{LazyCompact, SmartString};
use swc_atoms::{
wtf8::{CodePoint, Wtf8, Wtf8Buf},
Atom, AtomStoreCell,
};
use swc_common::{
comments::{Comment, CommentKind, Comment... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | true |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/src/lexer/capturing.rs | crates/swc_ecma_parser/src/lexer/capturing.rs | use std::mem;
use swc_common::Span;
use crate::{
error::Error,
input::Tokens,
lexer::{token::TokenAndSpan, Token, TokenFlags},
syntax::SyntaxFlags,
Context,
};
#[derive(Debug)]
pub struct Capturing<I> {
inner: I,
captured: Vec<TokenAndSpan>,
}
pub struct CapturingCheckpoint<I: Tokens> {
... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/src/lexer/comments_buffer.rs | crates/swc_ecma_parser/src/lexer/comments_buffer.rs | use swc_common::{comments::Comment, BytePos};
#[derive(Debug, Clone)]
pub struct BufferedComment {
pub kind: BufferedCommentKind,
pub pos: BytePos,
pub comment: Comment,
}
#[derive(Debug, Clone, Copy)]
pub enum BufferedCommentKind {
Leading,
Trailing,
}
#[derive(Default, Clone)]
pub struct Commen... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/src/lexer/jsx.rs | crates/swc_ecma_parser/src/lexer/jsx.rs | macro_rules! xhtml {
(
$(
$i:ident : $s:expr,
)*
) => {
pub(super) fn xhtml(s: &str) -> Option<char> {
match s{
$(stringify!($i) => Some($s),)*
_ => None,
}
}
};
}
xhtml!(
quot: '\u{0022}',
amp: '&',
apos: '\u{0027}',
lt: '... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/src/lexer/token.rs | crates/swc_ecma_parser/src/lexer/token.rs | use std::fmt::Display;
use swc_atoms::{Atom, Wtf8Atom};
use swc_common::{BytePos, Span};
use swc_ecma_ast::AssignOp;
use super::LexResult;
use crate::{
error::Error,
input::{Buffer, Tokens},
Context, Lexer,
};
#[derive(Debug, Clone)]
pub enum TokenValue {
/// unknown ident, jsx name and shebang
W... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/tests/errors.rs | crates/swc_ecma_parser/tests/errors.rs | #![allow(unused)]
use std::{
fs::read_to_string,
path::{Path, PathBuf},
};
use pretty_assertions::assert_eq;
use swc_common::{errors::Handler, sync::Lrc, SourceMap};
use swc_ecma_ast::*;
use swc_ecma_parser::{lexer::Lexer, PResult, Parser, StringInput};
use swc_ecma_visit::{Fold, FoldWith};
use testing::{run_... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/tests/comments.rs | crates/swc_ecma_parser/tests/comments.rs | use std::path::PathBuf;
use swc_common::{
comments::SingleThreadedComments,
errors::{DiagnosticBuilder, Handler},
input::SourceFileInput,
BytePos, Span,
};
use swc_ecma_ast::*;
use swc_ecma_parser::{lexer::Lexer, EsSyntax, Parser, Syntax, TsSyntax};
use swc_ecma_visit::{Visit, VisitWith};
use testing::... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/tests/typescript.rs | crates/swc_ecma_parser/tests/typescript.rs | #![allow(clippy::needless_update)]
use std::{
fs::File,
io::Read,
path::{Path, PathBuf},
};
use pretty_assertions::assert_eq;
use swc_common::{comments::SingleThreadedComments, FileName};
use swc_ecma_ast::*;
use swc_ecma_parser::{lexer::Lexer, PResult, Parser, Syntax, TsSyntax};
use swc_ecma_visit::FoldW... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/tests/span.rs | crates/swc_ecma_parser/tests/span.rs | use std::path::PathBuf;
use swc_common::{comments::SingleThreadedComments, errors::Handler, Spanned};
use swc_ecma_ast::*;
use swc_ecma_parser::{lexer::Lexer, EsSyntax, Parser, Syntax, TsSyntax};
use swc_ecma_visit::{Visit, VisitWith};
#[testing::fixture("tests/span/**/*.js")]
#[testing::fixture("tests/span/**/*.ts")... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/tests/js.rs | crates/swc_ecma_parser/tests/js.rs | #![allow(clippy::needless_update)]
use std::{
fs::File,
io::Read,
path::{Path, PathBuf},
};
use swc_common::{comments::SingleThreadedComments, FileName};
use swc_ecma_ast::*;
use swc_ecma_parser::{lexer::Lexer, EsSyntax, PResult, Parser, Syntax};
use swc_ecma_visit::FoldWith;
use testing::StdErr;
use cra... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/tests/test262.rs | crates/swc_ecma_parser/tests/test262.rs | #![feature(test)]
extern crate test;
use std::{
env,
fs::{read_dir, File},
io::{self, Read},
path::Path,
};
use common::Normalizer;
use swc_ecma_ast::*;
use swc_ecma_parser::{lexer::Lexer, PResult, Parser, Syntax};
use swc_ecma_visit::FoldWith;
use test::{
test_main, DynTestFn, Options, ShouldPan... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/tests/jsx.rs | crates/swc_ecma_parser/tests/jsx.rs | use std::{
fs::read_to_string,
path::{Path, PathBuf},
};
use pretty_assertions::assert_eq;
use swc_common::{errors::Handler, sync::Lrc, SourceMap};
use swc_ecma_ast::*;
use swc_ecma_parser::{lexer::Lexer, PResult, Parser};
use swc_ecma_visit::{Fold, FoldWith};
use testing::{run_test, StdErr};
fn parse_module(... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/tests/common/mod.rs | crates/swc_ecma_parser/tests/common/mod.rs | use swc_common::Span;
use swc_ecma_ast::*;
use swc_ecma_visit::{Fold, FoldWith};
pub struct Normalizer {
pub drop_span: bool,
pub is_test262: bool,
}
impl Fold for Normalizer {
fn fold_class_members(&mut self, mut node: Vec<ClassMember>) -> Vec<ClassMember> {
node = node.fold_children_with(self);
... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/benches/lexer.rs | crates/swc_ecma_parser/benches/lexer.rs | extern crate swc_malloc;
use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Bencher, Criterion};
use swc_common::{input::StringInput, FileName};
use swc_ecma_parser::{lexer::Lexer, Syntax, TsSyntax};
fn bench_module(b: &mut Bencher, syntax: Syntax, src: &'static str) {
let _ = ::testing::... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/benches/parser.rs | crates/swc_ecma_parser/benches/parser.rs | extern crate swc_malloc;
use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Bencher, Criterion};
use swc_common::{comments::SingleThreadedComments, FileName};
use swc_ecma_parser::{lexer::Lexer, Parser, StringInput, Syntax, TsSyntax};
fn bench_module(b: &mut Bencher, syntax: Syntax, src: &'st... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/benches/compare.rs | crates/swc_ecma_parser/benches/compare.rs | extern crate swc_malloc;
use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Bencher, Criterion};
use swc_common::{FileName, Span, DUMMY_SP};
use swc_ecma_ast::Module;
use swc_ecma_parser::{Parser, StringInput, Syntax};
use swc_ecma_visit::{Fold, FoldWith, VisitMut, VisitMutWith};
static SOURC... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/examples/parse.rs | crates/swc_ecma_parser/examples/parse.rs | use std::{ffi::OsStr, path::Path};
use swc_common::{
errors::{ColorConfig, Handler},
sync::Lrc,
SourceMap,
};
use swc_ecma_ast::Program;
use swc_ecma_parser::{lexer::Lexer, EsSyntax, Parser, StringInput, Syntax, TsSyntax};
fn main() {
let cm: Lrc<SourceMap> = Default::default();
let handler = Hand... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/examples/typescript.rs | crates/swc_ecma_parser/examples/typescript.rs | use swc_common::{
errors::{ColorConfig, Handler},
sync::Lrc,
FileName, SourceMap,
};
use swc_ecma_parser::{lexer::Lexer, Parser, StringInput, Syntax};
fn main() {
let cm: Lrc<SourceMap> = Default::default();
let handler = Handler::with_tty_emitter(ColorConfig::Auto, true, false, Some(cm.clone()));
... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/examples/perf.rs | crates/swc_ecma_parser/examples/perf.rs | extern crate swc_malloc;
use std::{collections::hash_map::DefaultHasher, hash::Hash};
use codspeed_criterion_compat::black_box;
use swc_common::{sync::Lrc, SourceMap};
use swc_ecma_parser::{lexer::Lexer, Parser, StringInput, Syntax, TsSyntax};
fn main() {
let mut cnt = 0;
let mut hasher = DefaultHasher::new(... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_parser/examples/parse-all.rs | crates/swc_ecma_parser/examples/parse-all.rs | #![deny(warnings)]
extern crate swc_malloc;
use std::{env, path::PathBuf, time::Instant};
use codspeed_criterion_compat::black_box;
use swc_common::{errors::HANDLER, GLOBALS};
use swc_ecma_parser::parse_file_as_module;
use walkdir::WalkDir;
fn main() {
let dirs = env::args().skip(1).collect::<Vec<_>>();
let... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_graph_analyzer/src/lib.rs | crates/swc_graph_analyzer/src/lib.rs | use std::{fmt::Debug, hash::Hash, marker::PhantomData};
use auto_impl::auto_impl;
use petgraph::{prelude::GraphMap, Directed};
use rustc_hash::{FxBuildHasher, FxHashSet};
#[auto_impl(&, Box, Rc, Arc)]
pub trait DepGraph {
type ModuleId: Debug + Copy + Eq + Hash + Ord;
fn deps_of(&self, module_id: Self::Modul... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_graph_analyzer/tests/cycle.rs | crates/swc_graph_analyzer/tests/cycle.rs | use swc_graph_analyzer::{DepGraph, GraphAnalyzer};
struct Deps<'a> {
deps: &'a [(usize, Vec<usize>)],
}
impl DepGraph for Deps<'_> {
type ModuleId = usize;
fn deps_of(&self, module_id: Self::ModuleId) -> Vec<Self::ModuleId> {
self.deps
.iter()
.find_map(|(id, deps)| {
... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/lib.rs | crates/swc_ecma_lexer/src/lib.rs | //! # swc_ecma_lexer
//!
//! This crate provides a lexer for ECMAScript and TypeScript. It can ensure
//! these tokens are correctly parsed.
#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(test, feature(test))]
#![deny(clippy::all)]
#![deny(unused)]
#![allow(clippy::nonminimal_bool)]
#![allow(clippy::too_many_argum... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/error.rs | crates/swc_ecma_lexer/src/error.rs | pub use swc_ecma_parser::error::{Error, SyntaxError};
| rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/utils.rs | crates/swc_ecma_lexer/src/utils.rs | use swc_atoms::Atom;
use super::Context;
use crate::token::*;
impl Context {
pub fn is_reserved(self, word: &Word) -> bool {
match *word {
Word::Keyword(Keyword::Let) | Word::Ident(IdentLike::Known(known_ident!("static"))) => {
self.contains(Context::Strict)
}
... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/input.rs | crates/swc_ecma_lexer/src/input.rs | use std::{cell::RefCell, mem, mem::take, rc::Rc};
use lexer::TokenContexts;
use swc_common::{BytePos, Span};
use swc_ecma_ast::EsVersion;
use crate::{
common::{
input::Tokens,
lexer::token::TokenFactory,
parser::token_and_span::TokenAndSpan as TokenAndSpanTrait,
syntax::{Syntax, Sy... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/token.rs | crates/swc_ecma_lexer/src/token.rs | //! Ported from [babel/babylon][]
//!
//! [babel/babylon]:https://github.com/babel/babel/blob/2d378d076eb0c5fe63234a8b509886005c01d7ee/packages/babylon/src/tokenizer/types.js
use num_bigint::BigInt as BigIntValue;
use swc_atoms::{Atom, Wtf8Atom};
use swc_common::Span;
pub(crate) use swc_ecma_ast::{AssignOp, BinaryOp};
... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/syntax.rs | crates/swc_ecma_lexer/src/common/syntax.rs | pub use swc_ecma_parser::{EsSyntax, Syntax, SyntaxFlags, TsSyntax};
| rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/mod.rs | crates/swc_ecma_lexer/src/common/mod.rs | pub mod context;
pub mod input;
pub mod lexer;
pub mod parser;
pub mod syntax;
| rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/context.rs | crates/swc_ecma_lexer/src/common/context.rs | bitflags::bitflags! {
#[derive(Debug, Clone, Copy, Default)]
pub struct Context: u32 {
/// `true` while backtracking
const IgnoreError = 1 << 0;
/// Is in module code?
const Module = 1 << 1;
const CanBeModule = 1 << 2;
const Strict = 1 << 3;
const ForLoopInit = 1 << 4;
... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/input.rs | crates/swc_ecma_lexer/src/common/input.rs | use swc_common::BytePos;
use swc_ecma_ast::EsVersion;
use super::context::Context;
use crate::{common::syntax::SyntaxFlags, error::Error, lexer};
/// Clone should be cheap if you are parsing typescript because typescript
/// syntax requires backtracking.
pub trait Tokens<TokenAndSpan>: Clone + Iterator<Item = TokenAn... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/parser/is_simple_param_list.rs | crates/swc_ecma_lexer/src/common/parser/is_simple_param_list.rs | use swc_ecma_ast::{Param, ParamOrTsParamProp, Pat};
pub trait IsSimpleParameterList {
fn is_simple_parameter_list(&self) -> bool;
}
impl IsSimpleParameterList for Vec<Param> {
fn is_simple_parameter_list(&self) -> bool {
self.iter().all(|param| matches!(param.pat, Pat::Ident(_)))
}
}
impl IsSimpl... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/parser/object.rs | crates/swc_ecma_lexer/src/common/parser/object.rs | use swc_common::{Span, Spanned, DUMMY_SP};
use swc_ecma_ast::*;
use super::{
expr::parse_assignment_expr,
pat::{parse_binding_element, parse_binding_pat_or_ident},
PResult, Parser,
};
use crate::{
common::{
context::Context,
lexer::token::TokenFactory,
parser::{
buff... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/parser/expr.rs | crates/swc_ecma_lexer/src/common/parser/expr.rs | use either::Either;
use rustc_hash::FxHashMap;
use swc_atoms::atom;
use swc_common::{util::take::Take, BytePos, Span, Spanned};
use swc_ecma_ast::*;
use super::{
assign_target_or_spread::AssignTargetOrSpread, buffer::Buffer, ident::parse_ident_name,
PResult, Parser,
};
use crate::{
common::{
contex... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | true |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/parser/class_and_fn.rs | crates/swc_ecma_lexer/src/common/parser/class_and_fn.rs | use swc_atoms::atom;
use swc_common::{BytePos, Span, Spanned};
use swc_ecma_ast::*;
use super::{
buffer::Buffer,
expr::{parse_args, parse_assignment_expr},
has_use_strict,
ident::{parse_binding_ident, parse_opt_binding_ident, parse_private_name},
is_constructor,
output_type::OutputType,
pat... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | true |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/parser/pat.rs | crates/swc_ecma_lexer/src/common/parser/pat.rs | use swc_common::{BytePos, Span, Spanned};
use swc_ecma_ast::*;
use super::{
assign_target_or_spread::AssignTargetOrSpread,
class_and_fn::{parse_access_modifier, parse_decorators},
pat_type::PatType,
typescript::{
eat_any_ts_modifier, parse_ts_modifier, parse_ts_type_ann, try_parse_ts_type_ann,
... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/parser/pat_type.rs | crates/swc_ecma_lexer/src/common/parser/pat_type.rs | #[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(super) enum PatType {
BindingPat,
BindingElement,
/// AssignmentPattern
AssignPat,
AssignElement,
}
impl PatType {
pub fn element(self) -> Self {
match self {
PatType::BindingPat | PatType::BindingElement => PatType::BindingEl... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/parser/assign_target_or_spread.rs | crates/swc_ecma_lexer/src/common/parser/assign_target_or_spread.rs | use swc_common::ast_node;
use swc_ecma_ast::{ExprOrSpread, Pat};
#[ast_node]
pub enum AssignTargetOrSpread {
#[tag("ExprOrSpread")]
ExprOrSpread(ExprOrSpread),
#[tag("*")]
Pat(Pat),
}
| rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/parser/typescript.rs | crates/swc_ecma_lexer/src/common/parser/typescript.rs | use std::{fmt::Write, mem};
use either::Either;
use swc_atoms::{atom, Atom, Wtf8Atom};
use swc_common::{BytePos, Span, Spanned};
use swc_ecma_ast::*;
use super::{
class_and_fn::{parse_class_decl, parse_fn_block_or_expr_body, parse_fn_decl},
eof_error,
expr::{is_start_of_left_hand_side_expr, parse_new_expr... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | true |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/parser/output_type.rs | crates/swc_ecma_lexer/src/common/parser/output_type.rs | use swc_common::Span;
use swc_ecma_ast::{
Class, ClassDecl, ClassExpr, Decl, DefaultDecl, ExportDefaultDecl, Expr, FnDecl, FnExpr,
Function, Ident,
};
use crate::error::SyntaxError;
pub trait OutputType: Sized {
const IS_IDENT_REQUIRED: bool;
/// From babel..
///
/// When parsing function exp... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/parser/state.rs | crates/swc_ecma_lexer/src/common/parser/state.rs | use std::ops::{Deref, DerefMut};
use rustc_hash::FxHashMap;
use swc_atoms::Atom;
use swc_common::{BytePos, Span};
#[derive(Clone, Default)]
pub struct State {
pub labels: Vec<Atom>,
/// Start position of an assignment expression.
pub potential_arrow_start: Option<BytePos>,
/// Start position of an AST... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/parser/util.rs | crates/swc_ecma_lexer/src/common/parser/util.rs | use swc_atoms::{atom, Atom};
use swc_common::{Span, Spanned};
use swc_ecma_ast::{
BindingIdent, BlockStmt, Decl, Expr, Ident, IdentName, JSXElementName, JSXMemberExpr,
JSXNamespacedName, JSXObject, Key, Param, Pat, PropName, Str,
};
pub fn unwrap_ts_non_null(mut expr: &Expr) -> &Expr {
while let Expr::TsNo... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/parser/ident.rs | crates/swc_ecma_lexer/src/common/parser/ident.rs | use either::Either;
use swc_atoms::atom;
use swc_common::BytePos;
use swc_ecma_ast::*;
use super::{buffer::Buffer, expr::parse_str_lit, PResult, Parser};
use crate::{
common::{context::Context, lexer::token::TokenFactory, parser::token_and_span::TokenAndSpan},
error::SyntaxError,
};
// https://tc39.es/ecma262... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/parser/module_item.rs | crates/swc_ecma_lexer/src/common/parser/module_item.rs | use swc_atoms::atom;
use swc_common::Span;
use swc_ecma_ast::*;
use super::{
buffer::Buffer,
class_and_fn::{parse_default_async_fn, parse_default_fn, parse_fn_decl},
expr::parse_assignment_expr,
ident::{parse_ident, parse_ident_name, parse_module_export_name},
stmt::{parse_block_body, parse_stmt_li... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/parser/macros.rs | crates/swc_ecma_lexer/src/common/parser/macros.rs | macro_rules! unexpected {
($p:expr, $expected:literal) => {{
let got = $p.input_mut().dump_cur();
syntax_error!(
$p,
$p.input().cur_span(),
SyntaxError::Unexpected {
got,
expected: $expected
}
)
}};
}
macro_... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/parser/mod.rs | crates/swc_ecma_lexer/src/common/parser/mod.rs | use either::Either;
use expr::{parse_assignment_expr, parse_str_lit};
use expr_ext::ExprExt;
use swc_atoms::Atom;
use swc_common::{BytePos, Span, Spanned};
use swc_ecma_ast::*;
use self::{
buffer::{Buffer, NextTokenAndSpan},
state::{State, WithState},
token_and_span::TokenAndSpan,
};
use super::{context::C... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/parser/is_directive.rs | crates/swc_ecma_lexer/src/common/parser/is_directive.rs | use swc_ecma_ast::{ModuleItem, Stmt};
pub trait IsDirective {
fn as_ref(&self) -> Option<&Stmt>;
fn is_use_strict(&self) -> bool {
self.as_ref().is_some_and(Stmt::is_use_strict)
}
}
impl<T> IsDirective for Box<T>
where
T: IsDirective,
{
fn as_ref(&self) -> Option<&Stmt> {
T::as_ref... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/parser/buffer.rs | crates/swc_ecma_lexer/src/common/parser/buffer.rs | use swc_atoms::{Atom, Wtf8Atom};
use swc_common::{BytePos, Span};
use swc_ecma_ast::EsVersion;
use super::token_and_span::TokenAndSpan as TokenAndSpanTrait;
use crate::common::{
context::Context,
input::Tokens,
lexer::{token::TokenFactory, LexResult},
syntax::SyntaxFlags,
};
pub trait NextTokenAndSpan... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/parser/jsx.rs | crates/swc_ecma_lexer/src/common/parser/jsx.rs | use either::Either;
use swc_common::{BytePos, Span, Spanned};
use swc_ecma_ast::*;
use super::{PResult, Parser};
use crate::{
common::{
context::Context,
lexer::token::TokenFactory,
parser::{
buffer::Buffer,
eof_error,
expr::{parse_assignment_expr, parse_... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/parser/is_invalid_class_name.rs | crates/swc_ecma_lexer/src/common/parser/is_invalid_class_name.rs | use swc_common::Span;
use swc_ecma_ast::Ident;
pub trait IsInvalidClassName {
fn invalid_class_name(&self) -> Option<Span>;
}
impl IsInvalidClassName for Ident {
fn invalid_class_name(&self) -> Option<Span> {
match &*self.sym {
"string" | "null" | "number" | "object" | "any" | "unknown" | ... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/parser/token_and_span.rs | crates/swc_ecma_lexer/src/common/parser/token_and_span.rs | use swc_common::Span;
pub trait TokenAndSpan {
type Token;
fn new(token: Self::Token, span: Span, had_line_break: bool) -> Self;
fn token(&self) -> &Self::Token;
fn take_token(self) -> Self::Token;
fn span(&self) -> Span;
fn had_line_break(&self) -> bool;
}
| rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/parser/expr_ext.rs | crates/swc_ecma_lexer/src/common/parser/expr_ext.rs | use swc_ecma_ast::{
EsReserved, Expr, MemberExpr, ParenExpr, TsAsExpr, TsInstantiation, TsNonNullExpr,
TsSatisfiesExpr, TsTypeAssertion,
};
pub trait ExprExt {
fn as_expr(&self) -> &Expr;
/// "IsValidSimpleAssignmentTarget" from spec.
fn is_valid_simple_assignment_target(&self, strict: bool) -> bo... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/parser/verifier.rs | crates/swc_ecma_lexer/src/common/parser/verifier.rs | use swc_common::{Span, Spanned};
use swc_ecma_ast::{AssignProp, Expr};
use swc_ecma_visit::{noop_visit_type, Visit, VisitWith};
use crate::error::SyntaxError;
pub struct Verifier {
pub errors: Vec<(Span, SyntaxError)>,
}
impl Visit for Verifier {
noop_visit_type!();
fn visit_assign_prop(&mut self, p: &A... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/parser/stmt.rs | crates/swc_ecma_lexer/src/common/parser/stmt.rs | use swc_common::{BytePos, Span, Spanned};
use swc_ecma_ast::*;
use super::{
buffer::Buffer,
class_and_fn::parse_fn_decl,
expr::parse_assignment_expr,
is_directive::IsDirective,
pat::parse_binding_pat_or_ident,
typescript::{try_parse_ts_type_ann, ts_look_ahead},
PResult, Parser,
};
use crate... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | true |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/lexer/number.rs | crates/swc_ecma_lexer/src/common/lexer/number.rs | use swc_common::BytePos;
pub struct LazyInteger {
pub(super) start: BytePos,
pub(super) end: BytePos,
/// `true` if there was `8` or `9``
pub(super) not_octal: bool,
pub(super) has_underscore: bool,
}
const MAX_SAFE_INT: u64 = 9007199254740991;
pub(super) fn parse_integer<const RADIX: u8>(s: &str... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/lexer/char.rs | crates/swc_ecma_lexer/src/common/lexer/char.rs | /// Implemented for `u8` - operates on bytes for performance.
pub trait CharExt: Copy {
fn to_char(self) -> Option<char>;
/// Test whether a given byte/character starts an identifier.
///
/// https://tc39.github.io/ecma262/#prod-IdentifierStart
#[inline]
fn is_ident_start(self) -> bool {
... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/lexer/state.rs | crates/swc_ecma_lexer/src/common/lexer/state.rs | use swc_common::BytePos;
use crate::common::syntax::SyntaxFlags;
pub trait TokenType: TokenKind {
fn is_other_and_can_have_trailing_comment(self) -> bool;
fn is_other_and_before_expr_is_false(self) -> bool;
}
pub trait TokenKind: Copy {
fn is_dot(self) -> bool;
fn is_bin_op(self) -> bool;
fn is_s... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/lexer/search.rs | crates/swc_ecma_lexer/src/common/lexer/search.rs | //! Utilities inspired by OXC lexer for fast byte-wise searching over source
//! text.
/// How many bytes we process per batch when scanning.
pub const SEARCH_BATCH_SIZE: usize = 32;
/// Compile-time lookup table guaranteeing UTF-8 boundary safety.
#[repr(C, align(64))]
pub struct SafeByteMatchTable([bool; 256]);
im... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/lexer/whitespace.rs | crates/swc_ecma_lexer/src/common/lexer/whitespace.rs | /// Returns true if it's done
type ByteHandler = Option<for<'aa> fn(&mut SkipWhitespace<'aa>) -> u32>;
/// Lookup table for whitespace
static BYTE_HANDLERS: [ByteHandler; 256] = [
// 0 1 2 3 4 5 6 7 8 9 A B C D E F //
___, ___, ___, ___, ___, ___, ___, ___, ___,... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/lexer/mod.rs | crates/swc_ecma_lexer/src/common/lexer/mod.rs | use std::borrow::Cow;
use char::CharExt;
use either::Either::{self, Left, Right};
use num_bigint::BigInt as BigIntValue;
use smartstring::{LazyCompact, SmartString};
use state::State;
use swc_atoms::{
wtf8::{CodePoint, Wtf8, Wtf8Buf},
Atom,
};
use swc_common::{
comments::{Comment, CommentKind},
input::... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | true |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/lexer/comments_buffer.rs | crates/swc_ecma_lexer/src/common/lexer/comments_buffer.rs | use swc_common::{comments::Comment, BytePos};
#[derive(Debug, Clone)]
pub struct BufferedComment {
pub kind: BufferedCommentKind,
pub pos: BytePos,
pub comment: Comment,
}
#[derive(Debug, Clone, Copy)]
pub enum BufferedCommentKind {
Leading,
Trailing,
}
pub trait CommentsBufferTrait {
fn push... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/lexer/jsx.rs | crates/swc_ecma_lexer/src/common/lexer/jsx.rs | macro_rules! xhtml {
(
$(
$i:ident : $s:expr,
)*
) => {
pub(super) fn xhtml(s: &str) -> Option<char> {
match s{
$(stringify!($i) => Some($s),)*
_ => None,
}
}
};
}
xhtml!(
quot: '\u{0022}',
amp: '&',
apos: '\u{0027}',
lt: '... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/common/lexer/token.rs | crates/swc_ecma_lexer/src/common/lexer/token.rs | use num_bigint::BigInt;
use swc_atoms::{Atom, Wtf8Atom};
use swc_ecma_ast::{AssignOp, BinaryOp};
use super::LexResult;
use crate::common::{context::Context, input::Tokens};
pub trait TokenFactory<'a, TokenAndSpan, I: Tokens<TokenAndSpan>>: Sized + PartialEq {
type Lexer: super::Lexer<'a, TokenAndSpan>;
type B... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/parser/typescript.rs | crates/swc_ecma_lexer/src/parser/typescript.rs | #[cfg(test)]
mod tests {
use swc_ecma_ast::*;
use crate::{
common::parser::Parser as ParserTrait,
token::{BinOpToken, Token, TokenAndSpan},
Capturing, Lexer, Parser, Syntax,
};
#[test]
fn issue_726() {
crate::with_test_sess(
"type Test = (
string | n... | rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
swc-project/swc | https://github.com/swc-project/swc/blob/1faa4a57454ef3932c75a1aca7dd36e37bb215d3/crates/swc_ecma_lexer/src/parser/macros.rs | crates/swc_ecma_lexer/src/parser/macros.rs | macro_rules! trace_cur {
($p:expr, $name:ident) => {{
if cfg!(feature = "debug") {
tracing::debug!("{}: {:?}", stringify!($name), $p.input.cur());
}
}};
}
| rust | Apache-2.0 | 1faa4a57454ef3932c75a1aca7dd36e37bb215d3 | 2026-01-04T15:32:21.773776Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.