private void CheckArgumentIntegrity(Argument argument)
 {
     if (!(argument.Parent is Alias))
     {
         Context.AddError(CompilerErrorFactory.ArgumentMustBeDefinedInAlias(argument, _currentModule.FileName));
     }
 }
Exemple #2
0
 public static CompilerError UnexpectedArgument(Argument argument, string fileName)
 {
     return(Instantiate("MCE0024", new LexicalInfo(fileName, argument.NameInterval.Begin.Line, argument.NameInterval.Begin.Column, argument.NameInterval.Begin.Index), false));
 }
Exemple #3
0
 public static CompilerError ArgumentMustBeDefinedInAlias(Argument node, string fileName)
 {
     return(Instantiate("MCE0022", new LexicalInfo(fileName, node.NameInterval.Begin.Line, node.NameInterval.Begin.Column, node.NameInterval.Begin.Index), false));
 }
Exemple #4
0
 internal static CompilerError BlockArgumentIsExpected(Argument argument, string fileName)
 {
     return(Instantiate("MCE0015", new LexicalInfo(fileName, argument.NameInterval.Begin.Line, argument.NameInterval.Begin.Column, argument.NameInterval.Begin.Index), false));
 }
Exemple #5
0
 internal static CompilerError DuplicateArgumentName(Argument argument, string fileName)
 {
     return(Instantiate("MCE0011", new LexicalInfo(fileName, argument.NameInterval.Begin.Line, argument.NameInterval.Begin.Column, argument.NameInterval.Begin.Index), false, argument.Name));
 }
