Skip to main content

TokenBase

Base class for operators and literals, mainly for debugging and for throwing syntax errors.

Attributes

AttributeTypeDescription
idstring = nullnode/token type name
valuestring = nullused by literals
firstobject = nullused by tree nodes

Methods


nud()

@classmethod
def nud(
parser: [Parser](../../test/html/parser.md?sid=django_test_html_parser)
) - > null

Null denotation - called in prefix context. Raises a syntax error because the token is not expected in a prefix position within an if tag.

Parameters

NameTypeDescription
parser[Parser](../../test/html/parser.md?sid=django_test_html_parser)The parser instance used to raise the syntax error with context-specific information

Returns

TypeDescription
null

led()

@classmethod
def led(
left: [TokenBase](tokenbase.md?sid=django_template_smartif_tokenbase),
parser: [Parser](../../test/html/parser.md?sid=django_test_html_parser)
) - > null

Left denotation - called in infix context. Raises a syntax error because the token is not expected as an infix operator within an if tag.

Parameters

NameTypeDescription
left[TokenBase](tokenbase.md?sid=django_template_smartif_tokenbase)The token or node appearing to the left of this operator
parser[Parser](../../test/html/parser.md?sid=django_test_html_parser)The parser instance used to raise the syntax error with context-specific information

Returns

TypeDescription
null

display()

@classmethod
def display() - > string

Return what to display in error messages for this node

Returns

TypeDescription
stringThe node or token type name used for identification in error reports