v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
torque-parser.cc File Reference
#include "src/torque/torque-parser.h"
#include <algorithm>
#include <cctype>
#include <optional>
#include <set>
#include <stdexcept>
#include <unordered_map>
#include "include/v8config.h"
#include "src/common/globals.h"
#include "src/flags/flags.h"
#include "src/torque/ast.h"
#include "src/torque/constants.h"
#include "src/torque/declarations.h"
#include "src/torque/earley-parser.h"
#include "src/torque/global-context.h"
#include "src/torque/utils.h"
Include dependency graph for torque-parser.cc:

Go to the source code of this file.

Classes

struct  v8::internal::torque::ExpressionWithSource
 
struct  v8::internal::torque::TypeswitchCase
 
struct  v8::internal::torque::EnumEntry
 
class  v8::internal::torque::BuildFlags
 

Namespaces

namespace  v8
 
namespace  v8::internal
 
namespace  v8::internal::torque
 

Typedefs

using v8::internal::torque::TypeList = std::vector<TypeExpression*>
 

Functions

void v8::internal::torque::ParseTorque (const std::string &input)
 

Variable Documentation

◆ additiveExpression

Symbol* additiveExpression
Initial value:
=
BinaryOperator(multiplicativeExpression, OneOf({"+", "-"}))
Symbol * multiplicativeExpression

Definition at line 2691 of file torque-parser.cc.

◆ annotation

Symbol annotation
Initial value:
= {Rule(
{&annotationName, Optional<AnnotationParameter>(&annotationParameters)},
MakeAnnotation)}
Symbol annotationParameters
Symbol annotationName

Definition at line 2460 of file torque-parser.cc.

◆ annotationName

Symbol annotationName
Initial value:
= {
Rule({Pattern(MatchAnnotation)}, MakeIdentifierFromMatchedInput)}

Definition at line 2422 of file torque-parser.cc.

◆ annotationParameter

Symbol annotationParameter
Initial value:
= {
Rule({&identifier}, MakeStringAnnotationParameter),
Rule({&int32Literal}, MakeIntAnnotationParameter),
Rule({&externalString}, MakeStringAnnotationParameter)}
Symbol identifier
Symbol int32Literal
Symbol externalString

Definition at line 2450 of file torque-parser.cc.

◆ annotationParameters

Symbol annotationParameters
Initial value:
= {
Rule({Token("("), &annotationParameter, Token(")")})}
Symbol annotationParameter

Definition at line 2456 of file torque-parser.cc.

◆ annotations

Symbol* annotations = List<Annotation>(&annotation)

Definition at line 2465 of file torque-parser.cc.

◆ argumentList

Symbol argumentList
Initial value:
= {Rule(
{Token("("), List<Expression*>(expression, Token(",")), Token(")")})}

Definition at line 2620 of file torque-parser.cc.

◆ assignmentExpression

Symbol assignmentExpression
Initial value:
= {
MakeAssignmentExpression)}
Symbol conditionalExpression
Symbol assignmentExpression
Symbol assignmentOperator

Definition at line 2746 of file torque-parser.cc.

◆ assignmentOperator

Symbol assignmentOperator
Initial value:
= {
Rule({Token("=")}, YieldDefaultValue<std::optional<std::string>>),
Rule({OneOf({"*=", "/=", "%=", "+=", "-=", "<<=", ">>=", ">>>=", "&=",
"^=", "|="})},
ExtractAssignmentOperator)}

Definition at line 2739 of file torque-parser.cc.

◆ atomarStatement

Symbol atomarStatement
Initial value:
= {
Rule({expression}, MakeExpressionStatement),
Rule({Token("return"), Optional<Expression*>(expression)},
MakeReturnStatement),
Rule({Token("tail"), &callExpression}, MakeTailCallStatement),
Rule({Token("break")}, MakeBreakStatement),
Rule({Token("continue")}, MakeContinueStatement),
Rule({Token("goto"), &name,
TryOrDefault<std::vector<Expression*>>(&argumentList)},
MakeGotoStatement),
Rule({OneOf({"debug", "unreachable"})}, MakeDebugStatement)}
Symbol name
Symbol callExpression
Symbol argumentList

