aboutsummaryrefslogtreecommitdiff
path: root/src/boot/fe/token.ml
diff options
context:
space:
mode:
authorGraydon Hoare <[email protected]>2010-06-23 21:03:09 -0700
committerGraydon Hoare <[email protected]>2010-06-23 21:03:09 -0700
commitd6b7c96c3eb29b9244ece0c046d3f372ff432d04 (patch)
treeb425187e232966063ffc2f0d14c04a55d8f004ef /src/boot/fe/token.ml
parentInitial git commit. (diff)
downloadrust-d6b7c96c3eb29b9244ece0c046d3f372ff432d04.tar.xz
rust-d6b7c96c3eb29b9244ece0c046d3f372ff432d04.zip
Populate tree.
Diffstat (limited to 'src/boot/fe/token.ml')
-rw-r--r--src/boot/fe/token.ml308
1 files changed, 308 insertions, 0 deletions
diff --git a/src/boot/fe/token.ml b/src/boot/fe/token.ml
new file mode 100644
index 00000000..636e1ac2
--- /dev/null
+++ b/src/boot/fe/token.ml
@@ -0,0 +1,308 @@
+type token =
+
+ (* Expression operator symbols *)
+ PLUS
+ | MINUS
+ | STAR
+ | SLASH
+ | PERCENT
+ | EQ
+ | LT
+ | LE
+ | EQEQ
+ | NE
+ | GE
+ | GT
+ | NOT
+ | TILDE
+ | CARET
+ | AND
+ | ANDAND
+ | OR
+ | OROR
+ | LSL
+ | LSR
+ | ASR
+ | OPEQ of token
+ | AS
+ | WITH
+
+ (* Structural symbols *)
+ | AT
+ | DOT
+ | COMMA
+ | SEMI
+ | COLON
+ | RARROW
+ | SEND
+ | LARROW
+ | LPAREN
+ | RPAREN
+ | LBRACKET
+ | RBRACKET
+ | LBRACE
+ | RBRACE
+
+ (* Module and crate keywords *)
+ | MOD
+ | USE
+ | AUTH
+ | META
+
+ (* Metaprogramming keywords *)
+ | SYNTAX
+ | POUND
+
+ (* Statement keywords *)
+ | IF
+ | ELSE
+ | DO
+ | WHILE
+ | ALT
+ | CASE
+
+ | FAIL
+ | DROP
+
+ | IN
+ | FOR
+ | EACH
+ | PUT
+ | RET
+ | BE
+
+ (* Type and type-state keywords *)
+ | TYPE
+ | CHECK
+ | CLAIM
+ | PROVE
+
+ (* Effect keywords *)
+ | IO
+ | STATE
+ | UNSAFE
+
+ (* Type qualifiers *)
+ | NATIVE
+ | AUTO
+ | MUTABLE
+
+ (* Name management *)
+ | IMPORT
+ | EXPORT
+
+ (* Value / stmt declarators *)
+ | LET
+
+ (* Magic runtime services *)
+ | LOG
+ | SPAWN
+ | BIND
+ | THREAD
+ | YIELD
+ | JOIN
+
+ (* Literals *)
+ | LIT_INT of (int64 * string)
+ | LIT_FLO of string
+ | LIT_STR of string
+ | LIT_CHAR of int
+ | LIT_BOOL of bool
+
+ (* Name components *)
+ | IDENT of string
+ | IDX of int
+ | UNDERSCORE
+
+ (* Reserved type names *)
+ | BOOL
+ | INT
+ | UINT
+ | CHAR
+ | STR
+ | MACH of Common.ty_mach
+
+ (* Algebraic type constructors *)
+ | REC
+ | TUP
+ | TAG
+ | VEC
+ | ANY
+
+ (* Callable type constructors *)
+ | FN
+ | ITER
+
+ (* Object type *)
+ | OBJ
+
+ (* Comm and task types *)
+ | CHAN
+ | PORT
+ | TASK
+
+ | EOF
+
+ | BRACEQUOTE of string
+
+;;
+
+let rec string_of_tok t =
+ match t with
+ (* Operator symbols (mostly) *)
+ PLUS -> "+"
+ | MINUS -> "-"
+ | STAR -> "*"
+ | SLASH -> "/"
+ | PERCENT -> "%"
+ | EQ -> "="
+ | LT -> "<"
+ | LE -> "<="
+ | EQEQ -> "=="
+ | NE -> "!="
+ | GE -> ">="
+ | GT -> ">"
+ | TILDE -> "~"
+ | CARET -> "^"
+ | NOT -> "!"
+ | AND -> "&"
+ | ANDAND -> "&&"
+ | OR -> "|"
+ | OROR -> "||"
+ | LSL -> "<<"
+ | LSR -> ">>"
+ | ASR -> ">>>"
+ | OPEQ op -> string_of_tok op ^ "="
+ | AS -> "as"
+ | WITH -> "with"
+
+ (* Structural symbols *)
+ | AT -> "@"
+ | DOT -> "."
+ | COMMA -> ","
+ | SEMI -> ";"
+ | COLON -> ":"
+ | RARROW -> "->"
+ | SEND -> "<|"
+ | LARROW -> "<-"
+ | LPAREN -> "("
+ | RPAREN -> ")"
+ | LBRACKET -> "["
+ | RBRACKET -> "]"
+ | LBRACE -> "{"
+ | RBRACE -> "}"
+
+ (* Module and crate keywords *)
+ | MOD -> "mod"
+ | USE -> "use"
+ | AUTH -> "auth"
+
+ (* Metaprogramming keywords *)
+ | SYNTAX -> "syntax"
+ | META -> "meta"
+ | POUND -> "#"
+
+ (* Control-flow keywords *)
+ | IF -> "if"
+ | ELSE -> "else"
+ | DO -> "do"
+ | WHILE -> "while"
+ | ALT -> "alt"
+ | CASE -> "case"
+
+ | FAIL -> "fail"
+ | DROP -> "drop"
+
+ | IN -> "in"
+ | FOR -> "for"
+ | EACH -> "each"
+ | PUT -> "put"
+ | RET -> "ret"
+ | BE -> "be"
+
+ (* Type and type-state keywords *)
+ | TYPE -> "type"
+ | CHECK -> "check"
+ | CLAIM -> "claim"
+ | PROVE -> "prove"
+
+ (* Effect keywords *)
+ | IO -> "io"
+ | STATE -> "state"
+ | UNSAFE -> "unsafe"
+
+ (* Type qualifiers *)
+ | NATIVE -> "native"
+ | AUTO -> "auto"
+ | MUTABLE -> "mutable"
+
+ (* Name management *)
+ | IMPORT -> "import"
+ | EXPORT -> "export"
+
+ (* Value / stmt declarators. *)
+ | LET -> "let"
+
+ (* Magic runtime services *)
+ | LOG -> "log"
+ | SPAWN -> "spawn"
+ | BIND -> "bind"
+ | THREAD -> "thread"
+ | YIELD -> "yield"
+ | JOIN -> "join"
+
+ (* Literals *)
+ | LIT_INT (_,s) -> s
+ | LIT_FLO n -> n
+ | LIT_STR s -> ("\"" ^ (String.escaped s) ^ "\"")
+ | LIT_CHAR c -> ("'" ^ (Common.escaped_char c) ^ "'")
+ | LIT_BOOL b -> if b then "true" else "false"
+
+ (* Name components *)
+ | IDENT s -> s
+ | IDX i -> ("_" ^ (string_of_int i))
+ | UNDERSCORE -> "_"
+
+ (* Reserved type names *)
+ | BOOL -> "bool"
+ | INT -> "int"
+ | UINT -> "uint"
+ | CHAR -> "char"
+ | STR -> "str"
+ | MACH m -> Common.string_of_ty_mach m
+
+ (* Algebraic type constructors *)
+ | REC -> "rec"
+ | TUP -> "tup"
+ | TAG -> "tag"
+ | VEC -> "vec"
+ | ANY -> "any"
+
+ (* Callable type constructors *)
+ | FN -> "fn"
+ | ITER -> "fn"
+
+ (* Object type *)
+ | OBJ -> "obj"
+
+ (* Ports and channels *)
+ | CHAN -> "chan"
+ | PORT -> "port"
+
+ (* Taskess types *)
+ | TASK -> "task"
+
+ | BRACEQUOTE _ -> "{...bracequote...}"
+
+ | EOF -> "<EOF>"
+;;
+
+
+(*
+ * Local Variables:
+ * fill-column: 78;
+ * indent-tabs-mode: nil
+ * buffer-file-coding-system: utf-8-unix
+ * compile-command: "make -k -C ../.. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
+ * End:
+ *)