Esempio n. 1
0
        private bool parseEntry(string line)
        {
            HexValuePair tokens = getTokens(line, true);

            if (tokens == null)
            {
                return(false);
            }

            return(addToMaps(tokens.HexNumber, tokens.Value));
        }
Esempio n. 2
0
        private bool parseEndLine(string line)
        {
            line = line.Substring(1);
            string hexstr, textstr;

            HexValuePair tokens = getTokens(line, false);

            if (tokens == null)
            {
                return(false);
            }

            hexstr  = tokens.HexNumber;
            textstr = string.IsNullOrEmpty(tokens.Value) ? DefEndLine : tokens.Value;

            return(addToMaps(hexstr, textstr));
        }
Esempio n. 3
0
        private HexValuePair getTokens(string line, bool isNormalEntry)
        {
            HexValuePair tokens = new HexValuePair();
            int          pos;

            //if "XX="
            if ((pos = line.IndexOf('=')) == line.Length - 1)
            {
                RecordError("Entry is incomplete");
                return(null);
            }
            //if "XX"
            if (pos == -1)
            {
                if (isNormalEntry)
                {
                    RecordError("No string token present");
                    return(null);
                }
                else
                {
                    pos = line.Length;
                }
            }
            else
            {
                tokens.Value = line.Substring(pos + 1);
            }
            string hexString = line.Substring(0, pos).ToUpper();

            pos = findFirstNotOf(hexString, HexAlphaNum);
            if (pos >= 0)
            {
                hexString = hexString.Substring(0, pos);
            }

            if ((hexString.Length & 1) != 0)
            {
                RecordError("Incomplete hex token");
                return(null);
            }
            tokens.HexNumber = hexString;
            return(tokens);
        }
Esempio n. 4
0
		private HexValuePair getTokens (string line, bool isNormalEntry)
		{
            HexValuePair tokens = new HexValuePair();
			int pos;

			//if "XX="
			if ((pos = line.IndexOf ('=')) == line.Length - 1)
            {
				RecordError ("Entry is incomplete");
				return null;
			}
			//if "XX"
			if (pos == -1) {
                if (isNormalEntry)
                {
                    RecordError("No string token present");
                    return null;
                }
                else
                {
                    pos = line.Length;
                }
			} 
            else
            {
                tokens.Value = line.Substring (pos + 1);
			}
            string hexString = line.Substring (0, pos).ToUpper();

            pos = findFirstNotOf (hexString, HexAlphaNum);
            if (pos >= 0)
            {
                hexString = hexString.Substring(0, pos);
            }

            if ((hexString.Length & 1) != 0)
            {
				RecordError("Incomplete hex token");
				return null;
			}
            tokens.HexNumber = hexString;
			return tokens;
		}
Esempio n. 5
0
        private bool parseLink(string line)
        {
            LinkedEntry l = new LinkedEntry();
            int         pos;

            line = line.Substring(1);
            string       hexstr, textstr;
            HexValuePair tokens = getTokens(line, true);

            if (tokens == null)
            {
                return(false);
            }

            hexstr = tokens.HexNumber;
            pos    = tokens.Value.LastIndexOf(',');

            if (pos == -1)
            {
                RecordError("No comma, linked entry format is $XX=<text>,num");
                return(false);
            }

            textstr      = tokens.Value.Substring(0, pos);
            tokens.Value = tokens.Value.Substring(pos + 1);
            pos          = findFirstNotOf(tokens.Value, "0123456789");

            if (pos >= 0)
            {
                RecordError("Nonnumeric characters in num field, linked entry format is $XX=<text>,num");
                return(false);
            }

            l.Text   = textstr;
            l.Number = int.Parse(tokens.Value);

            if (ReaderType == TableReaderType.ReadTypeDump)
            {
                l.Text = changeControlCodes(l.Text, true);
                if (LinkedEntries.ContainsKey(hexstr))
                {
                    RecordError("Linked entry with this hex token already exists.");
                    return(false);
                }
                else
                {
                    LinkedEntries.Add(hexstr, l);
                }
            }
            else if (ReaderType == TableReaderType.ReadTypeInsert)
            {
                string modString = textstr;
                modString = changeControlCodes(modString, false);
                if (LookupValue.ContainsKey(modString))
                {
                    RecordError("Unable to add duplicate text token, causes dumper conflicts");
                    return(false);
                }
                else
                {
                    LookupValue.Add(modString, hexstr);
                    updateLongest(hexstr, modString);
                }
            }
            return(true);
        }