Exemple #1
0
 private bool PeekType(MessageTokenType type)
 {
     if (IsEmpty())
     {
         return(false);
     }
     return(tokens[0].type.Equals(type));
 }
Exemple #2
0
        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));
            }
        }
Exemple #3
0
 public MessageToken(MessageTokenType type, string content, uint lineNum)
 {
     this.type    = type;
     this.content = content;
     this.lineNum = lineNum;
 }
Exemple #4
0
        /// <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));
        }