text:
package org.hibernate.validator.cfg.context.impl;

import java.lang.annotation.ElementType;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import javax.validation.ValidationException;

import org.hibernate.validator.cfg.context.MethodConstraintMappingContext;
import org.hibernate.validator.cfg.context.PropertyConstraintMappingContext;
import org.hibernate.validator.cfg.context.TypeConstraintMappingContext;
import org.hibernate.validator.util.Contracts;
import org.hibernate.validator.util.ReflectionHelper;

/**
 * Base class for implementations of constraint mapping creational context types.
 *
 * @author Gunnar Morling
 */
public abstract class ConstraintMappingContextImplBase {

	protected final Class<?> beanClass;

	protected final ConstraintMappingContext mapping;

	public ConstraintMappingContextImplBase(Class<?> beanClass, ConstraintMappingContext mapping) {

		this.beanClass = beanClass;
		this.mapping = mapping;
	}

	public <C> TypeConstraintMappingContext<C> type(Class<C> type) {

		Contracts.assertNotNull( beanClass, "The bean type must not be null when creating a constraint mapping." );

		return new TypeConstraintMappingContextImpl<C>( type, mapping );
	}

	public PropertyConstraintMappingContext property(String property, ElementType elementType) {

		Contracts.assertNotNull( property, "The property name must not be null." );
		Contracts.assertNotNull( elementType, "The element type must not be null." );

		if ( property.length() == 0 ) {
			throw new IllegalArgumentException( "The property name must not be empty." );
		}

		Member member = ReflectionHelper.getMember(
				beanClass, property, elementType
		);

		if ( member == null ) {
			throw new ValidationException(
					"The class " + beanClass + " does not have a property '"
							+ property + "' with access " + elementType
			);
		}

		return new PropertyConstraintMappingContextImpl( beanClass, member, mapping );
	}

	public MethodConstraintMappingContext method(String name, Class<?>... parameterTypes) {

		Contracts.assertNotNull( name, "The method name must not be null." );

		Method method = ReflectionHelper.getDeclaredMethod( beanClass, name, parameterTypes );

		if ( method == null ) {
			StringBuilder sb = new StringBuilder();
			for ( Class<?> oneParameterType : parameterTypes ) {
				sb.append( oneParameterType.getName() + ", " );
			}

			String parameterTypesAsString = sb.length() > 2 ? sb.substring( 0, sb.length() - 2 ) : sb.toString();

			throw new IllegalArgumentException(
					String.format( "Type %s doesn't have a method %s(%s).", beanClass, name, parameterTypesAsString )
			);
		}

		return new MethodConstraintMappingContextImpl( beanClass, method, mapping );
	}

}


text:
using System.Collections.Generic;
using MatrixSolver.Core.Matrix.Models;

namespace MatrixSolver.Core.Matrix.Solvers
{
    public interface ISolver
    {
        Models.Matrix2 Matrix { get; }
        List<Models.Matrix2> Steps { get; }
        void ToEchelonForm();
        bool Solve();
        bool IsConsistent();
    }
}

redpajama_set_name: RedPajamaGithub


text:
static NSString * const kAFMultipartFormLineDelimiter = @"\r\n"; // CRLF
static NSString * const kAFMultipartFormBoundary = @"Boundary+0xAbCdEfGbOuNdArY";

@interface AFMultipartFormData : NSObject <AFMultipartFormData> {
@private
    NSStringEncoding _stringEncoding;
    NSMutableData *_mutableData;
}

@property (readonly) NSData *data;

- (id)initWithStringEncoding:(NSStringEncoding)encoding;

@end

#pragma mark -

#ifdef _SYSTEMCONFIGURATION_H
typedef SCNetworkReachabilityRef AFNetworkReachabilityRef;
#else
typedef id AFNetworkReachabilityRef;
#endif

typedef void (^AFNetworkReachabilityStatusBlock)(BOOL isNetworkReachable);
typedef void (^AFCompletionBlock)(void);

static NSUInteger const kAFHTTPClientDefaultMaxConcurrentOperationCount = 4;

static NSString * AFBase64EncodedStringFromString(NSString *string) {
    NSData *data = [NSData dataWithBytes:[string UTF8String] length:[string lengthOfBytesUsingEncoding:NSUTF8StringEncoding]];
    NSUInteger length = [data length];
    NSMutableData *mutableData = [NSMutableData dataWithLength:((length + 2) / 3) * 4];

    uint8_t *input = (uint8_t *)[data bytes];
    uint8_t *output = (uint8_t *)[mutableData mutableBytes];

    for (NSUInteger i = 0; i < length; i += 3) {
        NSUInteger value = 0;
        for (NSUInteger j = i; j < (i + 3); j++) {
            value <<= 8;
            if (j < length) {
                value |= (0xFF & input[j]);
            }
        }

        static uint8_t const kAFBase64EncodingTable[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

        NSUInteger idx = (i / 3) * 4;
        output[idx + 0] = kAFBase64EncodingTable[(value >> 18) & 0x3F];
        output[idx + 1] = kAFBase64EncodingTable[(value >> 12) & 0x3F];
        output[idx + 2] = (i + 1) < length ? kAFBase64EncodingTable[(value >> 6)  & 0x3F] : '=';
        output[idx + 3] = (i + 2) < length ? kAFBase64EncodingTable[(value >> 0)  & 0x3F] : '=';
    }

    return [[[NSString alloc] initWithData:mutableData encoding:NSASCIIStringEncoding] autorelease];
}

NSString * AFURLEncodedStringFromStringWithEncoding(NSString *string, NSStringEncoding encoding) {
    static NSString * const kAFLegalCharactersToBeEscaped = @"?!@#$^&%*+,:;='\"`<>()[]{}/\\|~ ";

    // Following the suggestion in documentation for `CFURLCreateStringByAddingPercentEscapes` to "pre-process" URL strings (using stringByReplacingPercentEscapesUsingEncoding) with unpredictable sequences that may already contain percent escapes.
	return [(NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)[string stringByReplacingPercentEscapesUsingEncoding:encoding], NULL, (CFStringRef)kAFLegalCharactersToBeEscaped, CFStringConvertNSStringEncodingToEncoding(encoding)) autorelease];
}

NSString * AFQueryStringFromParametersWithEncoding(NSDictionary *parameters, NSStringEncoding encoding) {
    NSMutableArray *mutableParameterComponents = [NSMutableArray array];
    for (id key in [parameters allKeys]) {
        id value = [parameters valueForKey:key];
        if ([value isKindOfClass:[NSArray class]]) {
            NSString *arrayKey = AFURLEncodedStringFromStringWithEncoding([NSString stringWithFormat:@"%@[]", [key description]], encoding);
            for (id arrayValue in value) {
                NSString *component = [NSString stringWithFormat:@"%@=%@", arrayKey, AFURLEncodedStringFromStringWithEncoding([arrayValue description], encoding)];
                [mutableParameterComponents addObject:component];
            }
        } else {
            NSString *component = [NSString stringWithFormat:@"%@=%@", AFURLEncodedStringFromStringWithEncoding([key description], encoding), AFURLEncodedStringFromStringWithEncoding([value description], encoding)];
            [mutableParameterComponents addObject:component];
        }
    }

    return [mutableParameterComponents componentsJoinedByString:@"&"];
}

static NSString * AFJSONStringFromParameters(NSDictionary *parameters) {
    NSError *error = nil;
    NSData *JSONData = AFJSONEncode(parameters, &error);
    if (!error) {
        return [[[NSString alloc] initWithData:JSONData encoding:NSUTF8StringEncoding] autorelease];
    } else {
        return nil;
    }
}

static NSString * AFPropertyListStringFromParameters(NSDictionary *parameters) {
    NSString *propertyListString = nil;
    NSError *error = nil;

    NSData *propertyListData = [NSPropertyListSerialization dataWithPropertyList:parameters format:NSPropertyListXMLFormat_v1_0 options:0 error:&error];
    if (!error) {
        propertyListString = [[[NSString alloc] initWithData:propertyListData encoding:NSUTF8StringEncoding] autorelease];
    }

    return propertyListString;
}

@interface AFHTTPClient ()
@property (readwrite, nonatomic, retain) NSURL *baseURL;
@property (readwrite, nonatomic, retain) NSMutableArray *registeredHTTPOperationClassNames;
@property (readwrite, nonatomic, retain) NSMutableDictionary *defaultHeaders;
@property (readwrite, nonatomic, retain) NSOperationQueue *operationQueue;
@property (readwrite, nonatomic, assign) AFNetworkReachabilityRef networkReachability;
@property (readwrite, nonatomic, copy) AFNetworkReachabilityStatusBlock networkReachabilityStatusBlock;
@end

@implementation AFHTTPClient
@synthesize baseURL = _baseURL;
@synthesize stringEncoding = _stringEncoding;
@synthesize parameterEncoding = _parameterEncoding;
@synthesize registeredHTTPOperationClassNames = _registeredHTTPOperationClassNames;
@synthesize defaultHeaders = _defaultHeaders;
@synthesize operationQueue = _operationQueue;
@synthesize networkReachability = _networkReachability;
@synthesize networkReachabilityStatusBlock = _networkReachabilityStatusBlock;

+ (AFHTTPClient *)clientWithBaseURL:(NSURL *)url {
    return [[[self alloc] initWithBaseURL:url] autorelease];
}

- (id)initWithBaseURL:(NSURL *)url {
    self = [super init];
    if (!self) {
        return nil;
    }

    self.baseURL = url;

    self.stringEncoding = NSUTF8StringEncoding;
    self.parameterEncoding = AFFormURLParameterEncoding;

    self.registeredHTTPOperationClassNames = [NSMutableArray array];

	self.defaultHeaders = [NSMutableDictionary dictionary];

	// Accept-Encoding HTTP Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.3
	[self setDefaultHeader:@"Accept-Encoding" value:@"gzip"];

	// Accept-Language HTTP Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4
	NSString *preferredLanguageCodes = [[NSLocale preferredLanguages] componentsJoinedByString:@", "];
	[self setDefaultHeader:@"Accept-Language" value:[NSString stringWithFormat:@"%@, en-us;q=0.8", preferredLanguageCodes]];

#if __IPHONE_OS_VERSION_MIN_REQUIRED
    // User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43
    [self setDefaultHeader:@"User-Agent" value:[NSString stringWithFormat:@"%@/%@ (%@, %@ %@, %@, Scale/%f)", [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleIdentifierKey], [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey], @"unknown", [[UIDevice currentDevice] systemName], [[UIDevice currentDevice] systemVersion], [[UIDevice currentDevice] model], ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] ? [[UIScreen mainScreen] scale] : 1.0)]];
#elif __MAC_OS_X_VERSION_MIN_REQUIRED
    [self setDefaultHeader:@"User-Agent" value:[NSString stringWithFormat:@"%@/%@ (%@)", [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleIdentifierKey], [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey], @"unknown"]];
#endif

    self.operationQueue = [[[NSOperationQueue alloc] init] autorelease];
	[self.operationQueue setMaxConcurrentOperationCount:kAFHTTPClientDefaultMaxConcurrentOperationCount];

    return self;
}

- (void)dealloc {
    [_baseURL release];
    [_registeredHTTPOperationClassNames release];
    [_defaultHeaders release];
    [_operationQueue release];
    [_networkReachabilityStatusBlock release];
    if (_networkReachability) {
        CFRelease(_networkReachability);
    }

    [super dealloc];
}

- (NSString *)description {
    return [NSString stringWithFormat:@"<%@: %p, baseURL: %@, defaultHeaders: %@, registeredOperationClasses: %@, operationQueue: %@>", NSStringFromClass([self class]), self, [self.baseURL absoluteString], self.defaultHeaders, self.registeredHTTPOperationClassNames, self.operationQueue];
}

#pragma mark -

