view lexer/Keyword.d @ 154:0ea5d2f3e96b

Parsing "this" as constructor. Also removed regex from the test run program(seg fault - dmd???)
author Anders Johnsen <skabet@gmail.com>
date Mon, 21 Jul 2008 21:45:54 +0200
parents 6ec686d9c87d
children 57b0b4464a0b
line wrap: on
line source

module lexer.Keyword;

import lexer.Token;

/**
  A list of keywords in an associative array that link a string
  representation of the keyword to a Tok
  */
Tok[char[]] keywords;

static this ()
{
    keywords =
    [
        // types
        "byte"[]    : Tok.Byte,
        "ubyte"     : Tok.Ubyte,
        "short"     : Tok.Short,
        "ushort"    : Tok.Ushort,
        "int"       : Tok.Int,
        "uint"      : Tok.Uint,
        "long"      : Tok.Long,
        "ulong"     : Tok.Ulong,

        "char"      : Tok.Char,
        "wchar"     : Tok.Wchar,
        "dchar"     : Tok.Dchar,

        "bool"      : Tok.Bool,

        "float"     : Tok.Float,
        "double"    : Tok.Double,

        "void"      : Tok.Void,

        // type related
        "struct"    : Tok.Struct,
        "function"  : Tok.Function,
        "delegate"  : Tok.Delegate,
        "class"     : Tok.Class,
        "interface" : Tok.Interface,
        "union"     : Tok.Union,
        "typedef"   : Tok.Typedef,
        "typeid"    : Tok.Typeid,
        "typeof"    : Tok.Typeof,
        "sizeof"    : Tok.Sizeof,
        "alias"     : Tok.Alias,
        "this"      : Tok.This,
//        "super"     : Tok.Super,

        // control flow
        "if"        : Tok.If,
        "else"      : Tok.Else,
        "while"     : Tok.While,
        "for"       : Tok.For,
        "switch"    : Tok.Switch,
        "case"      : Tok.Case,
        "default"   : Tok.Default,
        "break"     : Tok.Break,
        "return"    : Tok.Return,
        "cast"      : Tok.Cast,

        // modules
        "module"    : Tok.Module,
        "import"    : Tok.Import,

        // attributse
        "public"    : Tok.Public,
        "private"   : Tok.Private,
        "protected" : Tok.Protected,
        "package"   : Tok.Package,
        "export"    : Tok.Export,
        "static"    : Tok.Static,
        "final"     : Tok.Final,
        "const"     : Tok.Const,
        "abstract"  : Tok.Abstract,
        "override"  : Tok.Override,
        "deprecated": Tok.Deprecated,
        "auto"      : Tok.Auto,
        "extern"    : Tok.Extern,

        // exceptions
        "assert"    : Tok.Assert,
        "throw"     : Tok.Throw,
        "try"       : Tok.Try,
        "catch"     : Tok.Catch,
        "finally"   : Tok.Finally,

        // functions
        "in"        : Tok.In,
        "out"       : Tok.Out,
        "body"      : Tok.Body,

        "asm"       : Tok.Asm
    ];
}