-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInterfaces.cs
86 lines (63 loc) · 2.08 KB
/
Interfaces.cs
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
/*
File: Interfaces.cs
Purpose: defines the interfaces that make up the compiler toolkit.
Version: 2.1
Date: 22nd May 2010.
Author: Allan C. Milne.
Namespace: AllanMilne.Ardkit
Exposes: IToken, ICompilerError, IScanner, IParser, ISymbol, ISymbolTable, ISemantics.
Description:
This file defines all the interfaces for the components that make up the Ardkit compiler toolkit.
These components are those appropriate to the construction of a recursive-descent compiler.
*/
using System;
using System.IO;
using System.Collections.Generic;
namespace AllanMilne.PALCompiler
{
//=== dummy class just to provide version and copyright information.
public class Interfaces {
private static ComponentInfo info = new ComponentInfo (
"Interfaces", "2.1", "May 2010", "Allan C. Milne", "Interface designs for toolkit components");
public static ComponentInfo Info
{ get { return info; } }
//=== The interfaces.
} // end Interfaces class.
public interface IToken {
String TokenType { get; }
String TokenValue { get; }
int Line { get; }
int Column { get; }
bool Is (String s);
String ToString ();
} // end IToken interface.
public interface ICompilerError {
IToken ErrorToken { get; }
String ToString();
} // end ICompilerError interface.
public interface IScanner {
IToken CurrentToken { get; }
bool EndOfFile { get; }
void Init (TextReader src, List<ICompilerError> errs);
IToken NextToken () ;
} // end IScanner interface.
public interface IParser {
List<ICompilerError> Errors { get; }
bool Parse (TextReader src);
bool IsRecovering { get; }
} // end IParser interface.
public interface ISymbol {
String Name { get; }
int Type { get; }
IToken Source { get; }
} // end ISymbol interface.
public interface ISymbolTable : IEnumerable<ISymbol> {
bool IsDefined (String name);
bool Add (ISymbol symbol);
ISymbol Get (String name);
} // end ISymbolTable interface.
public interface ISemantics {
int CurrentType { get; set; }
void ResetCurrentType ();
} // end ISemantics interface.
} // end namespace.