#ifdef _SYSTEMCONFIGURATION_H
static void AFReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNetworkReachabilityFlags flags, void *info) {
    if (info) {
        AFNetworkReachabilityStatusBlock block = (AFNetworkReachabilityStatusBlock)info;
        BOOL isNetworkReachable = (flags & kSCNetworkReachabilityFlagsReachable);
        block(isNetworkReachable);
    }
}

- (void)setReachabilityStatusChangeBlock:(void (^)(BOOL isNetworkReachable))block {
    if (_networkReachability) {
        SCNetworkReachabilityUnscheduleFromRunLoop(_networkReachability, CFRunLoopGetMain(), (CFStringRef)NSRunLoopCommonModes);
        CFRelease(_networkReachability);
    }

    self.networkReachabilityStatusBlock = block;
    self.networkReachability = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, [[self.baseURL host] UTF8String]);
    SCNetworkReachabilityContext context = {0, self.networkReachabilityStatusBlock, NULL, NULL, NULL};
    SCNetworkReachabilitySetCallback(self.networkReachability, AFReachabilityCallback, &context);
    SCNetworkReachabilityScheduleWithRunLoop(self.networkReachability, CFRunLoopGetMain(), (CFStringRef)NSRunLoopCommonModes);
}
#endif

#pragma mark -

- (BOOL)registerHTTPOperationClass:(Class)operationClass {
    if (![operationClass isSubclassOfClass:[AFHTTPRequestOperation class]]) {
        return NO;
    }

    NSString *className = NSStringFromClass(operationClass);
    [self.registeredHTTPOperationClassNames removeObject:className];
    [self.registeredHTTPOperationClassNames insertObject:className atIndex:0];

    return YES;
}

- (void)unregisterHTTPOperationClass:(Class)operationClass {
    NSString *className = NSStringFromClass(operationClass);
    [self.registeredHTTPOperationClassNames removeObject:className];
}

#pragma mark -

- (NSString *)defaultValueForHeader:(NSString *)header {
	return [self.defaultHeaders valueForKey:header];
}

- (void)setDefaultHeader:(NSString *)header value:(NSString *)value {
	[self.defaultHeaders setValue:value forKey:header];
}

- (void)setAuthorizationHeaderWithUsername:(NSString *)username password:(NSString *)password {
	NSString *basicAuthCredentials = [NSString stringWithFormat:@"%@:%@", username, password];
    [self setDefaultHeader:@"Authorization" value:[NSString stringWithFormat:@"Basic %@", AFBase64EncodedStringFromString(basicAuthCredentials)]];
}

- (void)setAuthorizationHeaderWithToken:(NSString *)token {
    [self setDefaultHeader:@"Authorization" value:[NSString stringWithFormat:@"Token token=\"%@\"", token]];
}

- (void)clearAuthorizationHeader {
	[self.defaultHeaders removeObjectForKey:@"Authorization"];
}

#pragma mark -

- (NSMutableURLRequest *)requestWithMethod:(NSString *)method
                                      path:(NSString *)path
                                parameters:(NSDictionary *)parameters
{
    NSURL *url = [NSURL URLWithString:path relativeToURL:self.baseURL];
	NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] initWithURL:url] autorelease];
    [request setHTTPMethod:method];
    [request setAllHTTPHeaderFields:self.defaultHeaders];

    if (parameters) {
        if ([method isEqualToString:@"GET"] || [method isEqualToString:@"HEAD"] || [method isEqualToString:@"DELETE"]) {
            url = [NSURL URLWithString:[[url absoluteString] stringByAppendingFormat:[path rangeOfString:@"?"].location == NSNotFound ? @"?%@" : @"&%@", AFQueryStringFromParametersWithEncoding(parameters, self.stringEncoding)]];
            [request setURL:url];
        } else {
            NSString *charset = (NSString *)CFStringConvertEncodingToIANACharSetName(CFStringConvertNSStringEncodingToEncoding(self.stringEncoding));
            switch (self.parameterEncoding) {
                case AFFormURLParameterEncoding:;
                    [request setValue:[NSString stringWithFormat:@"application/x-www-form-urlencoded; charset=%@", charset] forHTTPHeaderField:@"Content-Type"];
                    [request setHTTPBody:[AFQueryStringFromParametersWithEncoding(parameters, self.stringEncoding) dataUsingEncoding:self.stringEncoding]];
                    break;
                case AFJSONParameterEncoding:;
                    [request setValue:[NSString stringWithFormat:@"application/json; charset=%@", charset] forHTTPHeaderField:@"Content-Type"];
                    [request setHTTPBody:[AFJSONStringFromParameters(parameters) dataUsingEncoding:self.stringEncoding]];
                    break;
                case AFPropertyListParameterEncoding:;
                    [request setValue:[NSString stringWithFormat:@"application/x-plist; charset=%@", charset] forHTTPHeaderField:@"Content-Type"];
                    [request setHTTPBody:[AFPropertyListStringFromParameters(parameters) dataUsingEncoding:self.stringEncoding]];
                    break;
            }
        }
    }

	return request;
}

- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method
                                                   path:(NSString *)path
                                             parameters:(NSDictionary *)parameters
                              constructingBodyWithBlock:(void (^)(id <AFMultipartFormData>formData))block
{
    NSMutableURLRequest *request = [self requestWithMethod:method path:path parameters:nil];
    __block AFMultipartFormData *formData = [[AFMultipartFormData alloc] initWithStringEncoding:self.stringEncoding];

    id key = nil;
	NSEnumerator *enumerator = [parameters keyEnumerator];
	while ((key = [enumerator nextObject])) {
        id value = [parameters valueForKey:key];
        NSData *data = nil;

        if ([value isKindOfClass:[NSData class]]) {
            data = value;
        } else {
            data = [[value description] dataUsingEncoding:self.stringEncoding];
        }

        [formData appendPartWithFormData:data name:[key description]];
    }

    if (block) {
        block(formData);
    }

    [request setValue:[NSString stringWithFormat:@"multipart/form-data; boundary=%@", kAFMultipartFormBoundary] forHTTPHeaderField:@"Content-Type"];
    [request setHTTPBody:[formData data]];

    [formData autorelease];

    return request;
}

- (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)urlRequest
                                                    success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
                                                    failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
{
    AFHTTPRequestOperation *operation = nil;
    NSString *className = nil;
    NSEnumerator *enumerator = [self.registeredHTTPOperationClassNames reverseObjectEnumerator];
    while (!operation && (className = [enumerator nextObject])) {
        Class op_class = NSClassFromString(className);
        if (op_class && [op_class canProcessRequest:urlRequest]) {
            operation = [[(AFHTTPRequestOperation *)[op_class alloc] initWithRequest:urlRequest] autorelease];
        }
    }

    if (!operation) {
        operation = [[[AFHTTPRequestOperation alloc] initWithRequest:urlRequest] autorelease];
    }

    [operation setCompletionBlockWithSuccess:success failure:failure];

    return operation;
}

#pragma mark -

- (void)enqueueHTTPRequestOperation:(AFHTTPRequestOperation *)operation {
    [self.operationQueue addOperation:operation];
}

- (void)cancelAllHTTPOperationsWithMethod:(NSString *)method path:(NSString *)path {
    for (AFHTTPRequestOperation *operation in [self.operationQueue operations]) {
        if ((!method || [method isEqualToString:[[operation request] HTTPMethod]]) && [path isEqualToString:[[[operation request] URL] path]]) {
            [operation cancel];
        }
    }
}

- (void)enqueueBatchOfHTTPRequestOperationsWithRequests:(NSArray *)requests
                                          progressBlock:(void (^)(NSUInteger numberOfCompletedOperations, NSUInteger totalNumberOfOperations))progressBlock
                                        completionBlock:(void (^)(NSArray *operations))completionBlock
{
    NSMutableArray *mutableOperations = [NSMutableArray array];
    for (NSURLRequest *request in requests) {
        AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:nil failure:nil];
        [mutableOperations addObject:operation];
    }

    [self enqueueBatchOfHTTPRequestOperations:mutableOperations progressBlock:progressBlock completionBlock:completionBlock];
}

- (void)enqueueBatchOfHTTPRequestOperations:(NSArray *)operations
                              progressBlock:(void (^)(NSUInteger numberOfCompletedOperations, NSUInteger totalNumberOfOperations))progressBlock
                            completionBlock:(void (^)(NSArray *operations))completionBlock
{
    NSBlockOperation *batchedOperation = [NSBlockOperation blockOperationWithBlock:^{
        if (completionBlock) {
            completionBlock(operations);
        }
    }];

    [self.operationQueue addOperation:batchedOperation];

    NSPredicate *finishedOperationPredicate = [NSPredicate predicateWithFormat:@"isFinished == YES"];

    for (AFHTTPRequestOperation *operation in operations) {
        AFCompletionBlock originalCompletionBlock = [[operation.completionBlock copy] autorelease];
        operation.completionBlock = ^{
            if (progressBlock) {
                progressBlock([[batchedOperation.dependencies filteredArrayUsingPredicate:finishedOperationPredicate] count], [batchedOperation.dependencies count]);
            }

            if (originalCompletionBlock) {
                originalCompletionBlock();
            }
        };

        [batchedOperation addDependency:operation];
        [self enqueueHTTPRequestOperation:operation];
    }
}

#pragma mark -

- (void)getPath:(NSString *)path
     parameters:(NSDictionary *)parameters
        success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
        failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
{
	NSURLRequest *request = [self requestWithMethod:@"GET" path:path parameters:parameters];
    AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure];
    [self enqueueHTTPRequestOperation:operation];
}

- (void)postPath:(NSString *)path
      parameters:(NSDictionary *)parameters
         success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
         failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
{
	NSURLRequest *request = [self requestWithMethod:@"POST" path:path parameters:parameters];
	AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure];
    [self enqueueHTTPRequestOperation:operation];
}

- (void)putPath:(NSString *)path
     parameters:(NSDictionary *)parameters
        success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
        failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
{
	NSURLRequest *request = [self requestWithMethod:@"PUT" path:path parameters:parameters];
	AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure];
    [self enqueueHTTPRequestOperation:operation];
}

- (void)deletePath:(NSString *)path
        parameters:(NSDictionary *)parameters
           success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
           failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
{
	NSURLRequest *request = [self requestWithMethod:@"DELETE" path:path parameters:parameters];
	AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure];
    [self enqueueHTTPRequestOperation:operation];
}

@end

#pragma mark -

static NSString * const kAFMultipartFormCRLF = @"\r\n";

static inline NSString * AFMultipartFormInitialBoundary() {
    return [NSString stringWithFormat:@"--%@%@", kAFMultipartFormBoundary, kAFMultipartFormCRLF];
}

static inline NSString * AFMultipartFormEncapsulationBoundary() {
    return [NSString stringWithFormat:@"%@--%@%@", kAFMultipartFormCRLF, kAFMultipartFormBoundary, kAFMultipartFormCRLF];
}

static inline NSString * AFMultipartFormFinalBoundary() {
    return [NSString stringWithFormat:@"%@--%@--%@%@", kAFMultipartFormCRLF, kAFMultipartFormBoundary, kAFMultipartFormCRLF, kAFMultipartFormCRLF];
}

@interface AFMultipartFormData ()
@property (readwrite, nonatomic, assign) NSStringEncoding stringEncoding;
@property (readwrite, nonatomic, retain) NSMutableData *mutableData;
@end

@implementation AFMultipartFormData
@synthesize stringEncoding = _stringEncoding;
@synthesize mutableData = _mutableData;

- (id)initWithStringEncoding:(NSStringEncoding)encoding {
    self = [super init];
    if (!self) {
        return nil;
    }

    self.stringEncoding = encoding;
    self.mutableData = [NSMutableData dataWithLength:0];

    return self;
}

- (void)dealloc {
    [_mutableData release];
    [super dealloc];
}

