Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QQmlJS::Lexer Class Reference

#include <qqmljslexer_p.h>

+ Inheritance diagram for QQmlJS::Lexer:
+ Collaboration diagram for QQmlJS::Lexer:

Classes

struct  State
 

Public Types

enum  {
  T_ABSTRACT = T_RESERVED_WORD , T_BOOLEAN = T_RESERVED_WORD , T_BYTE = T_RESERVED_WORD , T_CHAR = T_RESERVED_WORD ,
  T_DOUBLE = T_RESERVED_WORD , T_FINAL = T_RESERVED_WORD , T_FLOAT = T_RESERVED_WORD , T_GOTO = T_RESERVED_WORD ,
  T_IMPLEMENTS = T_RESERVED_WORD , T_INT = T_RESERVED_WORD , T_INTERFACE = T_RESERVED_WORD , T_LONG = T_RESERVED_WORD ,
  T_NATIVE = T_RESERVED_WORD , T_PACKAGE = T_RESERVED_WORD , T_PRIVATE = T_RESERVED_WORD , T_PROTECTED = T_RESERVED_WORD ,
  T_SHORT = T_RESERVED_WORD , T_SYNCHRONIZED = T_RESERVED_WORD , T_THROWS = T_RESERVED_WORD , T_TRANSIENT = T_RESERVED_WORD ,
  T_VOLATILE = T_RESERVED_WORD
}
 
enum  Error {
  NoError , IllegalCharacter , IllegalNumber , UnclosedStringLiteral ,
  IllegalEscapeSequence , IllegalUnicodeEscapeSequence , UnclosedComment , IllegalExponentIndicator ,
  IllegalIdentifier , IllegalHexadecimalEscapeSequence
}
 
enum  RegExpBodyPrefix { NoPrefix , EqualPrefix }
 
enum  RegExpFlag {
  RegExp_Global = 0x01 , RegExp_IgnoreCase = 0x02 , RegExp_Multiline = 0x04 , RegExp_Unicode = 0x08 ,
  RegExp_Sticky = 0x10
}
 
enum  ParseModeFlags { QmlMode = 0x1 , YieldIsKeyword = 0x2 , StaticIsKeyword = 0x4 }
 
enum class  ImportState { SawImport , NoQmlImport }
 
enum class  LexMode { WholeCode , LineByLine }
 
enum class  CodeContinuation { Reset , Continue }
 
enum  ParenthesesState { IgnoreParentheses , CountParentheses , BalancedParentheses }
 
enum class  CommentState { NoComment , HadComment , InMultilineComment }
 

Public Member Functions

 Lexer (Engine *engine, LexMode lexMode=LexMode::WholeCode)
 
bool qmlMode () const
 
bool yieldIsKeyWord () const
 
void setStaticIsKeyword (bool b)
 
QString code () const
 
void setCode (const QString &code, int lineno, bool qmlMode=true, CodeContinuation codeContinuation=CodeContinuation::Reset)
 
int lex ()
 
bool scanRegExp (RegExpBodyPrefix prefix=NoPrefix)
 
bool scanDirectives (Directives *directives, DiagnosticMessage *error)
 
int regExpFlags () const
 
QString regExpPattern () const
 
int tokenKind () const
 
int tokenOffset () const
 
int tokenLength () const
 
int tokenStartLine () const
 
int tokenStartColumn () const
 
QStringView tokenSpell () const
 
QStringView rawString () const
 
double tokenValue () const
 
QString tokenText () const
 
Error errorCode () const
 
QString errorMessage () const
 
bool canInsertAutomaticSemicolon (int token) const
 
void enterGeneratorBody ()
 
void leaveGeneratorBody ()
 
const Statestate () const
 
void setState (const State &state)
 

Static Protected Member Functions

static int classify (const QChar *s, int n, int parseModeFlags)
 

Friends

QML_PARSER_EXPORT QDebug operator<< (QDebug dbg, const Lexer &l)
 

Detailed Description

Definition at line 34 of file qqmljslexer_p.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
T_ABSTRACT 
T_BOOLEAN 
T_BYTE 
T_CHAR 
T_DOUBLE 
T_FINAL 
T_FLOAT 
T_GOTO 
T_IMPLEMENTS 
T_INT 
T_INTERFACE 
T_LONG 
T_NATIVE 
T_PACKAGE 
T_PRIVATE 
T_PROTECTED 
T_SHORT 
T_SYNCHRONIZED 
T_THROWS 
T_TRANSIENT 
T_VOLATILE 

Definition at line 37 of file qqmljslexer_p.h.

◆ CodeContinuation

Enumerator
Reset 
Continue 

