예제 #1
0
파일: LocalSymbol.cs 프로젝트: arlm/MixEmul
        public static IValue ParseValue(string text, int sectionCharIndex, ParsingStatus status)
        {
            if (!IsLocalSymbol(text))
            {
                return(null);
            }

            char       localSymbolChar = text[0];
            SymbolBase symbol          = status.Symbols[new string(localSymbolChar, 1)];

            if (symbol == null)
            {
                symbol = new LocalSymbol(localSymbolChar - '0');
                status.Symbols.Add(symbol);
            }

            if (!(symbol is LocalSymbol))
            {
                status.ReportParsingError(sectionCharIndex, 1, "non-local symbol named " + localSymbolChar + " already defined, unable to refer to it");
                return(symbol);
            }

            if (IsDefinitionChar(text[1]))
            {
                status.ReportParsingError(sectionCharIndex + 1, 1, "local symbol definition found where reference was expected");
                return(symbol);
            }

            return(new Reference((LocalSymbol)symbol, IsForwardReferenceChar(text[1]) ? Reference.Directions.Forwards : Reference.Directions.Backwards));
        }
예제 #2
0
파일: LocalSymbol.cs 프로젝트: arlm/MixEmul
        public static SymbolBase ParseDefinition(string text, int sectionCharIndex, ParsingStatus status)
        {
            if (!IsLocalSymbol(text))
            {
                return(null);
            }

            if (!IsDefinitionChar(text[1]))
            {
                status.ReportParsingError(sectionCharIndex + 1, 1, "local symbol reference found where definition was expected");
            }

            char       localSymbolChar = text[0];
            SymbolBase symbol          = status.Symbols[localSymbolChar.ToString()];

            if (symbol == null)
            {
                return(new LocalSymbol(localSymbolChar - '0'));
            }

            if (!(symbol is LocalSymbol))
            {
                status.ReportParsingError(sectionCharIndex, 1, "non-local symbol named " + localSymbolChar + " already defined");
            }

            return(symbol);
        }
예제 #3
0
파일: ValueSymbol.cs 프로젝트: arlm/MixEmul
        public static IValue ParseValue(string text, int sectionCharIndex, ParsingStatus status)
        {
            var symbolValue = LocalSymbol.ParseValue(text, sectionCharIndex, status);

            if (symbolValue != null)
            {
                return(symbolValue);
            }

            if (!IsValueSymbolName(text))
            {
                return(null);
            }

            SymbolBase symbol = status.Symbols[text];

            if (symbol == null)
            {
                symbol = new ValueSymbol(text);
                status.Symbols.Add(symbol);
            }

            return(symbol);
        }