- (NSData *)data {
    NSMutableData *finalizedData = [NSMutableData dataWithData:self.mutableData];
    [finalizedData appendData:[AFMultipartFormFinalBoundary() dataUsingEncoding:self.stringEncoding]];
    return finalizedData;
}

#pragma mark - AFMultipartFormData

- (void)appendPartWithHeaders:(NSDictionary *)headers body:(NSData *)body {
    if ([self.mutableData length] == 0) {
        [self appendString:AFMultipartFormInitialBoundary()];
    } else {
        [self appendString:AFMultipartFormEncapsulationBoundary()];
    }

    for (NSString *field in [headers allKeys]) {
        [self appendString:[NSString stringWithFormat:@"%@: %@%@", field, [headers valueForKey:field], kAFMultipartFormCRLF]];
    }

    [self appendString:kAFMultipartFormCRLF];
    [self appendData:body];
}

- (void)appendPartWithFormData:(NSData *)data name:(NSString *)name {
    NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary];
    [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"", name] forKey:@"Content-Disposition"];

    [self appendPartWithHeaders:mutableHeaders body:data];
}

- (void)appendPartWithFileData:(NSData *)data name:(NSString *)name fileName:(NSString *)fileName mimeType:(NSString *)mimeType {
    NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary];
    [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"];
    [mutableHeaders setValue:mimeType forKey:@"Content-Type"];

    [self appendPartWithHeaders:mutableHeaders body:data];
}

- (BOOL)appendPartWithFileURL:(NSURL *)fileURL name:(NSString *)name error:(NSError **)error {
    if (![fileURL isFileURL]) {
        NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
        [userInfo setValue:fileURL forKey:NSURLErrorFailingURLErrorKey];
        [userInfo setValue:NSLocalizedString(@"Expected URL to be a file URL", nil) forKey:NSLocalizedFailureReasonErrorKey];
        if (error != NULL) {
          *error = [[[NSError alloc] initWithDomain:AFNetworkingErrorDomain code:NSURLErrorBadURL userInfo:userInfo] autorelease];
        }

        return NO;
    }

    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:fileURL];
    [request setCachePolicy:NSURLCacheStorageNotAllowed];

    NSURLResponse *response = nil;
    NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:error];

    if (data && response) {
        [self appendPartWithFileData:data name:name fileName:[response suggestedFilename] mimeType:[response MIMEType]];

        return YES;
    } else {
        return NO;
    }
}

- (void)appendData:(NSData *)data {
    [self.mutableData appendData:data];
}

- (void)appendString:(NSString *)string {
    [self appendData:[string dataUsingEncoding:self.stringEncoding]];
}

@end


text:
<?php

namespace Czim\Service\Contracts;

use Czim\Service\Exceptions\Ssh2ConnectionException;

interface Ssh2ConnectionInterface
{
    /**
     * Connects to SSH2 server.
     *
     * @param string $url
     * @param string $user
     * @param string $password
     * @throws Ssh2ConnectionException  if cannot connect
     */
    public function __construct(string $url, string $user, string $password);

    /**
     * Reconnects if not already connected.
     *
     * @return bool
     * @throws Ssh2ConnectionException if connect fails
     */
    public function reconnect(): bool;

    public function disconnect(): bool;

    /**
     * Executes command over connection.
     *
     * @param string $command
     * @return mixed
     */
    public function exec(string $command): mixed;
}


text:
<!DOCTYPE html>

 <title>[Acid3 - Test 090a] NUL in regexp incorrectly ignored</title>

FAIL (script did not execute)


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _25.Numbers_from_N_to_1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            for (int i = n; i >=1; i--)
            {
                Console.WriteLine(i);
            }
        }
    }
}


text:
package de.gurkenlabs.litiengine.environment;

import java.util.ArrayList;
import java.util.Collection;

import de.gurkenlabs.litiengine.Direction;
import de.gurkenlabs.litiengine.entities.IEntity;
import de.gurkenlabs.litiengine.entities.Spawnpoint;
import de.gurkenlabs.litiengine.environment.tilemap.IMapObject;
import de.gurkenlabs.litiengine.environment.tilemap.MapObjectProperty;
import de.gurkenlabs.litiengine.environment.tilemap.MapObjectType;

public class SpawnpointMapObjectLoader extends MapObjectLoader {

  protected SpawnpointMapObjectLoader() {
    super(MapObjectType.SPAWNPOINT);
  }

  @Override
  public Collection<IEntity> load(Environment environment, IMapObject mapObject) {
    Collection<IEntity> entities = new ArrayList<>();
    if (!this.isMatchingType(mapObject)) {
      return entities;
    }

    final Direction direction = mapObject.getStringValue(MapObjectProperty.SPAWN_DIRECTION) != null
        ? Direction.valueOf(mapObject.getStringValue(MapObjectProperty.SPAWN_DIRECTION))
        : Direction.DOWN;
    final String spawnType = mapObject.getStringValue(MapObjectProperty.SPAWN_INFO);

    final Spawnpoint spawn = this.createSpawnpoint(mapObject, direction, spawnType);
    loadDefaultProperties(spawn, mapObject);

    entities.add(spawn);
    return entities;
  }

  protected Spawnpoint createSpawnpoint(IMapObject mapObject, Direction direction, String spawnType) {
    return new Spawnpoint(direction, spawnType);
  }
}


text:
import { createToken } from "../../src/scan/tokens_public"
import { EmbeddedActionsParser } from "../../src/parse/parser/traits/parser_traits"
import { createRegularToken } from "../utils/matchers"
import { IToken, TokenType } from "@chevrotain/types"
import { expect } from "chai"

describe("lookahead Regular Tokens Mode", () => {
  let OneTok: TokenType
  let TwoTok: TokenType
  let ThreeTok: TokenType
  let FourTok: TokenType
  let FiveTok: TokenType
  let SixTok: TokenType
  let SevenTok: TokenType
  let EightTok: TokenType
  let NineTok: TokenType
  let TenTok: TokenType
  let Comma: TokenType

  let ALL_TOKENS: TokenType[]

  before(() => {
    OneTok = createToken({ name: "OneTok" })
    TwoTok = createToken({ name: "TwoTok" })
    ThreeTok = createToken({ name: "ThreeTok" })
    FourTok = createToken({ name: "FourTok" })
    FiveTok = createToken({ name: "FiveTok" })
    SixTok = createToken({ name: "SixTok" })
    SevenTok = createToken({ name: "SevenTok" })
    EightTok = createToken({ name: "EightTok" })
    NineTok = createToken({ name: "NineTok" })
    TenTok = createToken({ name: "TenTok" })
    Comma = createToken({ name: "Comma" })

    ALL_TOKENS = [
      OneTok,
      TwoTok,
      ThreeTok,
      FourTok,
      FiveTok,
      SixTok,
      SevenTok,
      EightTok,
      NineTok,
      Comma
    ]
  })

  describe("The implicit lookahead calculation functionality of the Recognizer For OPTION", () => {
    class OptionsImplicitLookAheadParser extends EmbeddedActionsParser {
      constructor(input: IToken[] = []) {
        super(ALL_TOKENS, {})

        this.performSelfAnalysis()
        this.input = input
      }

      public manyOptionsRule = this.RULE(
        "manyOptionsRule",
        this.parseManyOptionsRule
      )

      private parseManyOptionsRule(): string {
        let total = ""

        this.OPTION8(() => {
          this.CONSUME1(OneTok)
          total += "1"
        })

        this.OPTION9(() => {
          this.CONSUME1(TwoTok)
          total += "2"
        })

        this.OPTION3(() => {
          this.CONSUME1(ThreeTok)
          total += "3"
        })

        this.OPTION4(() => {
          this.CONSUME1(FourTok)
          total += "4"
        })

        this.OPTION5(() => {
          this.CONSUME1(FiveTok)
          total += "5"
        })

        this.option(20, () => {
          this.CONSUME1(SixTok)
          total += "6"
        })

        return total
      }
    }

    it("can automatically compute lookahead for OPTION1", () => {
      const input = [createRegularToken(OneTok)]
      const parser = new OptionsImplicitLookAheadParser(input)
      expect(parser.manyOptionsRule()).to.equal("1")
    })

    it("can automatically compute lookahead for OPTION2", () => {
      const input = [createRegularToken(TwoTok)]
      const parser = new OptionsImplicitLookAheadParser(input)
      expect(parser.manyOptionsRule()).to.equal("2")
    })

    it("can automatically compute lookahead for OPTION3", () => {
      const input = [createRegularToken(ThreeTok)]
      const parser = new OptionsImplicitLookAheadParser(input)
      expect(parser.manyOptionsRule()).to.equal("3")
    })

    it("can automatically compute lookahead for OPTION4", () => {
      const input = [createRegularToken(FourTok)]
      const parser = new OptionsImplicitLookAheadParser(input)
      expect(parser.manyOptionsRule()).to.equal("4")
    })

    it("can automatically compute lookahead for OPTION5", () => {
      const input = [createRegularToken(FiveTok)]
      const parser = new OptionsImplicitLookAheadParser(input)
      expect(parser.manyOptionsRule()).to.equal("5")
    })

    it("can automatically compute lookahead for option(idx, ...)", () => {
      const input = [createRegularToken(SixTok)]
      const parser = new OptionsImplicitLookAheadParser(input)
      expect(parser.manyOptionsRule()).to.equal("6")
    })
  })

  describe("The implicit lookahead calculation functionality of the Recognizer For MANY", () => {
    class ManyImplicitLookAheadParser extends EmbeddedActionsParser {
      constructor(input: IToken[] = []) {
        super(ALL_TOKENS, {})

        this.performSelfAnalysis()
        this.input = input
      }

      public manyRule = this.RULE("manyRule", this.parseManyRule)

      private parseManyRule(): string {
        let total = ""

        this.MANY1(() => {
          this.CONSUME1(OneTok)
          total += "1"
        })

        this.MANY2(() => {
          this.CONSUME1(TwoTok)
          total += "2"
        })

        this.MANY3(() => {
          this.CONSUME1(ThreeTok)
          total += "3"
        })

        this.MANY4(() => {
          this.CONSUME1(FourTok)
          total += "4"
        })

        this.MANY5(() => {
          this.CONSUME1(FiveTok)
          total += "5"
        })

        this.MANY6(() => {
          this.CONSUME1(SixTok)
          total += "6"
        })

        this.MANY7(() => {
          this.CONSUME1(SevenTok)
          total += "7"
        })

        this.MANY8(() => {
          this.CONSUME1(EightTok)
          total += "8"
        })

        this.MANY9(() => {
          this.CONSUME1(NineTok)
          total += "9"
        })

        this.many(20, () => {
          this.CONSUME1(TenTok)
          total += "10"
        })

        return total
      }
    }

    it("can automatically compute lookahead for MANY1", () => {
      const input = [createRegularToken(OneTok)]
      const parser = new ManyImplicitLookAheadParser(input)
      expect(parser.manyRule()).to.equal("1")
    })

    it("can automatically compute lookahead for MANY2", () => {
      const input = [createRegularToken(TwoTok)]
      const parser = new ManyImplicitLookAheadParser(input)
      expect(parser.manyRule()).to.equal("2")
    })

    it("can automatically compute lookahead for MANY3", () => {
      const input = [createRegularToken(ThreeTok)]
      const parser = new ManyImplicitLookAheadParser(input)
      expect(parser.manyRule()).to.equal("3")
    })

    it("can automatically compute lookahead for MANY4", () => {
      const input = [createRegularToken(FourTok)]
      const parser = new ManyImplicitLookAheadParser(input)
      expect(parser.manyRule()).to.equal("4")
    })

    it("can automatically compute lookahead for MANY5", () => {
      const input = [createRegularToken(FiveTok)]
      const parser = new ManyImplicitLookAheadParser(input)
      expect(parser.manyRule()).to.equal("5")
    })

    it("can automatically compute lookahead for MANY6", () => {
      const input = [createRegularToken(SixTok)]
      const parser = new ManyImplicitLookAheadParser(input)
      expect(parser.manyRule()).to.equal("6")
    })

    it("can automatically compute lookahead for MANY7", () => {
      const input = [createRegularToken(SevenTok)]
      const parser = new ManyImplicitLookAheadParser(input)
      expect(parser.manyRule()).to.equal("7")
    })

    it("can automatically compute lookahead for MANY8", () => {
      const input = [createRegularToken(EightTok)]
      const parser = new ManyImplicitLookAheadParser(input)
      expect(parser.manyRule()).to.equal("8")
    })

    it("can automatically compute lookahead for MANY9", () => {
      const input = [createRegularToken(NineTok)]
      const parser = new ManyImplicitLookAheadParser(input)
      expect(parser.manyRule()).to.equal("9")
    })

    it("can automatically compute lookahead for many(idx, ...)", () => {
      const input = [createRegularToken(TenTok)]
      const parser = new ManyImplicitLookAheadParser(input)
      expect(parser.manyRule()).to.equal("10")
    })

    it("can accept lookahead function param for flow mixing several MANYs", () => {
      const input = [
        createRegularToken(OneTok),
        createRegularToken(OneTok),
        createRegularToken(ThreeTok),
        createRegularToken(ThreeTok),
        createRegularToken(ThreeTok),
        createRegularToken(FiveTok)
      ]
      const parser = new ManyImplicitLookAheadParser(input)
      expect(parser.manyRule()).to.equal("113335")
    })
  })

  describe("The implicit lookahead calculation functionality of the Recognizer For MANY_SEP", () => {
    class ManySepImplicitLookAheadParser extends EmbeddedActionsParser {
      constructor(input: IToken[] = []) {
        super(ALL_TOKENS, {})

        this.performSelfAnalysis()
        this.input = input
      }

      public manySepRule = this.RULE("manySepRule", this.parseManyRule)

      private parseManyRule(): any {
        let total = ""
        const separators: IToken[] = []

        this.MANY_SEP1({
          SEP: Comma,
          DEF: () => {
            this.CONSUME1(OneTok)
            total += "1"
          }
        })

        this.MANY_SEP2({
          SEP: Comma,
          DEF: () => {
            this.CONSUME1(TwoTok)
            total += "2"
          }
        })

        this.MANY_SEP3({
          SEP: Comma,
          DEF: () => {
            this.CONSUME1(ThreeTok)
            total += "3"
          }
        })

        this.MANY_SEP4({
          SEP: Comma,
          DEF: () => {
            this.CONSUME1(FourTok)
            total += "4"
          }
        })

        this.MANY_SEP5({
          SEP: Comma,
          DEF: () => {
            this.CONSUME1(FiveTok)
            total += "5"
          }
        })

        this.MANY_SEP6({
          SEP: Comma,
          DEF: () => {
            this.CONSUME1(SixTok)
            total += "6"
          }
        })

        this.MANY_SEP7({
          SEP: Comma,
          DEF: () => {
            this.CONSUME1(SevenTok)
            total += "7"
          }
        })

        this.MANY_SEP8({
          SEP: Comma,
          DEF: () => {
            this.CONSUME1(EightTok)
            total += "8"
          }
        })

        this.MANY_SEP9({
          SEP: Comma,
          DEF: () => {
            this.CONSUME1(NineTok)
            total += "9"
          }
        })

        return {
          total: total,
          separators: separators
        }
      }
    }

    it("can automatically compute lookahead for MANY_SEP1", () => {
      const input = [createRegularToken(OneTok)]
      const parser = new ManySepImplicitLookAheadParser(input)
      expect(parser.manySepRule().total).to.equal("1")
    })

    it("can automatically compute lookahead for MANY_SEP2", () => {
      const input = [createRegularToken(TwoTok)]
      const parser = new ManySepImplicitLookAheadParser(input)
      expect(parser.manySepRule().total).to.equal("2")
    })

    it("can automatically compute lookahead for MANY_SEP3", () => {
      const input = [createRegularToken(ThreeTok)]
      const parser = new ManySepImplicitLookAheadParser(input)
      expect(parser.manySepRule().total).to.equal("3")
    })

    it("can automatically compute lookahead for MANY_SEP4", () => {
      const input = [createRegularToken(FourTok)]
      const parser = new ManySepImplicitLookAheadParser(input)
      expect(parser.manySepRule().total).to.equal("4")
    })

    it("can automatically compute lookahead for MANY_SEP5", () => {
      const input = [createRegularToken(FiveTok)]
      const parser = new ManySepImplicitLookAheadParser(input)
      expect(parser.manySepRule().total).to.equal("5")
    })

    it("can automatically compute lookahead for MANY_SEP6", () => {
      const input = [createRegularToken(SixTok)]
      const parser = new ManySepImplicitLookAheadParser(input)
      expect(parser.manySepRule().total).to.equal("6")
    })

    it("can automatically compute lookahead for MANY_SEP7", () => {
      const input = [createRegularToken(SevenTok)]
      const parser = new ManySepImplicitLookAheadParser(input)
      expect(parser.manySepRule().total).to.equal("7")
    })

    it("can automatically compute lookahead for MANY_SEP8", () => {
      const input = [createRegularToken(EightTok)]
      const parser = new ManySepImplicitLookAheadParser(input)
      expect(parser.manySepRule().total).to.equal("8")
    })

    it("can automatically compute lookahead for MANY_SEP9", () => {
      const input = [createRegularToken(NineTok)]
      const parser = new ManySepImplicitLookAheadParser(input)
      expect(parser.manySepRule().total).to.equal("9")
    })

    it("can accept lookahead function param for flow mixing several MANY_SEPs", () => {
      const input = [
        createRegularToken(OneTok),
        createRegularToken(Comma),
        createRegularToken(OneTok),
        createRegularToken(ThreeTok),
        createRegularToken(Comma),
        createRegularToken(ThreeTok),
        createRegularToken(Comma),
        createRegularToken(ThreeTok),
        createRegularToken(FiveTok)
      ]
      const parser = new ManySepImplicitLookAheadParser(input)
      const result = parser.manySepRule()
      expect(result.total).to.equal("113335")
    })
  })

  describe("The implicit lookahead calculation functionality of the Recognizer For AT_LEAST_ONE", () => {
    class AtLeastOneImplicitLookAheadParser extends EmbeddedActionsParser {
      constructor(input: IToken[] = []) {
        super(ALL_TOKENS, {})

        this.performSelfAnalysis()
        this.input = input
      }

      public atLeastOneRule = this.RULE(
        "atLeastOneRule",
        this.parseAtLeastOneRule,
        {
          recoveryValueFunc: () => {
            return "-666"
          }
        }
      )

      private parseAtLeastOneRule(): string {
        let total = ""

        this.AT_LEAST_ONE1(() => {
          this.CONSUME1(OneTok)
          total += "1"
        })

        this.AT_LEAST_ONE2(() => {
          this.CONSUME1(TwoTok)
          total += "2"
        })

        this.AT_LEAST_ONE3(() => {
          this.CONSUME1(ThreeTok)
          total += "3"
        })

        this.AT_LEAST_ONE4(() => {
          this.CONSUME1(FourTok)
          total += "4"
        })

        this.AT_LEAST_ONE5(() => {
          this.CONSUME1(FiveTok)
          total += "5"
        })

        this.AT_LEAST_ONE6(() => {
          this.CONSUME1(SixTok)
          total += "6"
        })

        this.AT_LEAST_ONE7(() => {
          this.CONSUME1(SevenTok)
          total += "7"
        })

        this.AT_LEAST_ONE8(() => {
          this.CONSUME1(EightTok)
          total += "8"
        })

        this.AT_LEAST_ONE9(() => {
          this.CONSUME1(NineTok)
          total += "9"
        })

        this.atLeastOne(32, () => {
          this.CONSUME1(TenTok)
          total += "10"
        })

        return total
      }
    }

    it("can accept lookahead function param for AT_LEAST_ONE", () => {
      const input = [
        createRegularToken(OneTok),
        createRegularToken(TwoTok),
        createRegularToken(TwoTok),
        createRegularToken(ThreeTok),
        createRegularToken(FourTok),
        createRegularToken(FourTok),
        createRegularToken(FiveTok),
        createRegularToken(SixTok),
        createRegularToken(SevenTok),
        createRegularToken(EightTok),
        createRegularToken(EightTok),
        createRegularToken(EightTok),
        createRegularToken(NineTok),
        createRegularToken(TenTok)
      ]
      const parser = new AtLeastOneImplicitLookAheadParser(input)
      expect(parser.atLeastOneRule()).to.equal("122344567888910")
    })

    it("will fail when zero occurrences of AT_LEAST_ONE in input", () => {
      const input = [
        createRegularToken(OneTok),
        createRegularToken(TwoTok) /*createToken(ThreeTok),*/,
        createRegularToken(FourTok),
        createRegularToken(FiveTok)
      ]
      const parser = new AtLeastOneImplicitLookAheadParser(input)
      expect(parser.atLeastOneRule()).to.equal("-666")
    })
  })

  describe("The implicit lookahead calculation functionality of the Recognizer For AT_LEAST_ONE_SEP", () => {
    class AtLeastOneSepImplicitLookAheadParser extends EmbeddedActionsParser {
      constructor(input: IToken[] = []) {
        super(ALL_TOKENS, {})

        this.performSelfAnalysis()
        this.input = input
      }

      public atLeastOneSepRule = this.RULE(
        "atLeastOneSepRule",
        this.parseAtLeastOneRule,
        {
          recoveryValueFunc: () => {
            return {
              total: "-666",
              separators: []
            }
          }
        }
      )

      private parseAtLeastOneRule(): any {
        let total = ""
        const separators: IToken[] = []

        this.AT_LEAST_ONE_SEP1({
          SEP: Comma,
          DEF: () => {
            this.CONSUME1(OneTok)
            total += "1"
          }
        })

        this.AT_LEAST_ONE_SEP2({
          SEP: Comma,
          DEF: () => {
            this.CONSUME1(TwoTok)
            total += "2"
          }
        })

        this.AT_LEAST_ONE_SEP3({
          SEP: Comma,
          DEF: () => {
            this.CONSUME1(ThreeTok)
            total += "3"
          }
        })

        this.AT_LEAST_ONE_SEP4({
          SEP: Comma,
          DEF: () => {
            this.CONSUME1(FourTok)
            total += "4"
          }
        })

        this.AT_LEAST_ONE_SEP5({
          SEP: Comma,
          DEF: () => {
            this.consume(72, FiveTok)
            total += "5"
          }
        })

        this.AT_LEAST_ONE_SEP6({
          SEP: Comma,
          DEF: () => {
            this.CONSUME1(SixTok)
            total += "6"
          }
        })

        this.AT_LEAST_ONE_SEP7({
          SEP: Comma,
          DEF: () => {
            this.CONSUME1(SevenTok)
            total += "7"
          }
        })

        this.AT_LEAST_ONE_SEP8({
          SEP: Comma,
          DEF: () => {
            this.CONSUME1(EightTok)
            total += "8"
          }
        })

        this.AT_LEAST_ONE_SEP9({
          SEP: Comma,
          DEF: () => {
            this.CONSUME1(NineTok)
            total += "9"
          }
        })

        return {
          total: total,
          separators: separators
        }
      }
    }

    it("can accept lookahead function param for AT_LEAST_ONE_SEP", () => {
      const input = [
        createRegularToken(OneTok),
        createRegularToken(TwoTok),
        createRegularToken(Comma),
        createRegularToken(TwoTok),
        createRegularToken(ThreeTok),
        createRegularToken(FourTok),
        createRegularToken(Comma),
        createRegularToken(FourTok),
        createRegularToken(FiveTok),
        createRegularToken(SixTok),
        createRegularToken(SevenTok),
        createRegularToken(Comma),
        createRegularToken(SevenTok),
        createRegularToken(Comma),
        createRegularToken(SevenTok),
        createRegularToken(EightTok),
        createRegularToken(NineTok)
      ]
      const parser = new AtLeastOneSepImplicitLookAheadParser(input)
      const parseResult = parser.atLeastOneSepRule()
      expect(parseResult.total).to.equal("1223445677789")
    })

    it("will fail when zero occurrences of AT_LEAST_ONE_SEP in input", () => {
      const input = [
        createRegularToken(OneTok),
        createRegularToken(TwoTok),
        /*createToken(ThreeTok),*/ createRegularToken(FourTok),
        createRegularToken(FiveTok)
      ]
      const parser = new AtLeastOneSepImplicitLookAheadParser(input)
      expect(parser.atLeastOneSepRule().total).to.equal("-666")
    })
  })

  describe("The implicit lookahead calculation functionality of the Recognizer For OR", () => {
    class OrImplicitLookAheadParser extends EmbeddedActionsParser {
      constructor(input: IToken[] = []) {
        super(ALL_TOKENS, {})

        this.performSelfAnalysis()
        this.input = input
      }

      public orRule = this.RULE("orRule", this.parseOrRule, {
        recoveryValueFunc: () => "-666"
      })

      private parseOrRule(): string {
        let total = ""

        this.OR8([
          {
            ALT: () => {
              this.CONSUME1(OneTok)
              total += "A1"
            }
          },
          {
            ALT: () => {
              this.CONSUME1(TwoTok)
              total += "A2"
            }
          },
          {
            ALT: () => {
              this.CONSUME1(ThreeTok)
              total += "A3"
            }
          },
          {
            ALT: () => {
              this.CONSUME1(FourTok)
              total += "A4"
            }
          },
          {
            ALT: () => {
              this.CONSUME1(FiveTok)
              total += "A5"
            }
          }
        ])

        this.OR2([
          {
            ALT: () => {
              this.CONSUME2(OneTok)
              total += "B1"
            }
          },
          {
            ALT: () => {
              this.CONSUME2(FourTok)
              total += "B4"
            }
          },
          {
            ALT: () => {
              this.CONSUME2(ThreeTok)
              total += "B3"
            }
          },
          {
            ALT: () => {
              this.CONSUME2(TwoTok)
              total += "B2"
            }
          },
          {
            ALT: () => {
              this.CONSUME2(FiveTok)
              total += "B5"
            }
          }
        ])

        this.OR3([
          {
            ALT: () => {
              this.CONSUME3(TwoTok)
              total += "C2"
            }
          },
          {
            ALT: () => {
              this.CONSUME3(FourTok)
              total += "C4"
            }
          },
          {
            ALT: () => {
              this.CONSUME3(ThreeTok)
              total += "C3"
            }
          },
          {
            ALT: () => {
              this.CONSUME3(FiveTok)
              total += "C5"
            }
          },
          {
            ALT: () => {
              this.CONSUME3(OneTok)
              total += "C1"
            }
          }
        ])

        this.OR4([
          {
            ALT: () => {
              this.CONSUME4(OneTok)
              total += "D1"
            }
          },
          {
            ALT: () => {
              this.CONSUME4(ThreeTok)
              total += "D3"
            }
          },
          {
            ALT: () => {
              this.CONSUME4(FourTok)
              total += "D4"
            }
          },
          {
            ALT: () => {
              this.CONSUME4(TwoTok)
              total += "D2"
            }
          },
          {
            ALT: () => {
              this.CONSUME4(FiveTok)
              total += "D5"
            }
          }
        ])

        this.OR5([
          {
            ALT: () => {
              this.CONSUME5(TwoTok)
              total += "E2"
            }
          },
          {
            ALT: () => {
              this.CONSUME5(OneTok)
              total += "E1"
            }
          },
          {
            ALT: () => {
              this.CONSUME5(FourTok)
              total += "E4"
            }
          },
          {
            ALT: () => {
              this.CONSUME5(ThreeTok)
              total += "E3"
            }
          },
          {
            ALT: () => {
              this.CONSUME5(FiveTok)
              total += "E5"
            }
          }
        ])

        this.or(45, [
          {
            ALT: () => {
              this.CONSUME6(TwoTok)
              total += "F2"
            }
          },
          {
            ALT: () => {
              this.CONSUME6(OneTok)
              total += "F1"
            }
          },
          {
            ALT: () => {
              this.CONSUME6(ThreeTok)
              total += "F3"
            }
          },
          {
            ALT: () => {
              this.CONSUME6(FourTok)
              total += "F4"
            }
          },
          {
            ALT: () => {
              this.consume(66, FiveTok)
              total += "F5"
            }
          }
        ])

        return total
      }
    }

    it("can compute the lookahead automatically for OR", () => {
      const input = [
        createRegularToken(OneTok),
        createRegularToken(TwoTok),
        createRegularToken(ThreeTok),
        createRegularToken(FourTok),
        createRegularToken(FiveTok),
        createRegularToken(ThreeTok)
      ]
      const parser = new OrImplicitLookAheadParser(input)
      expect(parser.orRule()).to.equal("A1B2C3D4E5F3")
    })

    it("will fail when none of the alternatives match", () => {
      const input = [createRegularToken(SixTok)]
      const parser = new OrImplicitLookAheadParser(input)
      expect(parser.orRule()).to.equal("-666")
    })
  })

  describe("OR production ambiguity detection when using implicit lookahead calculation", () => {
    it("will throw an error when two alternatives have the same single token (lookahead 1) prefix", () => {
      class OrAmbiguityLookAheadParser extends EmbeddedActionsParser {
        constructor(input: IToken[] = []) {
          super(ALL_TOKENS, {})

          this.performSelfAnalysis()
          this.input = input
        }

        public ambiguityRule = this.RULE(
          "ambiguityRule",
          this.parseAmbiguityRule
        )

        private parseAmbiguityRule(): void {
          this.OR1([
            {
              ALT: () => {
                this.CONSUME1(OneTok)
              }
            },
            // <-- this alternative starts with the same token as the previous one, ambiguity!
            {
              ALT: () => {
                this.CONSUME2(OneTok)
              }
            },
            {
              ALT: () => {
                this.CONSUME2(TwoTok)
              }
            },
            {
              ALT: () => {
                this.CONSUME2(ThreeTok)
              }
            }
          ])
        }
      }

      expect(() => new OrAmbiguityLookAheadParser()).to.throw(
        "Ambiguous Alternatives Detected:"
      )
      expect(() => new OrAmbiguityLookAheadParser()).to.throw("OneTok")
    })

    it("will throw an error when two alternatives have the same multi token (lookahead > 1) prefix", () => {
      class OrAmbiguityMultiTokenLookAheadParser extends EmbeddedActionsParser {
        constructor(input: IToken[] = []) {
          super(ALL_TOKENS, {})

          this.performSelfAnalysis()
          this.input = input
        }

        public ambiguityRule = this.RULE(
          "ambiguityRule",
          this.parseAmbiguityRule
        )

        private parseAmbiguityRule(): void {
          this.OR1([
            {
              ALT: () => {
                this.CONSUME1(OneTok)
              }
            },
            {
              ALT: () => {
                this.CONSUME1(TwoTok)
                this.CONSUME1(ThreeTok)
                this.CONSUME1(FourTok)
              }
            },
            {
              ALT: () => {
                this.CONSUME2(TwoTok)
                this.CONSUME2(ThreeTok)
                this.CONSUME2(FourTok)
              }
            }
          ])
        }
      }
      expect(() => new OrAmbiguityMultiTokenLookAheadParser()).to.throw(
        "Ambiguous Alternatives Detected:"
      )
      expect(() => new OrAmbiguityMultiTokenLookAheadParser()).to.throw(
        "TwoTok, ThreeTok, FourTok"
      )
    })
  })

  describe("The implicit lookahead calculation functionality of the Recognizer For OR (with IGNORE_AMBIGUITIES)", () => {
    class OrImplicitLookAheadParserIgnoreAmbiguities extends EmbeddedActionsParser {
      constructor(input: IToken[] = []) {
        super(ALL_TOKENS, {})

        this.performSelfAnalysis()
        this.input = input
      }

      public orRule = this.RULE("orRule", this.parseOrRule, {
        recoveryValueFunc: () => "-666"
      })

      private parseOrRule(): string {
        let total = ""

        this.OR({
          IGNORE_AMBIGUITIES: true,
          DEF: [
            {
              ALT: () => {
                this.CONSUME1(OneTok)
                total += "A1"
              }
            },
            {
              ALT: () => {
                this.CONSUME2(OneTok)
                total += "OOPS!"
              }
            },
            {
              ALT: () => {
                this.CONSUME1(ThreeTok)
                total += "A3"
              }
            },
            {
              ALT: () => {
                this.CONSUME1(FourTok)
                total += "A4"
              }
            },
            {
              ALT: () => {
                this.CONSUME1(FiveTok)
                total += "A5"
              }
            }
          ]
        })

        this.OR2({
          IGNORE_AMBIGUITIES: true,
          DEF: [
            {
              ALT: () => {
                this.CONSUME2(FourTok)
                total += "B4"
              }
            },
            {
              ALT: () => {
                this.CONSUME2(ThreeTok)
                total += "B3"
              }
            },
            {
              ALT: () => {
                this.CONSUME2(TwoTok)
                total += "B2"
              }
            },
            {
              ALT: () => {
                this.CONSUME3(TwoTok)
                total += "OOPS!"
              }
            },
            {
              ALT: () => {
                this.CONSUME2(FiveTok)
                total += "B5"
              }
            }
          ]
        })

        this.OR3({
          IGNORE_AMBIGUITIES: true,
          DEF: [
            {
              ALT: () => {
                this.CONSUME3(FourTok)
                total += "C4"
              }
            },
            {
              ALT: () => {
                this.CONSUME3(ThreeTok)
                total += "C3"
              }
            },
            {
              ALT: () => {
                this.CONSUME4(ThreeTok)
                total += "OOPS!"
              }
            },
            {
              ALT: () => {
                this.CONSUME3(FiveTok)
                total += "C5"
              }
            },
            {
              ALT: () => {
                this.CONSUME3(OneTok)
                total += "C1"
              }
            }
          ]
        })

        this.OR4({
          IGNORE_AMBIGUITIES: true,
          DEF: [
            {
              ALT: () => {
                this.CONSUME4(OneTok)
                total += "D1"
              }
            },
            {
              ALT: () => {
                this.CONSUME4(FourTok)
                total += "D4"
              }
            },
            {
              ALT: () => {
                this.CONSUME5(FourTok)
                total += "OOPS!"
              }
            },
            {
              ALT: () => {
                this.CONSUME4(TwoTok)
                total += "D2"
              }
            }
          ]
        })

        this.OR5({
          IGNORE_AMBIGUITIES: true,
          DEF: [
            {
              ALT: () => {
                this.CONSUME5(TwoTok)
                total += "E2"
              }
            },
            {
              ALT: () => {
                this.CONSUME5(OneTok)
                total += "E1"
              }
            },
            {
              ALT: () => {
                this.CONSUME4(FiveTok)
                total += "E5"
              }
            },
            {
              ALT: () => {
                this.CONSUME5(ThreeTok)
                total += "E3"
              }
            },
            {
              ALT: () => {
                this.CONSUME5(FiveTok)
                total += "OOPS!"
              }
            }
          ]
        })

        return total
      }
    }

    it("can compute the lookahead automatically for OR", () => {
      const input = [
        createRegularToken(OneTok),
        createRegularToken(TwoTok),
        createRegularToken(ThreeTok),
        createRegularToken(FourTok),
        createRegularToken(FiveTok)
      ]
      const parser = new OrImplicitLookAheadParserIgnoreAmbiguities(input)
      expect(parser.orRule()).to.equal("A1B2C3D4E5")
    })

    it("will fail when none of the alternatives match", () => {
      const input = [createRegularToken(SixTok)]
      const parser = new OrImplicitLookAheadParserIgnoreAmbiguities(input)
      expect(parser.orRule()).to.equal("-666")
    })
  })

  describe("The support for MultiToken (K>1) implicit lookahead capabilities in DSL Production:", () => {
    it("OPTION", () => {
      class MultiTokenLookAheadForOptionParser extends EmbeddedActionsParser {
        constructor(input: IToken[] = []) {
          super(ALL_TOKENS, {})

          this.performSelfAnalysis()
          this.input = input
        }

        public rule = this.RULE("rule", () => {
          let result = "OPTION Not Taken"
          this.OPTION2(() => {
            this.CONSUME1(OneTok)
            this.CONSUME1(TwoTok)
            this.CONSUME1(ThreeTok)
            result = "OPTION Taken"
          })
          this.CONSUME2(OneTok)
          this.CONSUME2(TwoTok)
          return result
        })
      }

      const parser = new MultiTokenLookAheadForOptionParser([
        createRegularToken(OneTok),
        createRegularToken(TwoTok)
      ])
      expect(parser.rule()).to.equal("OPTION Not Taken")

      const parser2 = new MultiTokenLookAheadForOptionParser([
        createRegularToken(OneTok),
        createRegularToken(TwoTok),
        createRegularToken(ThreeTok),
        createRegularToken(OneTok),
        createRegularToken(TwoTok)
      ])
      expect(parser2.rule()).to.equal("OPTION Taken")
    })

    it("MANY", () => {
      class MultiTokenLookAheadForManyParser extends EmbeddedActionsParser {
        constructor(input: IToken[] = []) {
          super(ALL_TOKENS, {})

          this.performSelfAnalysis()
          this.input = input
        }

        public rule = this.RULE("orRule", () => {
          let numOfIterations = 0
          this.MANY(() => {
            this.CONSUME1(OneTok)
            this.CONSUME1(TwoTok)
            this.CONSUME1(ThreeTok)
            numOfIterations++
          })
          this.CONSUME2(OneTok)
          this.CONSUME2(TwoTok)
          return numOfIterations
        })
      }

      const parser = new MultiTokenLookAheadForManyParser([
        createRegularToken(OneTok),
        createRegularToken(TwoTok)
      ])
      expect(parser.rule()).to.equal(0)

      const oneIterationParser = new MultiTokenLookAheadForManyParser([
        createRegularToken(OneTok),
        createRegularToken(TwoTok),
        createRegularToken(ThreeTok),
        createRegularToken(OneTok),
        createRegularToken(TwoTok)
      ])
      expect(oneIterationParser.rule()).to.equal(1)

      const twoIterationsParser = new MultiTokenLookAheadForManyParser([
        createRegularToken(OneTok),
        createRegularToken(TwoTok),
        createRegularToken(ThreeTok),
        createRegularToken(OneTok),
        createRegularToken(TwoTok),
        createRegularToken(ThreeTok),
        createRegularToken(OneTok),
        createRegularToken(TwoTok)
      ])

      expect(twoIterationsParser.rule()).to.equal(2)
    })

    it("MANY_SEP", () => {
      class MultiTokenLookAheadForManySepParser extends EmbeddedActionsParser {
        constructor(input: IToken[] = []) {
          super(ALL_TOKENS, {})

          this.performSelfAnalysis()
          this.input = input
        }

        public rule = this.RULE("orRule", () => {
          let numOfIterations = 0
          this.MANY_SEP({
            SEP: Comma,
            DEF: () => {
              this.CONSUME1(OneTok)
              this.CONSUME1(TwoTok)
              this.CONSUME1(ThreeTok)
              numOfIterations++
            }
          })
          this.CONSUME2(OneTok)
          this.CONSUME2(TwoTok)
          return numOfIterations
        })
      }

      const parser = new MultiTokenLookAheadForManySepParser([
        createRegularToken(OneTok),
        createRegularToken(TwoTok)
      ])
      expect(parser.rule()).to.equal(0)

      const oneIterationParser = new MultiTokenLookAheadForManySepParser([
        createRegularToken(OneTok),
        createRegularToken(TwoTok),
        createRegularToken(ThreeTok),
        createRegularToken(OneTok),
        createRegularToken(TwoTok)
      ])
      expect(oneIterationParser.rule()).to.equal(1)

      const twoIterationsParser = new MultiTokenLookAheadForManySepParser([
        createRegularToken(OneTok),
        createRegularToken(TwoTok),
        createRegularToken(ThreeTok),
        createRegularToken(Comma),
        createRegularToken(OneTok),
        createRegularToken(TwoTok),
        createRegularToken(ThreeTok),
        createRegularToken(OneTok),
        createRegularToken(TwoTok)
      ])
      expect(twoIterationsParser.rule()).to.equal(2)
    })

    it("OR", () => {
      class MultiTokenLookAheadForOrParser extends EmbeddedActionsParser {
        constructor(input: IToken[] = []) {
          super(ALL_TOKENS, {})

          this.performSelfAnalysis()
          this.input = input
        }

        public orRule = this.RULE("orRule", () => {
          return this.OR([
            {
              ALT: () => {
                this.CONSUME1(OneTok)
                this.CONSUME2(OneTok)
                return "alt1 Taken"
              }
            },
            {
              ALT: () => {
                this.CONSUME3(OneTok)
                this.CONSUME1(TwoTok)
                this.CONSUME1(ThreeTok)
                return "alt2 Taken"
              }
            },
            {
              ALT: () => {
                this.CONSUME4(OneTok)
                this.CONSUME2(TwoTok)
                return "alt3 Taken"
              }
            },
            {
              ALT: () => {
                this.CONSUME1(FourTok)
                return "alt4 Taken"
              }
            }
          ])
        })
      }

      const alt1Parser = new MultiTokenLookAheadForOrParser([
        createRegularToken(OneTok),
        createRegularToken(OneTok)
      ])
      expect(alt1Parser.orRule()).to.equal("alt1 Taken")

      const alt2Parser = new MultiTokenLookAheadForOrParser([
        createRegularToken(OneTok),
        createRegularToken(TwoTok),
        createRegularToken(ThreeTok)
      ])
      expect(alt2Parser.orRule()).to.equal("alt2 Taken")

      const alt3Parser = new MultiTokenLookAheadForOrParser([
        createRegularToken(OneTok),
        createRegularToken(TwoTok)
      ])
      expect(alt3Parser.orRule()).to.equal("alt3 Taken")

      const alt4Parser = new MultiTokenLookAheadForOrParser([
        createRegularToken(FourTok)
      ])
      expect(alt4Parser.orRule()).to.equal("alt4 Taken")
    })

    it("AT_LEAST_ONE", () => {
      class MultiTokenLookAheadForAtLeastOneParser extends EmbeddedActionsParser {
        constructor(input: IToken[] = []) {
          super(ALL_TOKENS, {})

          this.performSelfAnalysis()
          this.input = input
        }

        public rule = this.RULE("orRule", () => {
          let numOfIterations = 0
          this.AT_LEAST_ONE(() => {
            this.CONSUME1(OneTok)
            this.CONSUME1(TwoTok)
            this.CONSUME1(ThreeTok)
            numOfIterations++
          })
          this.CONSUME2(OneTok)
          this.CONSUME2(TwoTok)
          return numOfIterations
        })
      }

      const oneIterationParser = new MultiTokenLookAheadForAtLeastOneParser([
        createRegularToken(OneTok),
        createRegularToken(TwoTok),
        createRegularToken(ThreeTok),
        createRegularToken(OneTok),
        createRegularToken(TwoTok)
      ])
      expect(oneIterationParser.rule()).to.equal(1)

      const twoIterationsParser = new MultiTokenLookAheadForAtLeastOneParser([
        createRegularToken(OneTok),
        createRegularToken(TwoTok),
        createRegularToken(ThreeTok),
        createRegularToken(OneTok),
        createRegularToken(TwoTok),
        createRegularToken(ThreeTok),
        createRegularToken(OneTok),
        createRegularToken(TwoTok)
      ])

      expect(twoIterationsParser.rule()).to.equal(2)

      const threeIterationsParser = new MultiTokenLookAheadForAtLeastOneParser([
        createRegularToken(OneTok),
        createRegularToken(TwoTok),
        createRegularToken(ThreeTok),
        createRegularToken(OneTok),
        createRegularToken(TwoTok),
        createRegularToken(ThreeTok),
        createRegularToken(OneTok),
        createRegularToken(TwoTok),
        createRegularToken(ThreeTok),
        createRegularToken(OneTok),
        createRegularToken(TwoTok)
      ])

      expect(threeIterationsParser.rule()).to.equal(3)
    })

    it("AT_LEAST_ONE_SEP", () => {
      class MultiTokenLookAheadForAtLeastOneSepParser extends EmbeddedActionsParser {
        constructor(input: IToken[] = []) {
          super(ALL_TOKENS, {})

          this.performSelfAnalysis()
          this.input = input
        }

        public rule = this.RULE("orRule", () => {
          let numOfIterations = 0
          this.AT_LEAST_ONE_SEP({
            SEP: Comma,
            DEF: () => {
              this.CONSUME1(OneTok)
              this.CONSUME1(TwoTok)
              this.CONSUME1(ThreeTok)
              numOfIterations++
            }
          })
          this.CONSUME2(OneTok)
          this.CONSUME2(TwoTok)
          return numOfIterations
        })
      }

      const oneIterationParser = new MultiTokenLookAheadForAtLeastOneSepParser([
        createRegularToken(OneTok),
        createRegularToken(TwoTok),
        createRegularToken(ThreeTok),
        createRegularToken(OneTok),
        createRegularToken(TwoTok)
      ])
      expect(oneIterationParser.rule()).to.equal(1)

      const twoIterationsParser = new MultiTokenLookAheadForAtLeastOneSepParser(
        [
          createRegularToken(OneTok),
          createRegularToken(TwoTok),
          createRegularToken(ThreeTok),
          createRegularToken(Comma),
          createRegularToken(OneTok),
          createRegularToken(TwoTok),
          createRegularToken(ThreeTok),
          createRegularToken(OneTok),
          createRegularToken(TwoTok)
        ]
      )
      expect(twoIterationsParser.rule()).to.equal(2)

      const threeIterationsParser =
        new MultiTokenLookAheadForAtLeastOneSepParser([
          createRegularToken(OneTok),
          createRegularToken(TwoTok),
          createRegularToken(ThreeTok),
          createRegularToken(Comma),
          createRegularToken(OneTok),
          createRegularToken(TwoTok),
          createRegularToken(ThreeTok),
          createRegularToken(Comma),
          createRegularToken(OneTok),
          createRegularToken(TwoTok),
          createRegularToken(ThreeTok),
          createRegularToken(OneTok),
          createRegularToken(TwoTok)
        ])
      expect(threeIterationsParser.rule()).to.equal(3)
    })
  })

  describe("The support for MultiToken (K>1) EXPLICIT lookahead capabilities in DSL Production:", () => {
    it("OPTION", () => {
      class MultiTokenLookAheadForOptionParser extends EmbeddedActionsParser {
        constructor(input: IToken[] = []) {
          super(ALL_TOKENS, {})

          this.performSelfAnalysis()
          this.input = input
        }

        public rule = this.RULE("rule", () => {
          let result = "OPTION Not Taken"
          this.OPTION2({
            // will only consider the OneTok when evaluating entering the OPTION
            MAX_LOOKAHEAD: 1,
            DEF: () => {
              this.CONSUME1(OneTok)
              this.CONSUME1(ThreeTok)
              result = "OPTION Taken"
            }
          })
          this.CONSUME2(OneTok)
          this.CONSUME2(TwoTok)
          return result
        })
      }

      const parser = new MultiTokenLookAheadForOptionParser([
        createRegularToken(OneTok),
        createRegularToken(TwoTok)
      ])
      const parseResult = parser.rule()
      expect(parseResult).to.be.undefined
      expect(parser.errors.length).to.eql(1)
      // wrong path chosen due to low explicit lookahead
      expect(parser.errors[0].message).to.include(
        "Expecting token of type --> ThreeTok <--"
      )
    })

    it("MANY", () => {
      class MultiTokenLookAheadForManyParser extends EmbeddedActionsParser {
        constructor(input: IToken[] = []) {
          super(ALL_TOKENS, {
            // Global Low maxLookahead
            maxLookahead: 1
          })

          this.performSelfAnalysis()
          this.input = input
        }

        public rule = this.RULE("orRule", () => {
          let numOfIterations = 0
          this.MANY({
            // Increase lookahead for this specific DSL method
            MAX_LOOKAHEAD: 3,
            DEF: () => {
              this.CONSUME1(OneTok)
              this.CONSUME1(TwoTok)
              this.CONSUME1(ThreeTok)
              numOfIterations++
            }
          })
          this.CONSUME2(OneTok)
          this.CONSUME2(TwoTok)
          return numOfIterations
        })
      }

      const parser = new MultiTokenLookAheadForManyParser([
        createRegularToken(OneTok),
        createRegularToken(TwoTok)
      ])
      expect(parser.rule()).to.equal(0)

      const oneIterationParser = new MultiTokenLookAheadForManyParser([
        createRegularToken(OneTok),
        createRegularToken(TwoTok),
        createRegularToken(ThreeTok),
        createRegularToken(OneTok),
        createRegularToken(TwoTok)
      ])
      expect(oneIterationParser.rule()).to.equal(1)

      const twoIterationsParser = new MultiTokenLookAheadForManyParser([
        createRegularToken(OneTok),
        createRegularToken(TwoTok),
        createRegularToken(ThreeTok),
        createRegularToken(OneTok),
        createRegularToken(TwoTok),
        createRegularToken(ThreeTok),
        createRegularToken(OneTok),
        createRegularToken(TwoTok)
      ])

      expect(twoIterationsParser.rule()).to.equal(2)
    })

    it("MANY_SEP", () => {
      class MultiTokenLookAheadForManySepParser extends EmbeddedActionsParser {
        constructor(input: IToken[] = []) {
          super(ALL_TOKENS, { maxLookahead: 1 })

          this.performSelfAnalysis()
          this.input = input
        }

        public rule = this.RULE("orRule", () => {
          let numOfIterations = 0
          this.MANY_SEP({
            MAX_LOOKAHEAD: 3,
            SEP: Comma,
            DEF: () => {
              this.CONSUME1(OneTok)
              this.CONSUME1(TwoTok)
              this.CONSUME1(ThreeTok)
              numOfIterations++
            }
          })
          this.CONSUME2(OneTok)
          this.CONSUME2(TwoTok)
          return numOfIterations
        })
      }

      const parser = new MultiTokenLookAheadForManySepParser([
        createRegularToken(OneTok),
        createRegularToken(TwoTok)
      ])
      expect(parser.rule()).to.equal(0)

      const oneIterationParser = new MultiTokenLookAheadForManySepParser([
        createRegularToken(OneTok),
        createRegularToken(TwoTok),
        createRegularToken(ThreeTok),
        createRegularToken(OneTok),
        createRegularToken(TwoTok)
      ])
      expect(oneIterationParser.rule()).to.equal(1)

      const twoIterationsParser = new MultiTokenLookAheadForManySepParser([
        createRegularToken(OneTok),
        createRegularToken(TwoTok),
        createRegularToken(ThreeTok),
        createRegularToken(Comma),
        createRegularToken(OneTok),
        createRegularToken(TwoTok),
        createRegularToken(ThreeTok),
        createRegularToken(OneTok),
        createRegularToken(TwoTok)
      ])
      expect(twoIterationsParser.rule()).to.equal(2)
    })

    it("OR", () => {
      class MultiTokenLookAheadForOrParser extends EmbeddedActionsParser {
        constructor(input: IToken[] = []) {
          super(ALL_TOKENS, {
            // Global low maxLookahead should cause ambiguities in this grammar
            maxLookahead: 1
          })

          this.performSelfAnalysis()
          this.input = input
        }

        public orRule = this.RULE("orRule", () => {
          return this.OR({
            // explicit higher maxLookahead is used to resolve the ambiguities
            MAX_LOOKAHEAD: 3,
            DEF: [
              {
                ALT: () => {
                  this.CONSUME1(OneTok)
                  this.CONSUME2(OneTok)
                  return "alt1 Taken"
                }
              },
              {
                ALT: () => {
                  this.CONSUME3(OneTok)
                  this.CONSUME1(TwoTok)
                  this.CONSUME1(ThreeTok)
                  return "alt2 Taken"
                }
              },
              {
                ALT: () => {
                  this.CONSUME4(OneTok)
                  this.CONSUME2(TwoTok)
                  return "alt3 Taken"
                }
              },
              {
                ALT: () => {
                  this.CONSUME1(FourTok)
                  return "alt4 Taken"
                }
              }
            ]
          })
        })
      }

      // let alt1Parser = new MultiTokenLookAheadForOrParser([
      //     createRegularToken(OneTok),
      //     createRegularToken(OneTok)
      // ])
      // expect(alt1Parser.orRule()).to.equal("alt1 Taken")

      const alt2Parser = new MultiTokenLookAheadForOrParser([
        createRegularToken(OneTok),
        createRegularToken(TwoTok),
        createRegularToken(ThreeTok)
      ])
      expect(alt2Parser.orRule()).to.equal("alt2 Taken")

      const alt3Parser = new MultiTokenLookAheadForOrParser([
        createRegularToken(OneTok),
        createRegularToken(TwoTok)
      ])
      expect(alt3Parser.orRule()).to.equal("alt3 Taken")

      const alt4Parser = new MultiTokenLookAheadForOrParser([
        createRegularToken(FourTok)
      ])
      expect(alt4Parser.orRule()).to.equal("alt4 Taken")
    })

    it("AT_LEAST_ONE", () => {
      class MultiTokenLookAheadForAtLeastOneParser extends EmbeddedActionsParser {
        constructor(input: IToken[] = []) {
          super(ALL_TOKENS, { maxLookahead: 1 })

          this.performSelfAnalysis()
          this.input = input
        }

        public rule = this.RULE("orRule", () => {
          let numOfIterations = 0
          this.AT_LEAST_ONE({
            MAX_LOOKAHEAD: 3,
            DEF: () => {
              this.CONSUME1(OneTok)
              this.CONSUME1(TwoTok)
              this.CONSUME1(ThreeTok)
              numOfIterations++
            }
          })
          this.CONSUME2(OneTok)
          this.CONSUME2(TwoTok)
          return numOfIterations
        })
      }

      const oneIterationParser = new MultiTokenLookAheadForAtLeastOneParser([
        createRegularToken(OneTok),
        createRegularToken(TwoTok),
        createRegularToken(ThreeTok),
        createRegularToken(OneTok),
        createRegularToken(TwoTok)
      ])
      expect(oneIterationParser.rule()).to.equal(1)

      const twoIterationsParser = new MultiTokenLookAheadForAtLeastOneParser([
        createRegularToken(OneTok),
        createRegularToken(TwoTok),
        createRegularToken(ThreeTok),
        createRegularToken(OneTok),
        createRegularToken(TwoTok),
        createRegularToken(ThreeTok),
        createRegularToken(OneTok),
        createRegularToken(TwoTok)
      ])

      expect(twoIterationsParser.rule()).to.equal(2)

      const threeIterationsParser = new MultiTokenLookAheadForAtLeastOneParser([
        createRegularToken(OneTok),
        createRegularToken(TwoTok),
        createRegularToken(ThreeTok),
        createRegularToken(OneTok),
        createRegularToken(TwoTok),
        createRegularToken(ThreeTok),
        createRegularToken(OneTok),
        createRegularToken(TwoTok),
        createRegularToken(ThreeTok),
        createRegularToken(OneTok),
        createRegularToken(TwoTok)
      ])

      expect(threeIterationsParser.rule()).to.equal(3)
    })

    it("AT_LEAST_ONE_SEP", () => {
      class MultiTokenLookAheadForAtLeastOneSepParser extends EmbeddedActionsParser {
        constructor(input: IToken[] = []) {
          super(ALL_TOKENS, { maxLookahead: 1 })

          this.performSelfAnalysis()
          this.input = input
        }

        public rule = this.RULE("orRule", () => {
          let numOfIterations = 0
          this.AT_LEAST_ONE_SEP({
            MAX_LOOKAHEAD: 3,
            SEP: Comma,
            DEF: () => {
              this.CONSUME1(OneTok)
              this.CONSUME1(TwoTok)
              this.CONSUME1(ThreeTok)
              numOfIterations++
            }
          })
          this.CONSUME2(OneTok)
          this.CONSUME2(TwoTok)
          return numOfIterations
        })
      }

      const oneIterationParser = new MultiTokenLookAheadForAtLeastOneSepParser([
        createRegularToken(OneTok),
        createRegularToken(TwoTok),
        createRegularToken(ThreeTok),
        createRegularToken(OneTok),
        createRegularToken(TwoTok)
      ])
      expect(oneIterationParser.rule()).to.equal(1)

      const twoIterationsParser = new MultiTokenLookAheadForAtLeastOneSepParser(
        [
          createRegularToken(OneTok),
          createRegularToken(TwoTok),
          createRegularToken(ThreeTok),
          createRegularToken(Comma),
          createRegularToken(OneTok),
          createRegularToken(TwoTok),
          createRegularToken(ThreeTok),
          createRegularToken(OneTok),
          createRegularToken(TwoTok)
        ]
      )
      expect(twoIterationsParser.rule()).to.equal(2)

      const threeIterationsParser =
        new MultiTokenLookAheadForAtLeastOneSepParser([
          createRegularToken(OneTok),
          createRegularToken(TwoTok),
          createRegularToken(ThreeTok),
          createRegularToken(Comma),
          createRegularToken(OneTok),
          createRegularToken(TwoTok),
          createRegularToken(ThreeTok),
          createRegularToken(Comma),
          createRegularToken(OneTok),
          createRegularToken(TwoTok),
          createRegularToken(ThreeTok),
          createRegularToken(OneTok),
          createRegularToken(TwoTok)
        ])
      expect(threeIterationsParser.rule()).to.equal(3)
    })
  })

  describe("Lookahead bug: MANY in OR", () => {
    class ManyInOrBugParser extends EmbeddedActionsParser {
      constructor() {
        super(ALL_TOKENS, {})
        this.performSelfAnalysis()
      }

      public main = this.RULE("main", () => {
        this.OR({
          DEF: [
            { ALT: () => this.SUBRULE(this.alt1) },
            { ALT: () => this.SUBRULE(this.alt2) }
          ],
          IGNORE_AMBIGUITIES: true
        })
      })

      public alt1 = this.RULE("alt1", () => {
        this.MANY(() => {
          this.CONSUME(Comma)
        })
        this.CONSUME(OneTok)
      })

      public alt2 = this.RULE("alt2", () => {
        this.MANY(() => {
          this.CONSUME(Comma)
        })
        this.CONSUME(TwoTok)
      })
    }

    let manyInOrBugParser: ManyInOrBugParser
    before(() => {
      manyInOrBugParser = new ManyInOrBugParser()
    })

    it("Won't throw NoViableAltException when the repetition appears twice", () => {
      const input = [
        createRegularToken(Comma),
        createRegularToken(Comma),
        createRegularToken(TwoTok)
      ]
      manyInOrBugParser.input = input
      manyInOrBugParser.main()
      expect(manyInOrBugParser.errors).to.be.empty
    })
  })

  describe("Categories lookahead bug #918", () => {
    it("Will take token categories into account when performing lookahead", () => {
      const A = createToken({ name: "A" })
      const B = createToken({ name: "B", categories: A })
      const C = createToken({ name: "C" })
      const D = createToken({ name: "D" })

      class CategoriesLookaheadBugParser extends EmbeddedActionsParser {
        constructor() {
          super([A, B, C, D])
          this.performSelfAnalysis()
        }

        public main = this.RULE("main", () => {
          this.OR([
            { ALT: () => this.SUBRULE(this.alt1) },
            { ALT: () => this.SUBRULE(this.alt2) }
          ])
        })

        public alt1 = this.RULE("alt1", () => {
          this.CONSUME(B)
          this.CONSUME(C)
        })

        public alt2 = this.RULE("alt2", () => {
          this.CONSUME(A)
          this.CONSUME(D)
        })
      }

      const input = [createRegularToken(B), createRegularToken(D)]

      const parser = new CategoriesLookaheadBugParser()
      parser.input = input
      parser.main()
      expect(parser.errors).to.be.empty
    })
  })
})


text:
<?php
namespace SclNominetEpp\Request\Update\Unrenew;

use SclNominetEpp\Request;
use SclNominetEpp\Response\Update\Unrenew\Unrenew as UnrenewResponse;

/**
 *
 *
 * @author Merlyn Cooper <merlyn.cooper@hotmail.co.uk>
 */

/**
 *
 *
 * @author Merlyn Cooper <merlyn.cooper@hotmail.co.uk>
 */
class Unrenew extends Request
{
    //put your code here
    const UNRENEW_NAMESPACE = 'http://www.nominet.org.uk/epp/xml/std-unrenew-1.0';

    protected $domainNames;

    public function __construct($value)
    {
        parent::__construct('update', new UnrenewResponse());
    }

    public function addContent(\SimpleXMLElement $updateXML)
    {
        $unrenewNS  = self::UNRENEW_NAMESPACE;

        $unrenewXSI = $unrenewNS . ' ' . 'std-unrenew-1.0.xsd';

        $update = $updateXML->addChild('u:unrenew', '', $unrenewNS);
        $update->addAttribute('xsi:schemaLocation', $unrenewXSI);
        if (!empty($this->domainNames)) {
            foreach ($this->domainNames as $domainName) {
                $update->addChild('domainName', $domainName, $unrenewNS);
            }
        }
    }
}


text:
package com.tvd12.ezyfox.util;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Map.Entry;

@Getter
@NoArgsConstructor
@AllArgsConstructor
public class EzyEntry<K, V> implements Entry<K, V>, Serializable {
    private static final long serialVersionUID = -6562095834319774526L;

    protected K key;
    protected V value;

    public static <K, V> EzyEntry<K, V> of(K key, V value) {
        return new EzyEntry<>(key, value);
    }

    public void setKey(K key) {
        this.key = key;
    }

    @Override
    public V setValue(V value) {
        V old = this.value;
        this.value = value;
        return old;
    }

    @SuppressWarnings("rawtypes")
    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (obj == this) {
            return true;
        }
        if (obj instanceof EzyEntry) {
            return key.equals(((EzyEntry) obj).key);
        }
        return false;
    }

    @Override
    public int hashCode() {
        return key.hashCode();
    }
}


text:
package org.apache.hadoop.yarn.server.api;

import org.apache.hadoop.classification.InterfaceAudience.Private;
import org.apache.hadoop.classification.InterfaceAudience.Public;
import org.apache.hadoop.classification.InterfaceStability.Evolving;
import org.apache.hadoop.classification.InterfaceStability.Unstable;
import org.apache.hadoop.yarn.api.records.ContainerId;
import org.apache.hadoop.yarn.api.records.Resource;

/**
 * Initialization context for {@link AuxiliaryService} when starting a
 * container.
 *
 */
@Public
@Evolving
public class ContainerInitializationContext extends ContainerContext {

    @Private
    @Unstable
    public ContainerInitializationContext(String user, ContainerId containerId,
                                          Resource resource) {
        super(user, containerId, resource);
    }

    @Private
    @Unstable
    public ContainerInitializationContext(String user, ContainerId containerId,
                                          Resource resource, ContainerType containerType) {
        super(user, containerId, resource, containerType);
    }
}


text:
class Event < ActiveRecord::Base
  acts_as_gmappable
  attr_accessible :address, :alert, :gmaps, :latitude, :longitude, :name

  validates(:address, presence: true)
  validates(:gmaps, presence: true)
  validates(:latitude, presence: true)
  validates(:longitude, presence: true)
  validates(:name, presence: true)
  validates(:alert, presence: true)

  def gmaps4rails_address
    address
  end

  def gmaps4rails_infowindow
    "
#{name}
"
  end

  def gmaps4rails_marker_picture
    if alert == 0
    {
        "rich_marker" =>  "

"
    }
    else
    {
        "rich_marker" =>  "

"
    }
    end
  end

end


text:
(function($) {
    $(window).load(function() {
        $('.flexslider').flexslider({
	            animation: 'fade'
	    });
    });
})(jQuery)


