Example #1
0
        public override bool TryParse(Scanner scanner, out PitchNode result)
        {
            result = new PitchNode();
            var anchor = scanner.MakeAnchor();

            NoteNameNode noteNameNode;

            if (!new NoteNameParser().TryParse(scanner, out noteNameNode))
            {
                result = null;
                return(false);
            }

            result.NoteName = noteNameNode;

            int octave;

            if (scanner.TryReadInteger(out octave))
            {
                result.OctaveGroup = new LiteralNode <int>(octave, scanner.LastReadRange);
            }

            result.Range = anchor.Range;

            return(true);
        }
Example #2
0
        public static bool TryReadInteger(Scanner scanner, out LiteralNode <int> node)
        {
            int value;

            if (!scanner.TryReadInteger(out value))
            {
                node = null;
                return(false);
            }

            node = new LiteralNode <int>(value, scanner.LastReadRange);
            return(true);
        }
Example #3
0
        public static bool TryReadBaseNoteValue(Scanner scanner, ILogger logger,
                                                out LiteralNode <BaseNoteValue> baseNoteValueNode)
        {
            int reciprocal;

            if (!scanner.TryReadInteger(out reciprocal))
            {
                logger.Report(LogLevel.Error, scanner.LastReadRange, Messages.Error_NoteValueExpected);
                baseNoteValueNode = null;
                return(false);
            }

            BaseNoteValue baseNoteValue;

            if (!BaseNoteValues.TryParse(reciprocal, out baseNoteValue))
            {
                logger.Report(LogLevel.Error, scanner.LastReadRange, Messages.Error_InvalidReciprocalNoteValue);
                baseNoteValueNode = null;
                return(false);
            }

            baseNoteValueNode = new LiteralNode <BaseNoteValue>(baseNoteValue, scanner.LastReadRange);
            return(true);
        }