Definition at line 100 of file qqmljslexer_p.h.

◆ CommentState

enum class QQmlJS::Lexer::CommentState
strong
Enumerator
NoComment 
HadComment 
InMultilineComment 

Definition at line 144 of file qqmljslexer_p.h.

◆ Error

Enumerator
NoError 
IllegalCharacter 
IllegalNumber 
UnclosedStringLiteral 
IllegalEscapeSequence 
IllegalUnicodeEscapeSequence 
UnclosedComment 
IllegalExponentIndicator 
IllegalIdentifier 
IllegalHexadecimalEscapeSequence 

Definition at line 61 of file qqmljslexer_p.h.

◆ ImportState

enum class QQmlJS::Lexer::ImportState
strong
Enumerator
SawImport 
NoQmlImport 

Definition at line 93 of file qqmljslexer_p.h.

◆ LexMode

enum class QQmlJS::Lexer::LexMode
strong
Enumerator
WholeCode 
LineByLine 

Definition at line 98 of file qqmljslexer_p.h.

◆ ParenthesesState

Enumerator
IgnoreParentheses 
CountParentheses 
BalancedParentheses 

Definition at line 138 of file qqmljslexer_p.h.

◆ ParseModeFlags

Enumerator
QmlMode 
YieldIsKeyword 
StaticIsKeyword 

Definition at line 87 of file qqmljslexer_p.h.

◆ RegExpBodyPrefix

Enumerator
NoPrefix 
EqualPrefix 

Definition at line 74 of file qqmljslexer_p.h.

◆ RegExpFlag

Enumerator
RegExp_Global 
RegExp_IgnoreCase 
RegExp_Multiline 
RegExp_Unicode 
RegExp_Sticky 

Definition at line 79 of file qqmljslexer_p.h.

Constructor & Destructor Documentation

◆ Lexer()

Lexer::Lexer ( Engine * engine,
LexMode lexMode = LexMode::WholeCode )

Definition at line 50 of file qqmljslexer.cpp.

References engine.

Member Function Documentation

◆ canInsertAutomaticSemicolon()

bool Lexer::canInsertAutomaticSemicolon ( int token) const

◆ classify()

int QQmlJS::Lexer::classify ( const QChar * s,
int n,
int parseModeFlags )
staticprotected

Definition at line 898 of file qqmljskeywords_p.h.

References QQmlJS::classify10(), QQmlJS::classify12(), QQmlJS::classify2(), QQmlJS::classify3(), QQmlJS::classify4(), QQmlJS::classify5(), QQmlJS::classify6(), QQmlJS::classify7(), QQmlJS::classify8(), and QQmlJS::classify9().

+ Here is the call graph for this function:

◆ code()

QString Lexer::code ( ) const

Definition at line 62 of file qqmljslexer.cpp.

Referenced by addLexToken(), and setCode().

+ Here is the caller graph for this function:

◆ enterGeneratorBody()

void QQmlJS::Lexer::enterGeneratorBody ( )
inline

Definition at line 146 of file qqmljslexer_p.h.

◆ errorCode()

Lexer::Error Lexer::errorCode ( ) const

Definition at line 1550 of file qqmljslexer.cpp.

References QQmlJS::Lexer::State::errorCode.

Referenced by addLexToken().

+ Here is the caller graph for this function:

◆ errorMessage()

QString Lexer::errorMessage ( ) const

Definition at line 1555 of file qqmljslexer.cpp.

Referenced by addLexToken().

+ Here is the caller graph for this function:

◆ leaveGeneratorBody()

void QQmlJS::Lexer::leaveGeneratorBody ( )
inline

Definition at line 147 of file qqmljslexer_p.h.

◆ lex()

◆ qmlMode()

bool Lexer::qmlMode ( ) const

Definition at line 57 of file qqmljslexer.cpp.

Referenced by lex(), and setCode().

+ Here is the caller graph for this function:

◆ rawString()

QStringView QQmlJS::Lexer::rawString ( ) const
inline

Definition at line 129 of file qqmljslexer_p.h.

◆ regExpFlags()

int QQmlJS::Lexer::regExpFlags ( ) const
inline

Definition at line 118 of file qqmljslexer_p.h.

◆ regExpPattern()

QString QQmlJS::Lexer::regExpPattern ( ) const
inline

Definition at line 119 of file qqmljslexer_p.h.

◆ scanDirectives()

bool Lexer::scanDirectives ( Directives * directives,
DiagnosticMessage * error )

Definition at line 1642 of file qqmljslexer.cpp.

