Ejemplo n.º 1
0
        private TypeReferenceNode parsePackageOrTypeName(bool fail) {
            if (!isIdentifier(lexicalUnit)) {
                if (fail) {
                    throw error(ParseErrorId.IdentifierExpected);
                } else {
                    return null;
                }
            }
            TypeReferenceNode result;
            int sp = scanner.StartPosition;
            int len = getLexicalUnitLength();
            var name = new SimpleNameTypeReferenceNode { StartPosition = sp };
            setScannerState(name);
            name.NameOffset = sp;
            name.NameLength = len;
            result = name;
            int endPosition = scanner.EndPosition;
            nextLexicalUnit(false);
            endPosition = parseTypeArguments(name.TypeArguments, false, endPosition);
            while (lexicalUnit == LexicalUnit.Dot) {
				result.EndPosition = scanner.StartPosition;
                nextLexicalUnit(fail);
                if (!isIdentifier(lexicalUnit)) {
                    if (fail) {
                        throw error(ParseErrorId.IdentifierExpected);
                    } else {
                        return null;
                    }
                }
                name = new SimpleNameTypeReferenceNode { StartPosition = scanner.StartPosition, EndPosition = scanner.EndPosition };
                setScannerState(name);
                name.NameOffset = scanner.StartPosition;
                name.NameLength = getLexicalUnitLength();
                var qualifiedType = new QualifiedTypeReferenceNode { EnclosingType = result, SimpleName = name,
                		StartPosition = result.StartPosition };
                copyScannerState(result, qualifiedType);
                result = qualifiedType;
                endPosition = scanner.EndPosition;
                nextLexicalUnit(false);
                endPosition = parseTypeArguments(name.TypeArguments,false, endPosition);
            }
			result.EndPosition = endPosition;
            return result;
        }
Ejemplo n.º 2
0
 private bool parseTypeParameters(List<SimpleNameTypeReferenceNode> parameters, bool fail) {
     if (lexicalUnit != LexicalUnit.LessThan) {
         return true;
     }
     nextLexicalUnit(true);
     while (true) {
         var type = new SimpleNameTypeReferenceNode { NameOffset = scanner.StartPosition, NameLength = getLexicalUnitLength() };
         setScannerState(type);
         parameters.add(type);
         if (!isIdentifier(lexicalUnit)) {
             if (fail) {
                 throw error(ParseErrorId.IdentifierExpected);
             } else {
                 return false;
             }
         }
         type.EndPosition = scanner.EndPosition;
         if (nextLexicalUnit(true) != LexicalUnit.Comma) {
             break;
         }
         nextLexicalUnit(true);
     }
     if (lexicalUnit != LexicalUnit.GreaterThan) {
         if (fail) {
             throw error(ParseErrorId.GreaterThanExpected);
         } else {
             return false;
         }
     }
     nextLexicalUnit(false);
     return true;
 }