/* * LEX.H * * (c)Copyright 1993-2014, Matthew Dillon, All Rights Reserved. See the * COPYRIGHT file at the base of the distribution. */ struct Lex; typedef RUNE_HEAD(lexlist, Lex) lexlist_t; typedef struct Lex { RUNE_ENTRY(Lex) l_Node; /* saved Lex structures for error reporting */ char *l_Path; char *l_Base; int l_Fd; int l_Bytes; int l_CacheLine; /* cached line number */ int l_CacheOff; /* start of cache line */ int l_RefCount; /* LexRef count */ int l_OpenCount; /* open/close count */ int l_DebugFileNo; /* assigned during emit phase if debugging */ } Lex; typedef struct { const char *t_Ptr; const char *t_End; int t_Len; int t_Type; int t_Line; int t_LinesInToken; Lex *t_Lex; } token_t; /* * LexRef - save lexical position for error generation after lexical * processing has completed. * * WARNING! Embedded in Declaration, fields must match classes/sys/runtime.d */ typedef struct { Lex *lr_Lex; /* pointer to (closed) Lex structure */ int lr_Offset; /* offset in file */ int lr_Len; /* length of token in file */ int lr_Line; /* line number */ int lr_Reserved03; } LexRef; #define T_WS 0x01 /* white space CR LF FF SP TAB */ #define T_AL 0x02 /* alpha */ #define T_NU 0x04 /* numeric */ #define T_QU 0x08 /* single/backtick/double quote */ #define T_SP 0x10 /* single-character special */ #define T_CM 0x20 /* comment '#' */ #define T_MP 0x40 /* multi-character special or operator */ #define T_XP 0x80 /* possible comment (/) */ #define T_ALNU (T_AL | T_NU) #define TOK_DOLLAR '$' #define TOK_OPAREN '(' #define TOK_CPAREN ')' #define TOK_COMMA ',' #define TOK_DOT '.' #define TOK_COLON ':' #define TOK_SEMI ';' #define TOK_AT '@' #define TOK_OBRACKET '[' #define TOK_CBRACKET ']' #define TOK_OBRACE '{' #define TOK_CBRACE '}' #define TOK_NOT '!' /* synthesized for exp, not actual lex token */ #define TOK_DSTRING '"' #define TOK_SSTRING '\'' #define TOK_BSTRING '`' #define TOK_ANGLESTR '<' /* (specially flagged, nominally TOK_OPER) */ #define TOK_ASS 0x0100 #define TOK_ANDAND 0x0101 #define TOK_OROR 0x0102 #define TOK_OPER 0x0103 #define TOK_INTEGER 0x0104 #define TOK_FLOAT 0x0105 #define TOK_ID (0x0106 | TOKF_ID) #define TOK_EOF (0x0107 | TOKF_EOF) #define TOK_COMPOUND 0x0108 /* synthesized for exp (exp, exp, ...) */ #define TOK_UNUSED0109 0x0109 #define TOK_CALL 0x010A /* synthesized for exp (exp, exp, ...) */ #define TOK_STRIND 0x010B /* -> */ #define TOK_UNUSED010C 0x010C #define TOK_PTRIND 0x010D /* (synthesized) pointer indirect */ #define TOK_STRUCT_ID 0x010E /* rhs side of '.' or '->' expression */ #define TOK_SEMGRP_ID 0x010F #define TOK_UNUSED110 0x0110 #define TOK_DECL 0x0111 /* collapsed into declaration */ #define TOK_VOIDEXP 0x0112 /* like an integer, but represents void */ #define TOK_ADDR 0x0113 /* (synthesized) address of */ #define TOK_TYPE 0x0114 /* a type (in ex_Type) */ #define TOK_THREAD_SCHEDULE 0x0115 /* thread schedule */ #define TOK_CLASSID (0x0116 | TOKF_ID) #define TOK_UNUSED117 0x0117 #define TOK_UNUSED118 0x0118 #define TOK_SIZEOF 0x0119 #define TOK_ARYSIZE 0x011A #define TOK_TYPEOF 0x011B #define TOK_CONSTEXP 0x011C /* resolved to cacheable constant */ #define TOK_INLINE_CALL 0x011D /* call -> inlined call */ #define TOK_BRACKETED 0x011E /* synthesized [ exp, exp, exp, ... ] */ #define TOKF_ID 0x01000000 #define TOKF_ERROR 0x02000000 #define TOKF_EOF 0x04000000 #define TOKF_SCOPE_QUAL 0x08000000 #define TOKF_STOR_QUAL 0x10000000 #define TOKF_KEYWORD 0x20000000 #define TOKF_ERREOF (TOKF_ERROR|TOKF_EOF) #define TOKF_ERR_MASK 0x0000FFFF #define TOKF_SCOPE_MASK 0x00000FFF #define TOKF_STOR_MASK 0x00000FFF #define TOK_ERR_NOERROR (TOKF_ERROR|0x00) /* special */ #define TOK_ERR_UNKNOWN (TOKF_ERROR|0x01) /* special */ #define TOK_ERR_UNTERMINATED_COMMENT (TOKF_ERROR|0x02) #define TOK_ERR_UNEXPECTED_CHAR (TOKF_ERROR|0x03) #define TOK_ERR_UNEXPECTED_TOKEN (TOKF_ERROR|0x04) #define TOK_ERR_BAD_NUMERIC_CONST (TOKF_ERROR|0x05) #define TOK_ERR_EMBEDDED_CRLF (TOKF_ERROR|0x06) #define TOK_ERR_ILLEGAL_ESCAPE (TOKF_ERROR|0x07) #define TOK_ERR_UNTERMINATED_STR (TOKF_ERROR|0x08) #define TOK_ERR_MULTIPLE_SCOPES (TOKF_ERROR|0x09) #define TOK_ERR_MISSING_OBRACE (TOKF_ERROR|0x0A) #define TOK_ERR_MISSING_CBRACE (TOKF_ERROR|0x0B) #define TOK_ERR_CASE_WITHOUT_SWITCH (TOKF_ERROR|0x0C) #define TOK_ERR_DEFAULT_WITHOUT_SWITCH (TOKF_ERROR|0x0D) #define TOK_ERR_ELSE_WITHOUT_IF (TOKF_ERROR|0x0E) #define TOK_ERR_DO_WITHOUT_WHILE (TOKF_ERROR|0x0F) #define TOK_ERR_BAD_BREAK_KEYWORD (TOKF_ERROR|0x10) #define TOK_ERR_MULTIPLE_DEFAULTS (TOKF_ERROR|0x11) #define TOK_ERR_SYNTAX (TOKF_ERROR|0x12) #define TOK_ERR_EXPECTED_STRING (TOKF_ERROR|0x13) #define TOK_ERR_EXPECTED_ID (TOKF_ERROR|0x14) #define TOK_ERR_IMPORT_NOT_FOUND (TOKF_ERROR|0x15) #define TOK_ERR_DECL_NOT_PROCEDURE (TOKF_ERROR|0x16) #define TOK_ERR_EXPECTED_COMMA (TOKF_ERROR|0x17) #define TOK_ERR_EXP_SYNTAX (TOKF_ERROR|0x18) #define TOK_ERR_CLASS_ILLEGAL_TYPE (TOKF_ERROR|0x19) #define TOK_ERR_EXPECTED_CPAREN (TOKF_ERROR|0x1A) #define TOK_ERR_EXPECTED_TYPE (TOKF_ERROR|0x1B) #define TOK_ERR_MUTILPLE_IDS (TOKF_ERROR|0x1C) #define TOK_ERR_EXPECTED_DECLARATOR (TOKF_ERROR|0x1D) #define TOK_ERR_ILLEGAL_ID_CONTEXT (TOKF_ERROR|0x1E) #define TOK_ERR_IMPORT_FAILED (TOKF_ERROR|0x1F) #define TOK_ERR_EXPECTED_QUOTED_OPERATOR (TOKF_ERROR|0x20) #define TOK_ERR_EXPECTED_SIMPLE_INTEGER (TOKF_ERROR|0x21) #define TOK_ERR_BREAK_CONT_NOT_FOUND (TOKF_ERROR|0x22) #define TOK_ERR_DUPLICATE_ATTACH (TOKF_ERROR|0x23) #define TOK_ERR_UNRECOGNIZED_ATTACH (TOKF_ERROR|0x24) #define TOK_ERR_ILLEGAL_TYPEDEF (TOKF_ERROR|0x25) #define TOK_ERR_OPERATOR_NOT_PROCEDURE (TOKF_ERROR|0x26) #define TOK_ERR_EMPTY_PATH (TOKF_ERROR|0x27) #define TOK_ERR_NOT_SUPPORTED (TOKF_ERROR|0x28) #define TOK_ERR_BADLY_FORMED_SIZEOF (TOKF_ERROR|0x29) #define TOK_ERR_EXP_REMOVED (TOKF_ERROR|0x2A) #define TOK_ERR_EXP_SYNTAX_MAYTYPE (TOKF_ERROR|0x2B) #define TOK_ERR_PARSE_ID_NOT_CLASS (TOKF_ERROR|0x2C) #define TOK_ERR_PARSE_CLASS_NOT_FOUND (TOKF_ERROR|0x2D) #define TOK_ERR_NO_DOTTED_ID_HERE (TOKF_ERROR|0x2E) #define TOK_ERR_NESTED_CLASS (TOKF_ERROR|0x2F) #define TOK_ERR_DUPLICATE_ID (TOKF_ERROR|0x30) #define TOK_ERR_METHOD_REQUIRES_OBJ (TOKF_ERROR|0x31) #define TOK_ERR_SCOPE_NOT_VISIBLE (TOKF_ERROR|0x32) #define TOK_ERR_ID_NOT_FOUND (TOKF_ERROR|0x33) #define TOK_ERR_EXPECTED_CLASSID (TOKF_ERROR|0x34) #define TOK_ERR_INCOMPATIBLE_SUBCLASS (TOKF_ERROR|0x35) #define TOK_ERR_INCOMPATIBLE_BINDING (TOKF_ERROR|0x36) #define TOK_ERR_EXPECTED_INTEGRAL_TYPE (TOKF_ERROR|0x37) #define TOK_ERR_EXPECTED_INTEGRER_CONST (TOKF_ERROR|0x38) #define TOK_ERR_ILLEGAL_UNLOCKED (TOKF_ERROR|0x39) #define TOK_ERR_ILLEGAL_ADDRLOCKED (TOKF_ERROR|0x3A) #define TOK_ERR_ILLEGAL_SUFFIX (TOKF_ERROR|0x3B) #define TOK_ERR_AUTOCAST_VALUE (TOKF_ERROR|0x3C) #define TOK_ERR_RESULT_SEQUENCING (TOKF_ERROR|0x3D) #define TOK_ERR_READONLY (TOKF_ERROR|0x3E) #define TOK_ERR_LIMITED_VOIDP_CAST (TOKF_ERROR|0x3F) #define TOK_ERR_SCOPE_MISMATCH (TOKF_ERROR|0x40) #define TOK_ERR_SCOPE_MISMATCH_THIS (TOKF_ERROR|0x41) #define TOK_ERR_ILLEGAL_LOCKING_REFINEMENT (TOKF_ERROR|0x42) #define TOK_ERR_ILLEGAL_LOCKED (TOKF_ERROR|0x43) #define LEX_ERR_STRINGS \ "", \ "Unknown Error", \ "Unterminated Comment", \ "Unexpected Lexical Character", \ "Unexpected Token", \ "Badly formed numerical constant", \ "Embedded CR or LFs in strings are illegal", \ "Illegal escape in string", \ /* 0x08 */ "Unterminated string", \ "Multiple scopes specified", \ "Expected open-brace", \ "Expected close-brace", \ "Case outside of switch", \ "Default outside of switch", \ "Else without if", \ "Do without while/until", \ /* 0x10 */ "Bad break/continue keyword", \ "Multiple default: clauses were specified", \ "Syntax error", \ "Expected string constant", \ "Expected identifier", \ "Import not found", \ "Illegal statement block, declaration is not a procedure",\ "Expected comma", \ /* 0x18 */ "Syntax error in expression", \ "Illegal type for class declaration", \ "Expected close parenthesis", \ "Expected type", \ "Multiple identifiers were specified", \ "Expected declarator", \ "Wrong kind of identifier was found for this context", \ "Error parsing imported file", \ /* 0x20 */ "Expected quoted operator", \ "Expected simple integer", \ "Break/continue point not found", \ "Duplicate internal attach", \ "Unrecognize internal attach id", \ "Illegal typedef", \ "Operator/cast/method declaration is not a procedure!", \ "Empty string not allowed", \ /* 0x28 */ "Not yet supported", \ "Badly formed sizeof(), typeof(), or arysize() operator",\ "Expression removed from tree", \ "Syntax error in expression. If trying to make a " \ "declaration, do not forget the required scope or " \ "storage qualifier", \ "Can only enter declaration into a class", \ "Unable to find class to enter declaration into", \ "Dotted ids are not allowed here", \ "You cannot nest classes or subclasses. Perhaps " \ "you meant to use an interface here?", \ /* 0x30 */ "Duplicate identifier during parsing", \ "A non-global method call must be called through an " \ "object context", \ "The id was found but is outside its visibility scope", \ "Identifier could not be located", \ "Expected type/class identifier", \ "Subclass is not compatible with its superclass", \ "Subclass is incompatible for binding purposes", \ "Expected integral type", \ "Expected resolvable integer constant", \ "Rune only allows 'unlocked' or 'locked' scope if " \ "storage defaults to soft-locked", \ "Cannot take the address of content-locked storage, " \ "you must make it 'unlocked'", \ "Unrecognize suffix for constant", \ "Autocast of constant would change its value", \ "Illegal placement of result; or use of argument " \ "or return value after result;", \ "Storage is read-only and may not be modified", \ "Objects cast to void* may not contain lvalues, " \ "pointers, or references", \ "Locking scope mismatch", \ "Locking scope mismatch on method object ('this')", \ "Procedure refinement cannot change locking mode", \ "Locking scope illegal here", \ NULL /* terminate the macro, the NULL is not really used */