// Path: src/fr/insalyon/citi/golo/compiler/parser/IdeJavaCharStream.java
// public class IdeJavaCharStream extends JavaCharStream implements GoloParserTokenManager.TokenCompleter {
//     private int currentOffset = 0;
//     private int tokenStart = 0;
// 
//     public IdeJavaCharStream(Reader reader) {
//         super(reader);
//     }
// 
//     @Override
//     public char readChar() throws IOException {
//         char result = super.readChar();
//             currentOffset++;
//         return result;
//     }
// 
//     @Override
//     public char BeginToken() throws IOException {
//         tokenStart = currentOffset;
//         char result = super.BeginToken();
//         if (tokenStart == currentOffset) {
//             currentOffset++;
//         }
//         return result;
//     }
// 
//     @Override
//     public void backup(int amount) {
//         super.backup(amount);
//         currentOffset -= amount;
//     }
// 
//     @Override
//     public void ReInit(Reader dstream) {
//         super.ReInit(dstream);
//         currentOffset = 0;
//     }
// 
//     @Override
//     public void completeToken(Token token) {
//         token.startOffset = tokenStart;
//         token.endOffset = currentOffset;
//     }
// 
// }


import fr.insalyon.citi.golo.compiler.GoloCompilationException;
import fr.insalyon.citi.golo.compiler.GoloCompiler;
import fr.insalyon.citi.golo.compiler.ir.GoloModule;
import fr.insalyon.citi.golo.compiler.parser.ASTCompilationUnit;
import fr.insalyon.citi.golo.compiler.parser.GoloASTNode;
import fr.insalyon.citi.golo.compiler.parser.GoloParserTokenManager;
import fr.insalyon.citi.golo.compiler.parser.IdeJavaCharStream;
import fr.insalyon.citi.golo.compiler.parser.Token;
import java.io.InputStream;
import java.io.Reader;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import javax.swing.event.ChangeListener;
import org.netbeans.modules.csl.api.Error;
import org.netbeans.modules.csl.api.Severity;
import org.netbeans.modules.csl.spi.DefaultError;
import org.netbeans.modules.csl.spi.ParserResult;
import org.netbeans.modules.parsing.api.Snapshot;
import org.netbeans.modules.parsing.api.Task;
import org.netbeans.modules.parsing.spi.Parser;
import org.netbeans.modules.parsing.spi.ParserResultTask;
import org.netbeans.modules.parsing.spi.SourceModificationEvent;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
/*
 *  Copyright 2013 SERLI (www.serli.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 * 
 */

package org.gololang.netbeans.parser;



/**
 *
 * @author David Festal <david.festal@serli.com>
 */
public class GoloParser extends Parser {

    private Snapshot snapshot;
    private Future<GoloParserResult> parserTaskResult;
    
    private static class InternalGoloCompiler extends GoloCompiler {
      @Override
      protected fr.insalyon.citi.golo.compiler.parser.GoloParser createGoloParser(final Reader sourceReader) {
// Path: src/fr/insalyon/citi/golo/compiler/parser/IdeJavaCharStream.java
// public class IdeJavaCharStream extends JavaCharStream implements GoloParserTokenManager.TokenCompleter {
//     private int currentOffset = 0;
//     private int tokenStart = 0;
// 
//     public IdeJavaCharStream(Reader reader) {
//         super(reader);
//     }
// 
//     @Override
//     public char readChar() throws IOException {
//         char result = super.readChar();
//             currentOffset++;
//         return result;
//     }
// 
//     @Override
//     public char BeginToken() throws IOException {
//         tokenStart = currentOffset;
//         char result = super.BeginToken();
//         if (tokenStart == currentOffset) {
//             currentOffset++;
//         }
//         return result;
//     }
// 
//     @Override
//     public void backup(int amount) {
//         super.backup(amount);
//         currentOffset -= amount;
//     }
// 
//     @Override
//     public void ReInit(Reader dstream) {
//         super.ReInit(dstream);
//         currentOffset = 0;
//     }
// 
//     @Override
//     public void completeToken(Token token) {
//         token.startOffset = tokenStart;
//         token.endOffset = currentOffset;
//     }
// 
// }


// Path: src/org/gololang/netbeans/parser/GoloParser.java
import fr.insalyon.citi.golo.compiler.GoloCompilationException;
import fr.insalyon.citi.golo.compiler.GoloCompiler;
import fr.insalyon.citi.golo.compiler.ir.GoloModule;
import fr.insalyon.citi.golo.compiler.parser.ASTCompilationUnit;
import fr.insalyon.citi.golo.compiler.parser.GoloASTNode;
import fr.insalyon.citi.golo.compiler.parser.GoloParserTokenManager;
import fr.insalyon.citi.golo.compiler.parser.IdeJavaCharStream;
import fr.insalyon.citi.golo.compiler.parser.Token;
import java.io.InputStream;
import java.io.Reader;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import javax.swing.event.ChangeListener;
import org.netbeans.modules.csl.api.Error;
import org.netbeans.modules.csl.api.Severity;
import org.netbeans.modules.csl.spi.DefaultError;
import org.netbeans.modules.csl.spi.ParserResult;
import org.netbeans.modules.parsing.api.Snapshot;
import org.netbeans.modules.parsing.api.Task;
import org.netbeans.modules.parsing.spi.Parser;
import org.netbeans.modules.parsing.spi.ParserResultTask;
import org.netbeans.modules.parsing.spi.SourceModificationEvent;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;

/*
 *  Copyright 2013 SERLI (www.serli.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 * 
 */

package org.gololang.netbeans.parser;



/**
 *
 * @author David Festal <david.festal@serli.com>
 */
public class GoloParser extends Parser {

    private Snapshot snapshot;
    private Future<GoloParserResult> parserTaskResult;
    
    private static class InternalGoloCompiler extends GoloCompiler {
      @Override
      protected fr.insalyon.citi.golo.compiler.parser.GoloParser createGoloParser(final Reader sourceReader) {
        final IdeJavaCharStream javaCharStream = new IdeJavaCharStream(sourceReader);