public static LexStateFunc LexParameters(LexerBase lexer) { lexer.AcceptAnyChar(" ,"); lexer.Ignore(); while (true) { if (lexer.HasPrefix(")")) { if (lexer.Width > 0) { lexer.Emit(TokenType.Parameter); } lexer.AcceptAnyChar(") "); lexer.AcceptWord("}}"); lexer.Ignore(); return(LexText); } if (lexer.HasPrefix("}}")) { if (lexer.Width > 0) { lexer.Emit(TokenType.Parameter); } lexer.AcceptWord("}}"); lexer.Ignore(); return(LexText); } var c = lexer.Next(); switch (c) { case '"': return(LexQuotes); case ' ': case ',': lexer.Backup(); if (lexer.Width > 0) { lexer.Emit(TokenType.Parameter); } lexer.AcceptAnyChar(" ,"); lexer.Ignore(); break; case LexerBase.EOF: throw new TemplateException(string.Format("Unfinished parameter at line {0}", lexer.Line)); } } }
public static LexStateFunc LexParameter(LexerBase lexer) { lexer.AcceptAnyChar(" "); lexer.Ignore(); while (true) { if (lexer.HasPrefix("}}")) { if (lexer.Width > 0) { lexer.Emit(TokenType.Parameter); } lexer.AcceptWord("}}"); lexer.Ignore(); return(LexText); } var c = lexer.Next(); if (c == LexerBase.EOF) { throw new TemplateException(string.Format("Unfinished parameter line {0}", lexer.Line)); } } }
public static LexStateFunc LexParameter(LexerBase lexer) { lexer.AcceptAnyChar(" "); lexer.Ignore(); while (true) { if (lexer.HasPrefix("}}")) { if(lexer.Width > 0) { lexer.Emit(TokenType.Parameter); } lexer.AcceptWord("}}"); lexer.Ignore(); return LexText; } var c = lexer.Next(); if(c == LexerBase.EOF) { throw new TemplateException(string.Format("Unfinished parameter line {0}", lexer.Line)); } } }
public static LexStateFunc LexText(LexerBase l) { while (true) { if (l.HasPrefix("{{")) { if (l.Width > 0) { l.Emit(TokenType.Text); } return(LexKeyword); } if (l.Next() == LexerBase.EOF) { if (l.Width > 0) { l.Emit(TokenType.Text); } return(null); } } }
public static LexStateFunc LexText(LexerBase l) { while (true) { if(l.HasPrefix("{{")) { if(l.Width > 0) { l.Emit(TokenType.Text); } return LexKeyword; } if(l.Next() == LexerBase.EOF) { if(l.Width > 0) { l.Emit(TokenType.Text); } return null; } } }
public static LexStateFunc LexParameters(LexerBase lexer) { lexer.AcceptAnyChar(" ,"); lexer.Ignore(); while (true) { if (lexer.HasPrefix(")")) { if(lexer.Width > 0) { lexer.Emit(TokenType.Parameter); } lexer.AcceptAnyChar(") "); lexer.AcceptWord("}}"); lexer.Ignore(); return LexText; } if (lexer.HasPrefix("}}")) { if(lexer.Width > 0) { lexer.Emit(TokenType.Parameter); } lexer.AcceptWord("}}"); lexer.Ignore(); return LexText; } var c = lexer.Next(); switch(c) { case '"': return LexQuotes; case ' ': case ',': lexer.Backup(); if(lexer.Width > 0) { lexer.Emit(TokenType.Parameter); } lexer.AcceptAnyChar(" ,"); lexer.Ignore(); break; case LexerBase.EOF: throw new TemplateException(string.Format("Unfinished parameter at line {0}", lexer.Line)); } } }