Ejemplo n.º 1
0
        public PreprocessorKeywords(NameTable symbolTable) {
            keywords = new Hashtable();

            for (PreprocessorTokenType token = 0; token < PreprocessorTokenType.Identifier; token += 1) {
                keywords.Add(symbolTable.Add(PreprocessorToken.TypeString(token)), token);
            }
        }
Ejemplo n.º 2
0
 public FileParser(NameTable nameTable, string path)
 {
     _nameTable = nameTable;
     _path = path;
     _parser = new Parser(nameTable, path);
     _parser.OnError += new ErrorEventHandler(OnParserError);
 }
Ejemplo n.º 3
0
        public Lexer(NameTable nameTable, string path) {
            _nameTable = nameTable;
            _path = path;
            _keywords = new Keywords(nameTable);
            _value = new StringBuilder(IdentifierToken.MaxIdentifierLength + 1);

            _lastLine = -1;
        }
Ejemplo n.º 4
0
        public FileLexer(NameTable nameTable, string path) {
            _lexer = new Lexer(nameTable, path);
            _lexer.OnError += new ErrorEventHandler(ReportError);
            _parser = new PreprocessorLineParser(nameTable);
            _parser.OnError += new ErrorEventHandler(ReportError);

            _path = path;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Initializes Keywords object. Adds all keywords to _nameTable.
        /// </summary>
        public Keywords(NameTable nameTable) {
            _keywords = new Hashtable((int)TokenType.Identifier);
            _nameTable = nameTable;

            for (TokenType token = 0; token < TokenType.Identifier; token += 1) {
                _keywords.Add(_nameTable.Add(Token.GetString(token)), token);
            }
        }
Ejemplo n.º 6
0
        public CompilationUnitNode BuildCodeModel(IStreamSource source)
        {
            _hasErrors = false;

            string filePath = source.FullName;
            #if DEBUG
            if (_options.InternalTestMode) {
                // This ensures in file paths are just file names in test output.
                filePath = Path.GetFileName(filePath);
            }
            #endif // DEBUG
            char[] buffer = GetBuffer(source);
            if (buffer == null) {
                _errorHandler.ReportError("Unable to read from file " + filePath, filePath);
                return null;
            }

            IDictionary definesTable = new Hashtable();
            if ((_options.Defines != null) && (_options.Defines.Count != 0)) {
                foreach (string s in _options.Defines) {
                    definesTable[s] = null;
                }
            }

            NameTable nameTable = new NameTable();
            LineMap lineMap = new LineMap(filePath);

            FileLexer lexer = new FileLexer(nameTable, filePath);
            lexer.OnError += new FileErrorEventHandler(OnError);
            Token[] tokens = lexer.Lex(buffer, definesTable, lineMap, /* includeComments */ false);

            if (_hasErrors == false) {
                FileParser parser = new FileParser(nameTable, filePath);
                parser.OnError += new FileErrorEventHandler(OnError);

                CompilationUnitNode compilationUnit = parser.Parse(tokens, lineMap);
                foreach (ParseNode node in compilationUnit.Members) {
                    NamespaceNode namespaceNode = node as NamespaceNode;
                    if (namespaceNode != null) {
                        namespaceNode.IncludeCompilationUnitUsingClauses();
                    }
                }

                if (_hasErrors == false) {
                    return compilationUnit;
                }
            }

            return null;
        }
Ejemplo n.º 7
0
        public Parser(NameTable symbolTable, string path) {
            this.symbolTable = symbolTable;
            _path = path;

            assemblyName = symbolTable.Add("assembly");
            moduleName = symbolTable.Add("module");
            unknownName = symbolTable.Add("__unknown");
            getName = symbolTable.Add("get");
            setName = symbolTable.Add("set");
            addName = symbolTable.Add("add");
            removeName = symbolTable.Add("remove");
            partialName = symbolTable.Add("partial");
            yieldName = symbolTable.Add("yield");
            whereName = symbolTable.Add("where");
            aliasName = symbolTable.Add("alias");
        }
 public PreprocessorLineParser(NameTable symbolTable)
 {
     lexer = new PreprocessorLexer(symbolTable);
     lexer.OnError += new ErrorEventHandler(this.ReportError);
 }
Ejemplo n.º 9
0
 public PreprocessorLexer(NameTable symbolTable)
 {
     _value = new StringBuilder();
     _nameTable = symbolTable;
     _keywords = new PreprocessorKeywords(symbolTable);
 }