Exemple #6
0
        /// <inheritdoc />
        public Pair CreateMappedPair(ITextSource textSource, int nameQuotesType, Interval nameInterval,
                                     AssignmentEnum assignment,
                                     Interval assignmentInterval, int valueQuotesType, Interval valueInterval, int valueIndent)
        {
            IMappedPair pair;
            var         nameText = GetNameText(textSource, nameQuotesType, nameInterval);
            var         value    = GetValue(textSource, assignment, valueQuotesType, valueInterval, valueIndent, _context, _module);

            if (nameQuotesType > 0)
            {
                pair = new Element
                       (
                    VerifyElementName(nameText, nameInterval, _module),
                    nameQuotesType: nameQuotesType,
                    nameInterval: nameInterval,
                    assignment: assignment,
                    assignmentInterval: assignmentInterval,
                    value: value.Item1,
                    valueQuotesType: valueQuotesType,
                    valueInterval: valueInterval,
                    interpolationItems: value.Item2,
                    valueIndent: valueIndent,
                    valueType: GetValueType(assignment, value.Item1, valueQuotesType)
                       );
            }
            else if (nameText.StartsWith("@"))
            {
                var tuple = Element.GetNameAndNs(nameText.Substring(1), nameQuotesType);
                var ns    = string.IsNullOrEmpty(tuple.Item1) ? null : tuple.Item1;
                pair = new Attribute
                       (
                    VerifyName(tuple.Item2, nameInterval, _module),
                    ns,
                    nameInterval: nameInterval,
                    assignment: assignment,
                    assignmentInterval: assignmentInterval,
                    value: value.Item1,
                    valueQuotesType: valueQuotesType,
                    valueInterval: valueInterval,
                    interpolationItems: value.Item2,
                    valueIndent: valueIndent,
                    valueType: GetValueType(assignment, value.Item1, valueQuotesType)
                       );
            }
            else if (nameText.StartsWith("!$"))
            {
                pair = new AliasDefinition
                       (
                    VerifyName(nameText.Substring(2), nameInterval, _module),
                    nameInterval: nameInterval,
                    assignment: assignment,
                    assignmentInterval: assignmentInterval,
                    value: value.Item1,
                    valueQuotesType: valueQuotesType,
                    valueInterval: valueInterval,
                    interpolationItems: value.Item2,
                    valueIndent: valueIndent,
                    valueType: GetValueType(assignment, value.Item1, valueQuotesType)
                       );
            }
            else if (nameText.StartsWith("!#"))
            {
                pair = new NamespaceDefinition
                       (
                    VerifyNsName(nameText.Substring(2), nameInterval, _module),
                    nameInterval: nameInterval,
                    assignment: assignment,
                    assignmentInterval: assignmentInterval,
                    value: value.Item1,
                    valueQuotesType: valueQuotesType,
                    valueInterval: valueInterval,
                    interpolationItems: value.Item2,
                    valueIndent: valueIndent,
                    valueType: GetValueType(assignment, value.Item1, valueQuotesType)
                       );
            }
            else if (nameText.StartsWith("!%"))
            {
                pair = new Parameter
                       (
                    VerifyNsName(nameText.Substring(2), nameInterval, _module),
                    nameInterval: nameInterval,
                    assignment: assignment,
                    assignmentInterval: assignmentInterval,
                    value: value.Item1,
                    valueQuotesType: valueQuotesType,
                    valueInterval: valueInterval,
                    interpolationItems: value.Item2,
                    valueIndent: valueIndent,
                    valueType: GetValueType(assignment, value.Item1, valueQuotesType)
                       );
            }
            else if (nameText.StartsWith("!"))
            {
                pair = new Document
                       (
                    VerifyName(nameText.Substring(1), nameInterval, _module),
                    nameInterval: nameInterval,
                    assignment: assignment,
                    assignmentInterval: assignmentInterval,
                    value: value.Item1,
                    valueQuotesType: valueQuotesType,
                    valueInterval: valueInterval,
                    interpolationItems: value.Item2,
                    valueIndent: valueIndent,
                    valueType: GetValueType(assignment, value.Item1, valueQuotesType)
                       );
            }
            else if (nameText.StartsWith("$"))
            {
                pair = new Alias
                       (
                    VerifyName(nameText.Substring(1), nameInterval, _module),
                    nameInterval: nameInterval,
                    assignment: assignment,
                    assignmentInterval: assignmentInterval,
                    value: value.Item1,
                    valueQuotesType: valueQuotesType,
                    valueInterval: valueInterval,
                    interpolationItems: value.Item2,
                    valueIndent: valueIndent,
                    valueType: GetValueType(assignment, value.Item1, valueQuotesType)
                       );
            }
            else if (nameText.StartsWith("%"))
            {
                pair = new Argument
                       (
                    VerifyName(nameText.Substring(1), nameInterval, _module),
                    nameInterval: nameInterval,
                    assignment: assignment,
                    assignmentInterval: assignmentInterval,
                    value: value.Item1,
                    valueQuotesType: valueQuotesType,
                    valueInterval: valueInterval,
                    interpolationItems: value.Item2,
                    valueIndent: valueIndent,
                    valueType: GetValueType(assignment, value.Item1, valueQuotesType)
                       );
            }
            else if (nameText.StartsWith("#"))
            {
                var tuple = Element.GetNameAndNs(nameText.Substring(1), nameQuotesType);
                var ns    = string.IsNullOrEmpty(tuple.Item1) ? null : tuple.Item1;

                if (ns == null)
                {
                    pair = new Scope
                           (
                        null,
                        VerifyScopeName(nameText.Substring(1), nameInterval, _module),
                        nameInterval: nameInterval,
                        assignment: assignment,
                        assignmentInterval: assignmentInterval,
                        value: value.Item1,
                        valueQuotesType: valueQuotesType,
                        valueInterval: valueInterval,
                        interpolationItems: value.Item2,
                        valueIndent: valueIndent,
                        valueType: GetValueType(assignment, value.Item1, valueQuotesType)
                           );
                }
                else
                {
                    pair = new Scope
                           (
                        VerifyElementName(tuple.Item2, nameInterval, _module),
                        VerifyScopeName(ns, nameInterval, _module),
                        nameInterval: nameInterval,
                        assignment: assignment,
                        assignmentInterval: assignmentInterval,
                        value: value.Item1,
                        valueQuotesType: valueQuotesType,
                        valueInterval: valueInterval,
                        interpolationItems: value.Item2,
                        valueIndent: valueIndent,
                        valueType: GetValueType(assignment, value.Item1, valueQuotesType)
                           );
                }
            }
            else
            {
                var tuple = Element.GetNameAndNs(nameText, nameQuotesType);
                var ns    = string.IsNullOrEmpty(tuple.Item1) ? null : tuple.Item1;

                pair = new Element
                       (
                    VerifyElementName(tuple.Item2, nameInterval, _module),
                    VerifyScopeName(ns, nameInterval, _module),
                    nameInterval: nameInterval,
                    assignment: assignment,
                    assignmentInterval: assignmentInterval,
                    value: value.Item1,
                    valueQuotesType: valueQuotesType,
                    valueInterval: valueInterval,
                    interpolationItems: value.Item2,
                    valueIndent: valueIndent,
                    valueType: GetValueType(assignment, value.Item1, valueQuotesType)
                       );
            }
            return((Pair)pair);
        }