001package org.clafer.frontend; 002 003/** 004 * The kinds of tokens. 005 */ 006public enum TokenKind { 007 /** 008 * A name or a keyword, e.g., {@code c0_cost}, {@code abstract}, 009 * {@code int}: keywords are recognized by the parser where they are 010 * expected, so a clafer may be named like one. 011 */ 012 WORD, 013 /** 014 * A natural number, e.g., {@code 16}. A sign is a separate {@code -}. 015 */ 016 INT, 017 /** 018 * A decimal number with digits on both sides of the point, e.g., 019 * {@code 19.99}. 020 */ 021 DECIMAL, 022 /** 023 * A double, a decimal number with an exponent, e.g., {@code 1.2e2} or 024 * {@code 1.0e-2}, as the compiler prints a {@code double} literal. 025 */ 026 DOUBLE, 027 /** 028 * A string literal with its quotes and escapes as written, e.g., 029 * {@code "a\"b"}; see {@link Lexer#unescape}. 030 */ 031 STRING, 032 /** 033 * An operator or punctuation, e.g., {@code ->>}, {@code ..} or a brace. 034 */ 035 SYMBOL, 036 /** 037 * A line or block comment. Comments are set aside, not passed to the 038 * parser. 039 */ 040 COMMENT, 041 /** 042 * Text that is not a token, e.g., an unexpected character or an 043 * unterminated string. The lexer reports a diagnostic for it and goes on. 044 */ 045 ERROR, 046 /** 047 * A reserved word of the full language, e.g., {@code abstract}, 048 * {@code some} or {@code X} ({@link ClaferLexer}): it cannot name a 049 * clafer. The explicit languages have none ({@link #WORD}). 050 */ 051 KEYWORD, 052 /** 053 * An escape to a backend, {@code [alloy| ... |]} or 054 * {@code [choco| ... |]}, set aside like a comment ({@link ClaferLexer}). 055 */ 056 ESCAPE, 057 /** 058 * The start of a block of indented lines, an empty span: the opening 059 * brace that {@link Layout} inserts. 060 */ 061 INDENT, 062 /** 063 * The end of a block of indented lines, an empty span: the closing 064 * brace that {@link Layout} inserts. 065 */ 066 DEDENT, 067 /** 068 * The separator that {@link Layout} inserts between two lines at the 069 * same indentation, an empty span, so that, e.g., a group cardinality 070 * at the start of a line is not the cardinality of the clafer on the line 071 * before. 072 */ 073 SEPARATOR, 074 /** 075 * The end of the input, an empty span after the last character. 076 */ 077 EOF 078}