decompiler  1.0.0
Public Types | Public Member Functions | Public Attributes | List of all members
OpToken Class Reference

A token representing an operator in the high-level language. More...

#include <printlanguage.hh>

Public Types

enum  tokentype {
  binary, unary_prefix, postsurround, presurround,
  space
}
 The possible types of operator token. More...
 

Public Member Functions

bool parentheses (const OpToken &op2, int4 stage) const
 Determine if the given token should be emitted in its own parenthetic expression. More...
 

Public Attributes

const char * print
 Printing characters for the token.
 
int4 stage
 Additional elements consumed from the RPN stack when emitting this token.
 
int4 precedence
 Precedence level of this token (higher binds more tightly)
 
bool associative
 True if the operator is associative.
 
tokentype type
 The basic token type.
 
int4 spacing
 Spaces to print around operator.
 
int4 bump
 Spaces to indent if we break here.
 
OpTokennegate
 The token representing the negation of this token.
 

Detailed Description

A token representing an operator in the high-level language.

The token knows how to print itself and other syntax information like precedence level and associativity within the language, desired spacing, and how operator groups its input expressions. Note that an operator has a broader meaning than just p-code operators in this context.

Member Enumeration Documentation

◆ tokentype

The possible types of operator token.

Enumerator
binary 

Binary operator form (printed between its inputs)

unary_prefix 

Unary operator form (printed before its input)

postsurround 

Function or array operator form.

presurround 

Modifier form (like a cast operation)

space 

No explicitly printed token.

Member Function Documentation

◆ parentheses()

bool OpToken::parentheses ( const OpToken op2,
int4  stage 
) const

Determine if the given token should be emitted in its own parenthetic expression.

This token is being emitted. Check if its input expression, ending with the given operator token, needs to be surrounded by parentheses to convey the proper meaning.

Parameters
op2is the input token to this operator
stageis the stage of this operator currently being printed
Returns
true if op2 (as input to this) should be parenthesized

References associative, binary, postsurround, precedence, presurround, space, stage, type, and unary_prefix.


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