SanitizeIdentifiers

de.uni_luebeck.isp.tessla.tessla_compiler.backends.rustBackend.preprocessing.SanitizeIdentifiers$

This translation step remaps all identifiers to make them comply with Rust spec.

  • Underscores are replaced with double underscores. This is done to give single underscores special meaning, since they are then only generated by the other rules here.

  • The '$' character is replaced with '_', because the dollar sign is restricted for use in macros.

  • Rust keywords are prefixed with 'k_'.

  • Any unicode characters that are not in UAX31-R1 are mapped to their hex representation.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Concise view

Value members

Concrete methods

def escapeIdentifier(id: Identifier): Identifier
def escapeName(name: String, location: Location): String

Replace underscores with double underscores, and any non UAX31-R1 characters with their hex representation as uXXXX_. Additionally check if the name ends up being a Rust keyword, and prefix it with 'k_'

Replace underscores with double underscores, and any non UAX31-R1 characters with their hex representation as uXXXX_. Additionally check if the name ends up being a Rust keyword, and prefix it with 'k_'

Attributes

location

The location for better error information.

name

The name to escape.

Returns:

The escaped name.

def escapeType(typ: TypeExpression): TypeExpression
def findAndEscapeIdentifiers(expr: ExpressionOrRef): ExpressionOrRef
def phase: TesslaPhase[Specification, Specification]
def unescapeName(name: String): String

Reverse escapeName, needed for struct display/parsing

Reverse escapeName, needed for struct display/parsing

Attributes

name

The name to unescape.

Returns:

The original name.

Concrete fields

final val RUST_KEYWORDS: Set[String]

https://doc.rust-lang.org/reference/keywords.html