References error, QQmlJS::Lexer::State::handlingDirectives, QQmlJS::Directives::importFile(), QQmlJS::Directives::importModule(), isUriToken(), lex(), QQmlJS::Directives::pragmaLibrary(), Q_ASSERT, setError(), QQmlJS::Lexer::State::tokenKind, tokenStartColumn(), tokenStartLine(), tokenText(), and QCoreApplication::translate().

+ Here is the call graph for this function:

◆ scanRegExp()

bool Lexer::scanRegExp ( RegExpBodyPrefix prefix = NoPrefix)

Definition at line 1385 of file qqmljslexer.cpp.

References QQmlJS::Lexer::State::currentChar, EqualPrefix, QQmlJS::Lexer::State::patternFlags, regExpFlagFromChar(), QString::resize(), QCoreApplication::translate(), and QQmlJS::Lexer::State::validTokenText.

Referenced by addLexToken().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCode()

void Lexer::setCode ( const QString & code,
int lineno,
bool qmlMode = true,
Lexer::CodeContinuation codeContinuation = CodeContinuation::Reset )

Definition at line 67 of file qqmljslexer.cpp.

References QString::clear(), code(), Continue, qmlMode(), QString::reserve(), Reset, QQmlJS::Engine::setCode(), QString::size(), and QString::unicode().

Referenced by QQmlJS::Dom::JsFile::JsFile(), QQmlJS::Dom::QmlFile::QmlFile(), QQmlJSLinter::applyFixes(), QV4::Compiler::Codegen::compileModule(), QmlIR::IRBuilder::generateFromQml(), QQmlLSUtils::isValidEcmaScriptIdentifier(), QQmlJSLinter::lintFile(), QQmlJSTypeReader::operator()(), QQmlJSTypeDescriptionReader::operator()(), QQmlJS::Dom::Scanner::operator()(), QV4::Script::parse(), QV4::FunctionCtor::parse(), QV4::Script::precompile(), and qCompileJSFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setState()

void Lexer::setState ( const State & state)

Definition at line 1801 of file qqmljslexer.cpp.

References state().

Referenced by QQmlJS::Dom::Scanner::operator()().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setStaticIsKeyword()

void QQmlJS::Lexer::setStaticIsKeyword ( bool b)
inline

Definition at line 107 of file qqmljslexer_p.h.

◆ state()

const Lexer::State & Lexer::state ( ) const

Definition at line 1797 of file qqmljslexer.cpp.

Referenced by addLexToken(), QQmlJS::Dom::Scanner::operator()(), and setState().

+ Here is the caller graph for this function:

◆ tokenKind()

int QQmlJS::Lexer::tokenKind ( ) const
inline

Definition at line 121 of file qqmljslexer_p.h.

Referenced by lex().

+ Here is the caller graph for this function:

◆ tokenLength()

int QQmlJS::Lexer::tokenLength ( ) const
inline

Definition at line 123 of file qqmljslexer_p.h.

Referenced by addLexToken().

+ Here is the caller graph for this function:

◆ tokenOffset()

int QQmlJS::Lexer::tokenOffset ( ) const
inline

Definition at line 122 of file qqmljslexer_p.h.

Referenced by lex().

+ Here is the caller graph for this function:

◆ tokenSpell()

QStringView QQmlJS::Lexer::tokenSpell ( ) const
inline

Definition at line 128 of file qqmljslexer_p.h.

◆ tokenStartColumn()

int QQmlJS::Lexer::tokenStartColumn ( ) const
inline

Definition at line 126 of file qqmljslexer_p.h.

Referenced by addLexToken(), lex(), and scanDirectives().

+ Here is the caller graph for this function:

◆ tokenStartLine()

int QQmlJS::Lexer::tokenStartLine ( ) const
inline

Definition at line 125 of file qqmljslexer_p.h.

Referenced by lex(), and scanDirectives().

+ Here is the caller graph for this function:

◆ tokenText()

QString Lexer::tokenText ( ) const

Definition at line 1539 of file qqmljslexer.cpp.

References QQmlJS::Lexer::State::tokenKind, and QQmlJS::Lexer::State::validTokenText.

Referenced by addLexToken(), and scanDirectives().

+ Here is the caller graph for this function:

◆ tokenValue()

double QQmlJS::Lexer::tokenValue ( ) const
inline

Definition at line 130 of file qqmljslexer_p.h.

◆ yieldIsKeyWord()

bool QQmlJS::Lexer::yieldIsKeyWord ( ) const
inline

Definition at line 106 of file qqmljslexer_p.h.

Friends And Related Symbol Documentation

◆ operator<<

QML_PARSER_EXPORT QDebug operator<< ( QDebug dbg,
const Lexer & l )
friend

Definition at line 443 of file qqmljslexer.cpp.


The documentation for this class was generated from the following files: