Ivory Language Lexical Specification

Description

This page lists all the major token classes of the Ivory language.

Identifiers

Identifiers refer to a named program element. Unlike C, Ivory does not require the lexer to distinguish typenames.

Typenames have the following regular expression:

[a-zA-Z][0-9a-zA-Z_]*

Literals

Literals specify a value.

Integer can be given in decimal, hexidecimal, or octal

Decimal literals have the following regular expression:

[0-9]*

Octal literals have the following regular expression:

0[0-7]*

Hexidecimal literals have the following regular expression:

0x[0-9a-f]*

Floating point literals give a floating point value. They have the following regular expression:

[0-9]*"."[0-9]?([eE][+-]?[0-9]*)?

String and character literals behave exactly as they do in C. String literals are enclosed in double quotes, and character literals are in single quotes. Both observe C-style escape sequences. Adjacent string literals are combined into one.

Comments

The

//
sequence ignores the rest of the line. Additionally, anything inside a
/*
and a
*/
is ignored. Ivory supports nested comments, unlike C.

Operators

The following operators are recognized:

  • &
  • &&
  • &=
  • ->
  • =
  • |
  • ||
  • |=
  • |<
  • >|
  • ^
  • :
  • /
  • /=
  • .
  • ==
  • !
  • <
  • >
  • <=
  • >=
  • <<
  • >>
  • <<=
  • >>=
  • {
  • }
  • [
  • ]
  • (
  • )
  • -
  • --
  • -=
  • %
  • %=
  • !=
  • ?
  • +
  • ++
  • +=
  • ...
  • ;
  • *
  • *=
  • ^=
  • ~

Keywords

The reserved words are recognized:

  • asm
  • break
  • case
  • const
  • catch
  • continue
  • default
  • do
  • else
  • enum
  • export
  • exception
  • extern
  • final
  • for
  • global
  • if
  • import
  • include
  • inline
  • private
  • public
  • pure
  • return
  • restrict
  • shared
  • signed
  • signature
  • sizeof
  • static
  • strict
  • struct
  • switch
  • template
  • throw
  • type
  • union
  • unsigned
  • volatile
  • while