text:
import socket

import itertools

import errno
import six
from six import moves

import kombu
from oslo_log import log as logging

from mistral import config as cfg
from mistral import exceptions as exc
from mistral.rpc import base as rpc_base
from mistral.rpc.kombu import base as kombu_base
from mistral.rpc.kombu import kombu_hosts
from mistral.rpc.kombu import kombu_listener
from mistral import utils

#: When connection to the RabbitMQ server breaks, the
#: client will receive EPIPE socket errors. These indicate
#: an error that may be fixed by retrying. This constant
#: is a guess for how many times the retry may be reasonable
EPIPE_RETRIES = 4

LOG = logging.getLogger(__name__)

CONF = cfg.CONF

CONF.import_opt('rpc_response_timeout', 'mistral.config')

class KombuRPCClient(rpc_base.RPCClient, kombu_base.Base):
    def __init__(self, conf):
        super(KombuRPCClient, self).__init__(conf)

        kombu_base.set_transport_options()

        self._register_mistral_serialization()

        self.topic = conf.topic
        self.server_id = conf.host

        self._hosts = kombu_hosts.KombuHosts(CONF)

        self.exchange = CONF.control_exchange
        self.virtual_host = CONF.oslo_messaging_rabbit.rabbit_virtual_host
        self.durable_queue = CONF.oslo_messaging_rabbit.amqp_durable_queues
        self.auto_delete = CONF.oslo_messaging_rabbit.amqp_auto_delete
        self._timeout = CONF.rpc_response_timeout
        self.routing_key = self.topic

        hosts = self._hosts.get_hosts()

        connections = []

        for host in hosts:
            conn = self._make_connection(
                host.hostname,
                host.port,
                host.username,
                host.password,
                self.virtual_host
            )
            connections.append(conn)

        self._connections = itertools.cycle(connections)

        # Create exchange.
        exchange = self._make_exchange(
            self.exchange,
            durable=self.durable_queue,
            auto_delete=self.auto_delete
        )

        # Create queue.
        self.queue_name = utils.generate_unicode_uuid()
        self.callback_queue = kombu.Queue(
            self.queue_name,
            exchange=exchange,
            routing_key=self.queue_name,
            durable=False,
            exclusive=True,
            auto_delete=True
        )

        self._listener = kombu_listener.KombuRPCListener(
            connections=self._connections,
            callback_queue=self.callback_queue
        )

        self._listener.start()

    def _wait_for_result(self, correlation_id):
        """Waits for the result from the server.

        Waits for the result from the server, checks every second if
        a timeout occurred. If a timeout occurred - the `RpcTimeout` exception
        will be raised.
        """
        try:
            return self._listener.get_result(correlation_id, self._timeout)
        except moves.queue.Empty:
            raise exc.MistralException(
                "RPC Request timeout, correlation_id = %s" % correlation_id
            )

    def _call(self, ctx, method, target, async_=False, **kwargs):
        """Performs a remote call for the given method.

        :param ctx: authentication context associated with mistral
        :param method: name of the method that should be executed
        :param kwargs: keyword parameters for the remote-method
        :param target: Server name
        :param async: bool value means whether the request is
            asynchronous or not.
        :return: result of the method or None if async.
        """
        correlation_id = utils.generate_unicode_uuid()

        body = {
            'rpc_ctx': ctx.to_dict(),
            'rpc_method': method,
            'arguments': self._serialize_message(kwargs),
            'async': async_
        }

        LOG.debug("Publish request: %s", body)

        try:
            if not async_:
                self._listener.add_listener(correlation_id)

            # Publish request.
            for retry_round in six.moves.range(EPIPE_RETRIES):
                if self._publish_request(body, correlation_id):
                    break

            # Start waiting for response.
            if async_:
                return

            LOG.debug(
                "Waiting a reply for sync call [reply_to = %s]",
                self.queue_name
            )

            result = self._wait_for_result(correlation_id)
            res_type = result[kombu_base.TYPE]
            res_object = result[kombu_base.RESULT]

            if res_type == 'error':
                raise res_object
            else:
                res_object = self._deserialize_message(res_object)['body']

        finally:
            if not async_:
                self._listener.remove_listener(correlation_id)

        return res_object

    def _publish_request(self, body, correlation_id):
        """Publishes the request message

        .. note::
            The :const:`errno.EPIPE` socket errors are suppressed
            and result in False being returned. This is because
            this type of error can usually be fixed by retrying.

        :param body: message body
        :param correlation_id: correlation id
        :return: True if publish succeeded, False otherwise
        :rtype: bool
        """
        try:
            conn = self._listener.wait_ready()
            if conn:
                with kombu.producers[conn].acquire(block=True) as producer:
                    producer.publish(
                        body=body,
                        exchange=self.exchange,
                        routing_key=self.topic,
                        reply_to=self.queue_name,
                        correlation_id=correlation_id,
                        delivery_mode=2
                    )
                    return True
        except socket.error as e:
            if e.errno != errno.EPIPE:
                raise
            else:
                LOG.debug('Retrying publish due to broker connection failure')
        return False

    def sync_call(self, ctx, method, target=None, **kwargs):
        return self._call(ctx, method, async_=False, target=target, **kwargs)

    def async_call(self, ctx, method, target=None, **kwargs):
        return self._call(ctx, method, async_=True, target=target, **kwargs)


text:
> List directory contents.
> Drop-in replacement for `ls -l`.

- List files and directories in the current directory, one per line, with details:

`vdir`

- List with sizes displayed in human readable units (KB, MB, GB):

`vdir -h`

- List including hidden files (starting with a dot):

`vdir -a`

- List files and directories sorting entries by size (largest first):

`vdir -S`

- List files and directories sorting entries by modification time (newest first):

`vdir -t`

- List grouping directories first:

`vdir --group-directories-first`

- Recursively list all files and directories in a specific directory:

`vdir --recursive {{path/to/directory}}`


text:
Imports System.Runtime.InteropServices
Imports NetOffice
Imports NetOffice.Tools
Imports Word = NetOffice.WordApi
Imports NetOffice.WordApi.Tools
Imports NetOffice.OfficeApi.Tools
'
'Document Inspector Example
'
<COMAddin("Word05 Sample Addin VB4", "Document Inspector Example", LoadBehavior.LoadAtStartup)>
<DocumentInspector("Word05AddinVB4 Inspector", "This is a sample inspector", "12,14,15,16", 1)>
<ProgId("Word05AddinVB4.Connect"), Guid("D34CE190-3E6F-454A-9121-6FC6BC9CEC09"), Codebase, Timestamp>
Public Class Addin
    Inherits Word.Tools.COMAddin

    Protected Overrides Function OnCreateDocumentInspector() As ToolsDocumentInspector

        Return New CustomDocumentInspector()

    End Function

End Class