aboutsummaryrefslogtreecommitdiff
path: root/backendC/CleanCompilerSources/scanner.h
blob: b550cc4ba51637f3ac789c518caa9ea1cda472cd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
     +---------------------------------------------------------------------+
     |    For each identifier stored in the symbol table a structure of    |
     |    type 'Ident' is reserved.								|
     +---------------------------------------------------------------------+
*/

extern char *ConvertNextTokenToString (void);

typedef
	enum
	{
		IdentToken, IntToken,  CharToken,
		StringToken, RealToken, AnnotToken, InstructionToken,
		EOFToken,
		errorsym, barsym, strictsym, opensym,
		closesym, opensquaresym, closesquaresym, colonsym,
 		typesym, semicolonsym, commasym, dotsym, openbracesym,
		closebracesym, arrowsym, abstypesym,
		arraysym, strictarraysym, unboxedarraysym,

		atsym,boolsym, codesym, charsym,defsym,
		falsesym, filesym, fromsym, ifsym, impsym,
/* RWS */
		allsym,
		importsym, intsym, macrosym, modulesym, procidsym, redidsym,
		realsym, rulesym, stringsym,
		systemsym, truesym, typedefsym, applysym,
		uniquesym, worldsym,
		NumberOfKeywords /* make sure that this constant is the last one */
		
	} KeywordKind;  

extern char 	**ReservedWords;

	enum
	{
		/* 0 .. 255 are reserved for single ascii characters */
		kTokenImport = 256,	kTokenFrom, kTokenDefinition, kTokenImplementation,
		kTokenSystem, kTokenModule,
		kTokenLet, kTokenIn, kTokenCase, kTokenOf,
		kTokenWith, kTokenWhere, kTokenEquals, kTokenEqualColon,
		kTokenColonDoubleEqual, kTokenDoubleBackSlash,
		kTokenDoubleRightArrow,
		kTokenLeftArrow, kTokenLeftArrowColon, kTokenRightArrow,
		kTokenInfix, kTokenInfixL, kTokenInfixR,
		kTokenDotDot, kTokenDoubleColon,
		
		kTokenProcessOpen, kTokenProcessClose,
		kTokenChar, kTokenMultiChar, kTokenString, kTokenInt, kTokenReal,
		kTokenLowerIdentifier, kTokenUpperIdentifier, kTokenUnderscoreIdentifier,
		kTokenCode, kTokenInstruction,
		kTokenFalse, kTokenTrue,
		kTokenIf, kTokenAll,
		kNoToken, kTokenEOF,
		kTokenHashExclamationMark,

		kTokenOverload, kTokenInstance, kTokenClass,
		kTokenExport,

#ifdef H
		kTokenData, kTokenType, kTokenAtSign, kTokenThen, kTokenElse, kTokenInterface,
#endif

		kTokenDefault, kTokenResync
	};

typedef	unsigned int		Token;

STRUCT (tokenValue, TokenValue)
{
	Token	token;	
	long	lineNumber;
	union {
		char			*literal;
		IdentStringP	identString;
	} value;
};

typedef	enum { kScanModeNormal,kScanModeTypes,kScanModeInstructions } ScanMode;

extern	IdentP	RetrieveFromSymbolTable (char *name);
extern	IdentP	PutStringInHashTable (char *string, TableKind tabkind);
extern	IdentP	PutIdentStringInTable (IdentStringP identString, TableKind tabkind);


extern	void	InitScanner (void);

extern	void	ScanInit (void);
extern	void	ScanSetMode (ScanMode scanMode);
enum {kOffsideOnHardBrace = True, kNoOffsideOnHardBrace = False};
extern	void	ScanSetOffside (Bool offsideOnHardBrace);
extern	Bool	ScanUnsetOffside (void);
extern	void	ScanSetLayoutOption (void);
extern	Bool	ScanOpenFile (char *fileName, FileKind fileKind);
#if WRITE_DCL_MODIFICATION_TIME
extern	Bool	ScanOpenFileWithModificationTime (char *fileName, FileKind fileKind, FileTime *file_time_p);
#endif
extern	void	ScanCloseFile (void);
extern	Bool	ScanTokenToString (Token token, char *string);

/*
	ScanCleanToken fills the global structure gCurrentToken.
*/
extern	void		ScanInitialise (void);

#ifdef CLEAN2
extern	void ScanInitIdentStringTable (void);
#endif

extern	void		ScanCleanToken (void);
extern	TokenValueS	gCurrentToken;
extern void ScanInlineFile (char *fname);

extern Bool	gApplyLayoutRule;