private TypeExpressionNode createTypeExpression(TypeReferenceKind typeReferenceKind) {
     var result = new TypeExpressionNode { EndPosition = scanner.EndPosition };
     setScannerState(result);
     var typeReference = new PrimitiveTypeReferenceNode(typeReferenceKind) { EndPosition = scanner.EndPosition };
     setScannerState(typeReference);
     result.TypeReference = typeReference;
     return result;
 }
        private TypeReferenceNode parseNonArrayType(bool fail, bool allowVoid) {
            TypeReferenceNode result;
            switch (lexicalUnit) {
            case Identifier:
            case ContextualKeyword:
            case VerbatimIdentifier:
                result = parsePackageOrTypeName(fail);
                if (!fail && result == null) {
                    return null;
                }
                break;

            case Keyword:
                switch (scanner.Keyword) {
                case Byte:
                    result = new PrimitiveTypeReferenceNode(TypeReferenceKind.Byte) { EndPosition = scanner.EndPosition };
                    setScannerState(result);
                    nextLexicalUnit(false);
                    break;

                case Char:
                    result = new PrimitiveTypeReferenceNode(TypeReferenceKind.Char) { EndPosition = scanner.EndPosition };
                    setScannerState(result);
                    nextLexicalUnit(false);
                    break;

                case Short:
                    result = new PrimitiveTypeReferenceNode(TypeReferenceKind.Short) { EndPosition = scanner.EndPosition };
                    setScannerState(result);
                    nextLexicalUnit(false);
                    break;

                case Int:
                    result = new PrimitiveTypeReferenceNode(TypeReferenceKind.Int) { EndPosition = scanner.EndPosition };
                    setScannerState(result);
                    nextLexicalUnit(false);
                    break;

                case Long:
                    result = new PrimitiveTypeReferenceNode(TypeReferenceKind.Long) { EndPosition = scanner.EndPosition };
                    setScannerState(result);
                    nextLexicalUnit(false);
                    break;

                case Boolean:
                    result = new PrimitiveTypeReferenceNode(TypeReferenceKind.Boolean) { EndPosition = scanner.EndPosition };
                    setScannerState(result);
                    nextLexicalUnit(false);
                    break;

                case Double:
                    result = new PrimitiveTypeReferenceNode(TypeReferenceKind.Double) { EndPosition = scanner.EndPosition };
                    setScannerState(result);
                    nextLexicalUnit(false);
                    break;

                case String:
                    result = new PrimitiveTypeReferenceNode(TypeReferenceKind.String) { EndPosition = scanner.EndPosition };
                    setScannerState(result);
                    nextLexicalUnit(false);
                    break;

                case Float:
                    result = new PrimitiveTypeReferenceNode(TypeReferenceKind.Float) { EndPosition = scanner.EndPosition };
                    setScannerState(result);
                    nextLexicalUnit(false);
                    break;

                case Void:
                    result = new PrimitiveTypeReferenceNode(TypeReferenceKind.Void) { EndPosition = scanner.EndPosition };
                    setScannerState(result);
                    nextLexicalUnit(false);
                    break;

                default:
                    if (fail) {
                        throw error(ParseErrorId.IdentifierExpected);
                    } else {
                        return null;
                    }
                }
                break;

            default:
                if (fail) {
                    throw error(ParseErrorId.IdentifierExpected);
                } else {
                    return null;
                }
            }
            if (!allowVoid && result.TypeReferenceKind == TypeReferenceKind.Void) {
                if (fail) {
                    throw error(ParseErrorId.UnexpectedVoid);
                } else {
                    return null;
                }
            }
            return result;
        }