public BinaryFileFormat(CCFileClass ccFile = null) { if (ccFile != null && ccFile.Exists) { Filename = ccFile.Filename; ParserErrors.Clear(); if (!ReadFile(ccFile.BinaryStream)) { throw new ArgumentException(String.Format("File {0} could not be loaded.", ccFile.Filename)); } } }
void OnTextUpdated(string text) { HasErrors = false; ParserErrors.Clear(); if (_parser.ParseValid(text)) { _eventAggregator.GetEvent <TextInputValidatedEvent>().Publish(text); } else { _eventAggregator.GetEvent <InvalidInputEvent>().Publish(0); } }
public TextFileFormat(CCFileClass ccFile = null) { if (ccFile != null && ccFile.Exists) { Filename = ccFile.Filename; ParserErrors.Clear(); try { if (!ReadFile(ccFile.TextStream)) { throw new ArgumentException(); } } catch (FileParserException E) { throw new ArgumentException(String.Join("\n", errors), E); } } }
public Questionnaire BuildAST(string inputString) { MemoryStream inputStream = new MemoryStream(Encoding.UTF8.GetBytes(inputString ?? "")); AntlrInputStream antlrInputStream = new AntlrInputStream(inputStream); QLLexer lexer = new QLLexer(antlrInputStream); CommonTokenStream tokens = new CommonTokenStream(lexer); _parser = new QLParser(tokens); //Replaxe lexer/parser error listeners lexer.RemoveErrorListeners(); _parser.RemoveErrorListeners(); lexer.AddErrorListener(new LexerErrorListener() { OnError = LexerErrors.Add }); _parser.AddErrorListener(new ParserErrorListener() { OnError = ParserErrors.Add }); //set manager on partial parser class _parser.SetIdManager(Memory); //build AST _parseTree = _parser.questionnaire(); AST = _parser.GetAST(); //check for lexer/parser errors if (!LexerErrors.Any() && !ParserErrors.Any()) { TypeChecker.Run(AST); } return(AST); }
public INIParserException(ParserErrors error, object errorSource) { Error = error; ErrorSource = errorSource; }
public INIParserException(ParserErrors error) : this(error, null) { }
public void HandleError(ErrorDescription error) { HasErrors = true; ParserErrors.Add(error); }
public MainWindowViewModel() { CompositeDisposable.Add(new PropertyChangedEventListener(m_Model, (s, ev) => { switch (ev.PropertyName) { case nameof(m_Model.LyricsSource): RaisePropertyChanged(nameof(LyricsSource)); break; case nameof(m_Model.IsModified): RaisePropertyChanged(nameof(IsModified)); break; case nameof(m_Model.SavedFileNameWithoutExtension): RaisePropertyChanged(nameof(DocumentName)); break; } })); var synchronizationContext = SynchronizationContext.Current; Debug.Assert(synchronizationContext != null, "SynchronizationContext.Current is null"); CompositeDisposable.Add( m_Model.AsPropertyChanged(nameof(m_Model.ParserErrors)) .Throttle(TimeSpan.FromMilliseconds(1000)) .ObserveOn(synchronizationContext) .Subscribe(_ => { ParserErrors.Clear(); foreach (var item in m_Model.ParserErrors) { ParserErrors.Add(item); } }) ); CompositeDisposable.Add(new PropertyChangedEventListener(this, async(s, ev) => { switch (ev.PropertyName) { case nameof(CaretLocation): if (LyricsSource != null) { var logicalLineIndex = LyricsSource.LineMap.GetLogicalLineIndexByPhysical(CaretLocation.Line - 1); if (logicalLineIndex >= 0) { await ForcusViewSyllableAsync(logicalLineIndex, 0); } } break; case nameof(CurrentSyllable): if (LyricsSource != null) { var physicalLineIndex = LyricsSource.LineMap.GetPhysicalLineIndexByLogical(CurrentSyllable.Line); await FocusEditorCharacterAsync(physicalLineIndex + 1, -1, false); } break; } })); NewCommand = new HotKeyCommand(async() => await NewAsync()) { Gesture = new KeyGesture(Key.N, ModifierKeys.Control) }; OpenCommand = new HotKeyCommand(async() => await OpenAsync()) { Gesture = new KeyGesture(Key.O, ModifierKeys.Control) }; SaveAsCommand = new ViewModelCommand(async() => await SaveAsAsync()); SaveCommand = new HotKeyCommand(async() => await SaveAsync()) { Gesture = new KeyGesture(Key.S, ModifierKeys.Control) }; AutoSetRubyInSelectionCommand = new ViewModelCommand(AutoSetRubyInSelection); HighlightFirstCommand = new ViewModelCommand(async() => await HighlightLyricsAsync(LyricsHighlightRequest.First)); HighlightNextCommand = new ViewModelCommand(async() => await HighlightLyricsAsync(LyricsHighlightRequest.Next)); HighlightPreviousCommand = new ViewModelCommand(async() => await HighlightLyricsAsync(LyricsHighlightRequest.Previous)); HighlightNextLineCommand = new ViewModelCommand(async() => await HighlightLyricsAsync(LyricsHighlightRequest.NextLine)); HighlightPreviousLineCommand = new ViewModelCommand(async() => await HighlightLyricsAsync(LyricsHighlightRequest.PreviousLine)); MoveCaretToSelectedErrorCommand = new ViewModelCommand(async() => await MoveCaretToSelectedErrorAsync()); }