public DslParser(IDslSource dslSource, IConceptInfo[] conceptInfoPlugins, ILogProvider logProvider) { _dslSource = dslSource; _conceptInfoPlugins = conceptInfoPlugins; _performanceLogger = logProvider.GetLogger("Performance"); _logger = logProvider.GetLogger("DslParser"); }
public LoadDslModelCommand( IDslSource dslSource, IDataTypeProvider dataTypeProvider) { this.DslSource = dslSource; this.DataTypeProvider = dataTypeProvider; }
public static Token GetNextToken_ValueType(IDslSource dslSource, ref int position) { var dsl = dslSource.Script; Contract.Requires(dsl != null); Contract.Requires(position >= 0 && position <= dsl.Length); Contract.Ensures(position >= 0 && position <= dsl.Length); Contract.Ensures(position >= Contract.OldValue(position)); Contract.Ensures(Contract.Result<string>() != null); System.Diagnostics.Debug.Assert( position < dsl.Length && !Whitespaces.Contains(dsl[position]), "Unexpected call of GetNextToken_ValueType without skipping whitespaces."); if (IsSimpleStringElement(dsl[position])) return new Token { Value = ReadSimpleStringToken(dsl, ref position), Type = Token.TokenType.Text }; else if (IsQuotedStringStart(dsl[position])) return new Token { Value = ReadQuotedString(dsl, ref position), Type = Token.TokenType.Text }; else if (IsExternalTextStart(dsl[position])) return new Token { Value = ReadExternalText(dslSource, ref position), Type = Token.TokenType.Text }; else if (IsSingleLineCommentStart(dsl, position)) return new Token { Value = ReadSingleLineComment(dsl, ref position), Type = Token.TokenType.Comment }; else return new Token { Value = ReadSpecialCharacter(dsl, ref position), Type = Token.TokenType.Special }; }
public static List<Token> GetTokens(IDslSource dslSource) { List<Token> tokens = new List<Token>(); int scriptPosition = 0; while (true) { TokenizerInternals.SkipWhitespaces(dslSource.Script, ref scriptPosition); if (scriptPosition >= dslSource.Script.Length) break; int startPosition = scriptPosition; Token t = TokenizerInternals.GetNextToken_ValueType(dslSource, ref scriptPosition); if (t.Type != Token.TokenType.Comment) { t.DslSource = dslSource; t.PositionInDslSource = startPosition; tokens.Add(t); } } return tokens; }
private static string ReadExternalText(IDslSource dslSource, ref int end) { var dsl = dslSource.Script; Contract.Requires(dsl != null); Contract.Requires(end >= 0 && end < dsl.Length); Contract.Ensures(end >= 0 && end < dsl.Length); Contract.Ensures(end >= Contract.OldValue(end)); int begin = end; end++; while (end < dsl.Length && dsl[end] != '>') end++; if (end >= dsl.Length) throw new DslSyntaxException("Unexpected end of script within external text reference. Missing closing character: '>'."); end++; // Skip closing character. string basicFilePath = dsl.Substring(begin + 1, end - begin - 2); string dslScriptFolder = Path.GetDirectoryName(dslSource.GetSourceFilePath(begin)); return LoadFile(Path.Combine(dslScriptFolder, basicFilePath)); }