示例#1
0
文件: DslParser.cs 项目: koav/Rhetos
 public DslParser(IDslSource dslSource, IConceptInfo[] conceptInfoPlugins, ILogProvider logProvider)
 {
     _dslSource = dslSource;
     _conceptInfoPlugins = conceptInfoPlugins;
     _performanceLogger = logProvider.GetLogger("Performance");
     _logger = logProvider.GetLogger("DslParser");
 }
示例#2
0
 public LoadDslModelCommand(
     IDslSource dslSource,
     IDataTypeProvider dataTypeProvider)
 {
     this.DslSource = dslSource;
     this.DataTypeProvider = dataTypeProvider;
 }
示例#3
0
文件: Tokenizer.cs 项目: koav/Rhetos
        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
                };
        }
示例#4
0
文件: Tokenizer.cs 项目: koav/Rhetos
        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;
        }
示例#5
0
文件: Tokenizer.cs 项目: koav/Rhetos
        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));
        }