private bool PeekType(MessageTokenType type) { if (IsEmpty()) { return(false); } return(tokens[0].type.Equals(type)); }
private string MatchByType(MessageTokenType type) { MessageToken token = tokens[0]; if (token.type.Equals(type)) { tokens.RemoveAt(0); // Update line num if (!IsEmpty()) { lineNum = tokens[0].lineNum; } return(token.content); } else { throw new MessageParserException( "Unexpected token '" + token.content + "' at " + inFilePath + ":" + token.lineNum + ". Expecting a token of type " + Enum.GetName(typeof(MessageTokenType), token.type)); } }
public MessageToken(MessageTokenType type, string content, uint lineNum) { this.type = type; this.content = content; this.lineNum = lineNum; }
/// <summary> /// Returns the next constant declaration /// Will decide declaration type /// Assumes that '=' has been peeked /// </summary> /// <returns></returns> private MessageToken NextConstantDeclaration(MessageTokenType tokenType = MessageTokenType.ConstantDeclaration) { string val = ReadUntilNewLineAndTrim(); return(new MessageToken(tokenType, val, lineNum)); }