public string UpdateTriggers(string code) { throw new NotImplementedException(); using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(code))) using (var reader = new SStreamReader(stream)) using (var lexer = new Lexer(engine, reader)) foreach (var token in lexer.Read()) { if (token.Type == TokenType.TRIGGER) { } } return(null); }
public Token Create(AbstractLexer lexer, SStreamReader reader) { long startPos = reader.Position; int length = 0; int currentChar = lexer.Next(); length++; var sourcePos = lexer.CurrentSourcePosition; lexer.CheckMatch(StartCharacter); currentChar = lexer.Next(); length++; while (true) { if (!((currentChar >= 'a' && currentChar <= 'z') || (currentChar >= 'A' && currentChar <= 'Z') || (currentChar >= '0' && currentChar <= '9') || currentChar == '_')) { length--; break; } currentChar = lexer.Next(); length++; } if (currentChar == -1) { throw new MonkeyspeakException("Unexpected end of file", sourcePos); } #region Variable Table Handling if (lexer.LookAhead(1) == '[') { while (((currentChar >= 'a' && currentChar <= 'z') || (currentChar >= 'A' && currentChar <= 'Z') || (currentChar >= '0' && currentChar <= '9'))) { if (currentChar == -1) { throw new MonkeyspeakException("Unexpected end of file", lexer.CurrentSourcePosition); } currentChar = lexer.Next(); length++; if (currentChar == ']') { break; } if (!((currentChar >= 'a' && currentChar <= 'z') || (currentChar >= 'A' && currentChar <= 'Z') || (currentChar >= '0' && currentChar <= '9'))) { throw new MonkeyspeakException($"Invalid character in variable list index delcaration '{currentChar}'", lexer.CurrentSourcePosition); } } } #endregion Variable Table Handling return(new Token(TokenType.VARIABLE, startPos, length, lexer.CurrentSourcePosition)); }