Definition at line 2788 of file torque-parser.cc.

◆ bitFieldDeclaration

Symbol bitFieldDeclaration
Initial value:
= {Rule({&name, Token(":"), &type, Token(":"),
&int32Literal, Token("bit"), Token(";")},
MakeBitFieldDeclaration)}
Symbol type

Definition at line 2568 of file torque-parser.cc.

◆ bitwiseExpression

Symbol* bitwiseExpression
Initial value:
=
BinaryOperator(equalityExpression, OneOf({"&", "|"}))
Symbol * equalityExpression

Definition at line 2716 of file torque-parser.cc.

◆ block

Symbol block
Initial value:
= {
Rule({CheckIf(Token("deferred")), Token("{"),
ListAllowIfAnnotation<Statement*>(&statement), Token("}")},
MakeBlockStatement)}
Symbol statement

Definition at line 2752 of file torque-parser.cc.

◆ callExpression

Symbol callExpression
Initial value:
= {Rule(
Symbol * optionalOtherwise
Symbol identifierExpression

Definition at line 2624 of file torque-parser.cc.

◆ callMethodExpression

Symbol callMethodExpression
Initial value:
= {Rule(
MakeMethodCall)}
Symbol primaryExpression

Definition at line 2628 of file torque-parser.cc.

◆ classField

Symbol classField
Initial value:
= {
Rule({annotations, CheckIf(Token("weak")), CheckIf(Token("const")), &name,
CheckIf(Token("?")), optionalArraySpecifier, Token(":"), &type,
Token(";")},
MakeClassField)}
Symbol * annotations
Symbol * optionalArraySpecifier

Definition at line 2556 of file torque-parser.cc.

◆ conditionalExpression

Symbol conditionalExpression
Initial value:
= {
Rule({&logicalOrExpression, Token("?"), expression, Token(":"),
MakeConditionalExpression)}
Symbol logicalOrExpression
Symbol * expression

Definition at line 2732 of file torque-parser.cc.

◆ declaration

Symbol declaration

Definition at line 2862 of file torque-parser.cc.

◆ declarationList

Symbol declarationList
Initial value:
= {
Rule({List<std::vector<Declaration*>>(&declaration)}, ConcatList)}
Symbol declaration

Definition at line 2949 of file torque-parser.cc.

◆ enumEntry

Symbol enumEntry
Initial value:
= {
Rule({annotations, &name, optionalTypeSpecifier}, MakeEnumEntry)}
Symbol * optionalTypeSpecifier

Definition at line 2773 of file torque-parser.cc.

◆ equalityExpression

Symbol* equalityExpression
Initial value:
=
BinaryOperator(&relationalExpression, OneOf({"==", "!="}))
Symbol relationalExpression

Definition at line 2712 of file torque-parser.cc.

◆ expression

Symbol* expression = &assignmentExpression

Definition at line 2412 of file torque-parser.cc.

◆ expressionWithSource

Symbol expressionWithSource = {Rule({expression}, MakeExpressionWithSource)}

Definition at line 2767 of file torque-parser.cc.

◆ externalString

Symbol externalString = {Rule({&stringLiteral}, StringLiteralUnquoteAction)}

Definition at line 2434 of file torque-parser.cc.

◆ file

Symbol file
Initial value:
= {Rule({&file, Token("import"), &externalString},
ProcessTorqueImportDeclaration),
Rule({&file, &declaration}, AddGlobalDeclarations), Rule({})}
Symbol file

Definition at line 2952 of file torque-parser.cc.

◆ floatingPointLiteral

Symbol floatingPointLiteral
Initial value:
= {
Rule({Pattern(MatchFloatingPointLiteral)}, YieldDouble)}

Definition at line 2442 of file torque-parser.cc.

◆ genericParameter

Symbol genericParameter
Initial value:
= {
Rule({&name, Token(":"), Token("type"),
Optional<TypeExpression*>(Sequence({Token("extends"), &type}))},
MakeGenericParameter)}

Definition at line 2494 of file torque-parser.cc.

◆ genericParameters

Symbol genericParameters
Initial value:
= {
Rule({Token("<"), List<GenericParameter>(&genericParameter, Token(",")),
Token(">")})}
Symbol genericParameter

Definition at line 2500 of file torque-parser.cc.

◆ genericSpecializationTypeList

Symbol genericSpecializationTypeList
Initial value:
= {
Rule({Token("<"), typeList, Token(">")})}
Symbol * typeList

Definition at line 2505 of file torque-parser.cc.

◆ identifier

Symbol identifier
Initial value:
= {Rule({Pattern(MatchIdentifier)}, YieldMatchedInput),
Rule({Token("runtime")}, YieldMatchedInput)}

Definition at line 2415 of file torque-parser.cc.

◆ identifierExpression

Symbol identifierExpression
Initial value:
= {
TryOrDefault<TypeList>(&genericSpecializationTypeList)},
MakeIdentifierExpression),
}
Symbol genericSpecializationTypeList
Symbol namespaceQualification

Definition at line 2613 of file torque-parser.cc.

◆ implicitParameterList

Symbol implicitParameterList
Initial value:
{
Rule({Token("("), OneOf({"implicit", "js-implicit"}),
List<NameAndTypeExpression>(&nameAndType, Token(",")), Token(")")},
MakeImplicitParameterList)}
Symbol nameAndType

Definition at line 2511 of file torque-parser.cc.

◆ incrementDecrementOperator

Symbol incrementDecrementOperator
Initial value:
= {
Rule({Token("++")},
YieldIntegralConstant<IncrementDecrementOperator,
IncrementDecrementOperator::kIncrement>),
Rule({Token("--")},
YieldIntegralConstant<IncrementDecrementOperator,
IncrementDecrementOperator::kDecrement>)}

Definition at line 2604 of file torque-parser.cc.

◆ initializerList

Symbol initializerList
Initial value:
= {
Rule({Token("{"), List<NameAndExpression>(&namedExpression, Token(",")),
Token("}")})}
Symbol namedExpression

Definition at line 2638 of file torque-parser.cc.

◆ int32Literal

Symbol int32Literal
Initial value:
= {Rule({Pattern(MatchIntegerLiteral)}, YieldInt32),
Rule({Pattern(MatchHexLiteral)}, YieldInt32)}

Definition at line 2446 of file torque-parser.cc.

◆ integerLiteral

Symbol integerLiteral
Initial value:
= {
Rule({Pattern(MatchIntegerLiteral)}, YieldIntegerLiteral),
Rule({Pattern(MatchHexLiteral)}, YieldIntegerLiteral)}

Definition at line 2437 of file torque-parser.cc.

◆ intrinsicCallExpression

Symbol intrinsicCallExpression
Initial value:
= {Rule(
{&intrinsicName, TryOrDefault<TypeList>(&genericSpecializationTypeList),
MakeIntrinsicCallExpression)}
Symbol intrinsicName

Definition at line 2643 of file torque-parser.cc.

◆ intrinsicName

Symbol intrinsicName
Initial value:
= {
Rule({Pattern(MatchIntrinsicName)}, MakeIdentifierFromMatchedInput)}

Definition at line 2426 of file torque-parser.cc.

◆ labelParameter

Symbol labelParameter
Initial value:
= {Rule(
{&name,
TryOrDefault<TypeList>(Sequence({Token("("), typeList, Token(")")}))},
MakeLabelAndTypes)}

Definition at line 2529 of file torque-parser.cc.

◆ logicalAndExpression

Symbol logicalAndExpression
Initial value:
= {
Rule({&logicalAndExpression, Token("&&"), bitwiseExpression},
MakeLogicalAndExpression)}
Symbol * bitwiseExpression
Symbol logicalAndExpression

Definition at line 2720 of file torque-parser.cc.

◆ logicalOrExpression

Symbol logicalOrExpression
Initial value:
= {
Rule({&logicalOrExpression, Token("||"), &logicalAndExpression},
MakeLogicalOrExpression)}

Definition at line 2726 of file torque-parser.cc.

◆ map_

std::map<std::string, std::pair<AnnotationParameter, SourcePosition> > map_
private

Definition at line 737 of file torque-parser.cc.

◆ method

Symbol method
Initial value:
= {Rule(
{CheckIf(Token("transitioning")),
Optional<std::string>(Sequence({Token("operator"), &externalString})),
Token("macro"), &name, &parameterListNoVararg, &returnType,
MakeMethodDeclaration)}
Symbol * optionalLabelList
Symbol parameterListNoVararg
Symbol returnType

Definition at line 2847 of file torque-parser.cc.

◆ multiplicativeExpression

Symbol* multiplicativeExpression
Initial value:
=
BinaryOperator(&unaryExpression, OneOf({"*", "/", "%"}))
Symbol unaryExpression

Definition at line 2687 of file torque-parser.cc.

◆ name

Symbol name = {Rule({&identifier}, MakeIdentifier)}

Definition at line 2419 of file torque-parser.cc.

◆ nameAndType

Symbol nameAndType = {Rule({&name, Token(":"), &type}, MakeNameAndType)}

Definition at line 2549 of file torque-parser.cc.

◆ namedExpression

Symbol namedExpression
Initial value:
= {
Rule({&name, Token(":"), expression}, MakeNameAndExpression),
Rule({expression}, MakeNameAndExpressionFromExpression)}

Definition at line 2633 of file torque-parser.cc.

◆ namespaceQualification

Symbol namespaceQualification
Initial value:
= {
Rule({CheckIf(Token("::")),
List<std::string>(Sequence({&identifier, Token("::")}))},
MakeNamespaceQualification)}

Definition at line 2468 of file torque-parser.cc.

◆ newExpression

Symbol newExpression
Initial value:
= {
Rule({Token("new"),
CheckIf(Sequence({Token("("), Token("Pretenured"), Token(")")})),
CheckIf(Sequence({Token("("), Token("ClearPadding"), Token(")")})),
MakeNewExpression)}
Symbol simpleType
Symbol initializerList

Definition at line 2649 of file torque-parser.cc.

◆ optionalArraySpecifier

Symbol* optionalArraySpecifier
Initial value:
=
Optional<Expression*>(Sequence({Token("["), expression, Token("]")}))

Definition at line 2552 of file torque-parser.cc.

◆ optionalBody

Symbol optionalBody
Initial value:
= {
Rule({&block}, CastParseResult<Statement*, std::optional<Statement*>>),
Rule({Token(";")}, YieldDefaultValue<std::optional<Statement*>>)}

Definition at line 2842 of file torque-parser.cc.

◆ optionalClassBody

Symbol optionalClassBody
Initial value:
= {
Rule({Token("{"), List<Declaration*>(&method),
List<ClassFieldExpression>(&classField), Token("}")},
MakeClassBody),
Rule({Token(";")}, YieldDefaultValue<std::optional<ClassBody*>>)}
Symbol method
Symbol classField

Definition at line 2855 of file torque-parser.cc.

◆ optionalGenericParameters

Symbol* optionalGenericParameters = Optional<TypeList>(&genericParameters)

Definition at line 2509 of file torque-parser.cc.

◆ optionalImplicitParameterList

Symbol* optionalImplicitParameterList
Initial value:
{
Optional<ImplicitParameters>(&implicitParameterList)}
Symbol implicitParameterList

Definition at line 2516 of file torque-parser.cc.

◆ optionalLabelList

Symbol* optionalLabelList
Initial value:
{TryOrDefault<LabelAndTypesVector>(
Sequence({Token("labels"),
NonemptyList<LabelAndTypes>(&labelParameter, Token(","))}))}
Symbol labelParameter

Definition at line 2539 of file torque-parser.cc.

◆ optionalOtherwise

Symbol* optionalOtherwise
Initial value:
{TryOrDefault<std::vector<Statement*>>(
Sequence({Token("otherwise"),
NonemptyList<Statement*>(&atomarStatement, Token(","))}))}
Symbol atomarStatement

Definition at line 2544 of file torque-parser.cc.

◆ optionalTypeSpecifier

Symbol* optionalTypeSpecifier
Initial value:
=
Optional<TypeExpression*>(Sequence({Token(":"), &type}))

Definition at line 2769 of file torque-parser.cc.

◆ parameterListAllowVararg

Symbol parameterListAllowVararg
Initial value:
= {
Rule({optionalImplicitParameterList, Token("("),
List<NameAndTypeExpression>(Sequence({&nameAndType, Token(",")})),
Token("..."), &identifier, Token(")")},
MakeParameterList<true, true>)}
Symbol * optionalImplicitParameterList

Definition at line 2579 of file torque-parser.cc.

◆ parameterListNoVararg

Symbol parameterListNoVararg
Initial value:
= {
Rule({optionalImplicitParameterList, Token("("),
List<NameAndTypeExpression>(&nameAndType, Token(",")), Token(")")},
MakeParameterList<false, true>)}

Definition at line 2573 of file torque-parser.cc.

◆ primaryExpression

Symbol primaryExpression
Initial value:
= {
Rule({&callExpression}),
Rule({&primaryExpression, Token("."), &name}, MakeFieldAccessExpression),
Rule({&primaryExpression, Token("->"), &name},
MakeReferenceFieldAccessExpression),
Rule({&primaryExpression, Token("["), expression, Token("]")},
MakeElementAccessExpression),
Rule({&integerLiteral}, MakeIntegerLiteralExpression),
Rule({&floatingPointLiteral}, MakeFloatingPointLiteralExpression),
Rule({&stringLiteral}, MakeStringLiteralExpression),
Rule({&newExpression}),
Rule({Token("("), expression, Token(")")})}
StructExpression * MakeStructExpression(TypeExpression *type, std::vector< NameAndExpression > initializers)
Definition ast.h:1337
FieldAccessExpression * MakeFieldAccessExpression(Expression *object, std::string field)
Definition ast.h:1291
Symbol floatingPointLiteral
Symbol newExpression
Symbol integerLiteral
Symbol stringLiteral
Symbol intrinsicCallExpression
Symbol callMethodExpression

Definition at line 2657 of file torque-parser.cc.

◆ relationalExpression

Symbol relationalExpression
Initial value:
= {
Rule({shiftExpression}),
Rule({shiftExpression, OneOf({"<", ">", "<=", ">="}), shiftExpression},
MakeBinaryOperator)}
Symbol * shiftExpression

Definition at line 2706 of file torque-parser.cc.

◆ returnType

Symbol returnType
Initial value:
= {Rule({Token(":"), &type}),
Rule({}, DeprecatedMakeVoidType)}

Definition at line 2535 of file torque-parser.cc.

◆ set_

std::set<std::string> set_
private

Definition at line 736 of file torque-parser.cc.

◆ shiftExpression

Symbol* shiftExpression = BinaryOperator(additiveExpression, &shiftOperator)

Definition at line 2701 of file torque-parser.cc.

◆ shiftOperator

Symbol shiftOperator
Initial value:
= {
Rule({Token("<<")}, MakeIdentifierFromMatchedInput),
Rule({Token(">"), Token(">")}, MakeRightShiftIdentifier),
Rule({Token(">"), Token(">"), Token(">")}, MakeRightShiftIdentifier)}

Definition at line 2695 of file torque-parser.cc.

◆ simpleType

Symbol simpleType
Initial value:
= {
Rule({Token("("), &type, Token(")")}),
Rule({&namespaceQualification, CheckIf(Token("constexpr")), &identifier,
TryOrDefault<std::vector<TypeExpression*>>(
Rule({Token("builtin"), Token("("), typeList, Token(")"), Token("=>"),
MakeFunctionTypeExpression),
Rule({CheckIf(Token("const")), Token("&"), &simpleType},
MakeReferenceTypeExpression)}
BasicTypeExpression * MakeBasicTypeExpression(std::vector< std::string > namespace_qualification, Identifier *name, std::vector< TypeExpression * > generic_arguments={})
Definition ast.h:1330

Definition at line 2477 of file torque-parser.cc.

◆ statement

Symbol statement

Definition at line 2801 of file torque-parser.cc.

◆ stringLiteral

Symbol stringLiteral
Initial value:
= {
Rule({Pattern(MatchStringLiteral)}, YieldMatchedInput)}

Definition at line 2430 of file torque-parser.cc.

◆ structField

Symbol structField
Initial value:
= {
Rule({CheckIf(Token("const")), &name, Token(":"), &type, Token(";")},
MakeStructField)}

Definition at line 2563 of file torque-parser.cc.

◆ tryHandler

Symbol tryHandler
Initial value:
= {
Rule({Token("label"), &name,
TryOrDefault<ParameterList>(&parameterListNoVararg), &block},
MakeLabelBlock),
Rule({Token("catch"), Token("("),
List<std::string>(&identifier, Token(",")), Token(")"), &block},
MakeCatchBlock)}

Definition at line 2758 of file torque-parser.cc.

◆ type

Symbol type
Initial value:
= {Rule({&simpleType}), Rule({&type, Token("|"), &simpleType},
MakeUnionTypeExpression)}

Definition at line 2490 of file torque-parser.cc.

◆ typeList

Symbol* typeList = List<TypeExpression*>(&type, Token(","))

Definition at line 2474 of file torque-parser.cc.

◆ typeListMaybeVarArgs

Symbol typeListMaybeVarArgs
Initial value:
= {
Rule({optionalImplicitParameterList, Token("("),
List<TypeExpression*>(Sequence({&type, Token(",")})), Token("..."),
Token(")")},
MakeParameterList<true, false>),
Rule({optionalImplicitParameterList, Token("("), typeList, Token(")")},
MakeParameterList<false, false>)}

Definition at line 2520 of file torque-parser.cc.

◆ typeswitchCase

Symbol typeswitchCase
Initial value:
= {
Rule({Token("case"), Token("("),
Optional<Identifier*>(Sequence({&name, Token(":")})), &type,
Token(")"), Token(":"), &block},
MakeTypeswitchCase)}

Definition at line 2835 of file torque-parser.cc.

◆ unaryExpression

Symbol unaryExpression
Initial value:
= {
Rule({OneOf({"+", "-", "!", "~", "&"}), &unaryExpression},
MakeUnaryOperator),
Rule({Token("*"), &unaryExpression}, MakeDereferenceExpression),
Rule({Token("..."), &unaryExpression}, MakeSpreadExpression),
MakeIncrementDecrementExpressionPrefix),
MakeIncrementDecrementExpressionPostfix)}
Symbol incrementDecrementOperator

Definition at line 2675 of file torque-parser.cc.

◆ varDeclaration

Symbol varDeclaration
Initial value:
= {
Rule({OneOf({"let", "const"}), &name, optionalTypeSpecifier},
MakeVarDeclarationStatement)}

Definition at line 2777 of file torque-parser.cc.

◆ varDeclarationWithInitialization

Symbol varDeclarationWithInitialization
Initial value:
= {
Rule({OneOf({"let", "const"}), &name, optionalTypeSpecifier, Token("="),
expression},
MakeVarDeclarationStatement)}

Definition at line 2782 of file torque-parser.cc.