예제 #1
0
 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));
         }
     }
 }
예제 #2
0
 void OnTextUpdated(string text)
 {
     HasErrors = false;
     ParserErrors.Clear();
     if (_parser.ParseValid(text))
     {
         _eventAggregator.GetEvent <TextInputValidatedEvent>().Publish(text);
     }
     else
     {
         _eventAggregator.GetEvent <InvalidInputEvent>().Publish(0);
     }
 }
예제 #3
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);
         }
     }
 }
예제 #4
0
        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);
        }
예제 #5
0
 public INIParserException(ParserErrors error, object errorSource)
 {
     Error       = error;
     ErrorSource = errorSource;
 }
예제 #6
0
 public INIParserException(ParserErrors error)
     : this(error, null)
 {
 }
예제 #7
0
 public void HandleError(ErrorDescription error)
 {
     HasErrors = true;
     ParserErrors.Add(error);
 }
예제 #8
0
        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());
        }