MCPcopy Index your code
hub / github.com/microsoft/typescript-go / parseLiteralExpression

Method parseLiteralExpression

internal/parser/parser.go:5795–5819  ·  view source on GitHub ↗
(intern bool)

Source from the content-addressed store, hash-verified

5793}
5794
5795func (p *Parser) parseLiteralExpression(intern bool) *ast.Node {
5796 pos := p.nodePos()
5797 text := p.scanner.TokenValue()
5798 if intern {
5799 text = p.internIdentifier(text)
5800 }
5801 tokenFlags := p.scanner.TokenFlags()
5802 var result *ast.Node
5803 switch p.token {
5804 case ast.KindStringLiteral:
5805 result = p.factory.NewStringLiteral(text, tokenFlags)
5806 case ast.KindNumericLiteral:
5807 result = p.factory.NewNumericLiteral(text, tokenFlags)
5808 case ast.KindBigIntLiteral:
5809 result = p.factory.NewBigIntLiteral(text, tokenFlags)
5810 case ast.KindRegularExpressionLiteral:
5811 result = p.factory.NewRegularExpressionLiteral(text, tokenFlags)
5812 case ast.KindNoSubstitutionTemplateLiteral:
5813 result = p.factory.NewNoSubstitutionTemplateLiteral(text, tokenFlags)
5814 default:
5815 panic("Unhandled case in parseLiteralExpression")
5816 }
5817 p.nextToken()
5818 return p.finishNode(result, pos)
5819}
5820
5821func (p *Parser) parseIdentifierNameErrorOnUnicodeEscapeSequence() *ast.Node {
5822 if p.scanner.HasUnicodeEscape() || p.scanner.HasExtendedUnicodeEscape() {

Callers 10

parseJSONTextMethod · 0.95
parseModuleSpecifierMethod · 0.95
parseModuleExportNameMethod · 0.95
parseLiteralTypeNodeMethod · 0.95
parseImportAttributeMethod · 0.95

Calls 12

nodePosMethod · 0.95
internIdentifierMethod · 0.95
nextTokenMethod · 0.95
finishNodeMethod · 0.95
panicFunction · 0.85
TokenValueMethod · 0.80
TokenFlagsMethod · 0.80
NewStringLiteralMethod · 0.80
NewNumericLiteralMethod · 0.80
NewBigIntLiteralMethod · 0.80

Tested by

no test coverage detected