---
title: "Lexical Rules"
url: https://docs.zeroc.com/ice/3.8/slice/lexical-rules
language: matlab
docs_index: https://docs.zeroc.com/llms.txt
---

> For an index of every page, see [llms.txt](https://docs.zeroc.com/llms.txt).

# Lexical Rules

Programming language: MATLAB. Other languages: [C++](https://docs.zeroc.com/ice/3.8/slice/lexical-rules/cpp.md), [C#](https://docs.zeroc.com/ice/3.8/slice/lexical-rules/csharp.md), [Java](https://docs.zeroc.com/ice/3.8/slice/lexical-rules/java.md), [JavaScript](https://docs.zeroc.com/ice/3.8/slice/lexical-rules/js.md), [PHP](https://docs.zeroc.com/ice/3.8/slice/lexical-rules/php.md), [Python](https://docs.zeroc.com/ice/3.8/slice/lexical-rules/python.md), [Ruby](https://docs.zeroc.com/ice/3.8/slice/lexical-rules/ruby.md), [Swift](https://docs.zeroc.com/ice/3.8/slice/lexical-rules/swift.md).

## Comments

Slice supports block comments, delimited by `/*` and `*/`, and line comments, which start with `//` and extend to the end of the line:

```slice
/*
 * Block comment.
 */

// Line comment.
```

Slice also supports doc comments, which document the definition that follows them: line comments that start with `///` and block comments that start with `/**`. See [Comment Syntax](https://docs.zeroc.com/ice/3.8/slice/documenting-slice-definitions/comment-syntax.md).

## Keywords

Slice uses a number of [keywords](https://docs.zeroc.com/ice/3.8/slice/slice-keywords.md), which must be spelled in lowercase, such as `class` and `dictionary`. The keywords `Object` and `Value` are the exceptions: they must be capitalized as shown.

## Identifiers

An identifier begins with an ASCII letter, followed by any number of ASCII letters, digits, and underscores. An identifier cannot begin or end with an underscore, or contain two consecutive underscores: `get_account_name` is legal, but `_account`, `account_`, and `get__account` are not. Non-ASCII letters, such as Å, cannot appear in an identifier.

An identifier cannot end with `Helper`, `Holder`, `Prx`, or `Ptr`: the Slice compilers reserve these suffixes.

### Case Sensitivity

Identifiers that differ only in capitalization are the same identifier: you cannot declare both `TimeOfDay` and `TIMEOFDAY` in the same scope. After you declare an identifier, you must refer to it with the same capitalization; otherwise, the compiler rejects the reference.

### Escaped Identifiers

You can use a Slice keyword as an identifier by prefixing it with a backslash:

```slice
struct Value     // Error!
{
    // ...
}

struct \Value    // OK
{
    // ...
}
```

The backslash lets an existing definition keep a name that a later version of Slice makes a keyword. In new definitions, avoid keywords as identifiers. A backslash before an identifier that is not a keyword has no effect.

### Language Mapping

A Slice identifier maps to an identical MATLAB identifier, or a MATLAB identifier derived from this Slice identifier. For example, Slice interface `Greeter` is mapped to the MATLAB class `GreeterPrx`.

A Slice identifier that is a MATLAB keyword keeps its name in the generated MATLAB code, which is then invalid. Give this identifier a MATLAB name of your choice with the `matlab:identifier` metadata directive. For example, `end` is a MATLAB keyword but a valid Slice identifier:

```slice
struct Range
{
    ["matlab:identifier:last"]
    int end;
}
```

In the generated MATLAB code, the field `end` becomes `last`.

## See Also

- [Slice Keywords](https://docs.zeroc.com/ice/3.8/slice/slice-keywords.md)
- [Comment Syntax](https://docs.zeroc.com/ice/3.8/slice/documenting-slice-definitions/comment-syntax.md)
- [Slice Metadata Directives](https://docs.zeroc.com/ice/3.8/slice/slice-metadata-directives/matlab.md)
