コード例 #1
0
        public void LineParser_InvalidRHS_ReturnsInvalidSyntax()
        {
            string           line        = "\tproposition ( p and q ) ifandonlyif z r";
            SyntacticElement parseResult = LineParser.Parse(line);

            Assert.AreEqual(typeof(InvalidSyntacticElement), parseResult.GetType());
        }
コード例 #2
0
        public void LineParser_TooManyImplies_ReturnsInvalidSyntax()
        {
            string           line        = "\ttherefore p implies z";
            SyntacticElement parseResult = LineParser.Parse(line);

            Assert.AreEqual(typeof(InvalidSyntacticElement), parseResult.GetType());
        }
コード例 #3
0
        public void LineParser_TooManyIfAndOnlyIfs_ReturnsInvalidSyntax()
        {
            string           line        = "\tproposition p implies q implies z";
            SyntacticElement parseResult = LineParser.Parse(line);

            Assert.AreEqual(typeof(InvalidSyntacticElement), parseResult.GetType());
        }
コード例 #4
0
        public void LineParser__NoPropositionSymbol_ReturnsInvalidSyntax()
        {
            string           line        = "\tproposition p q ";
            SyntacticElement parseResult = LineParser.Parse(line);

            Assert.AreEqual(typeof(InvalidSyntacticElement), parseResult.GetType());
        }
コード例 #5
0
        public void LineParser__NoPropositionSymbol_onepredicateNegated_ReturnsNotExpression()
        {
            string           line        = "\tproposition not(p) ";
            SyntacticElement parseResult = LineParser.Parse(line);

            Assert.AreEqual(typeof(PropositionNegationSyntacticElement), parseResult.GetType());
            Assert.AreEqual("not (p)", ((PropositionNegationSyntacticElement)parseResult).Text);
        }
コード例 #6
0
        public void LineParser_InValidCommentDefinition_ReturnsInvalidSyntacticElement()
        {   // syntax of a comment, each comment must start a new line,
            // no inline comments are allowed. comments are denoted by
            // note: there can be no space between the note and the :
            string line;

            line = "\tnote :p and q are mental";
            SyntacticElement parseResult = LineParser.Parse(line);

            Assert.AreEqual(typeof(InvalidSyntacticElement), parseResult.GetType());
        }
コード例 #7
0
ファイル: LogicArgument.cs プロジェクト: GeoffBowden/ZedLang
 public bool Add(SyntacticElement se)
 {
     if (se is PropositionExpression)
     {
         return(Add((PropositionExpression)se));
     }
     if (se is PredicateSyntacticElement)
     {
         return(Add((PredicateSyntacticElement)se));
     }
     if (se is ThereforeSyntacticElement)
     {
         return(Add((ThereforeSyntacticElement)se));
     }
     if (se is PredicateSetterSyntacticElement)
     {
         return(Add((PredicateSetterSyntacticElement)se));
     }
     throw new NotImplementedException("Logic Argument: public bool Add( SyntacticElement se )");
 }
コード例 #8
0
ファイル: Program.cs プロジェクト: GeoffBowden/ZedLang
 public static Command GetCommand(string commandText)
 {
     if ((string.Compare(commandText, "Quit", StringComparison.OrdinalIgnoreCase) == 0) ||
         (string.Compare(commandText, "Exit", StringComparison.OrdinalIgnoreCase) == 0) ||
         (string.Compare(commandText, "bye", StringComparison.OrdinalIgnoreCase) == 0))
     {
         return(new QuitCommand(commandText));
     }
     else if (string.Compare(commandText, "help", StringComparison.OrdinalIgnoreCase) == 0)
     {
         return(new HelpCommand(commandText));
     }
     else if (string.Compare(commandText, "new", StringComparison.OrdinalIgnoreCase) == 0)
     {
         return(new NewProgramCommand(commandText));
     }
     else if (string.Compare(commandText, "clear", StringComparison.OrdinalIgnoreCase) == 0)
     {
         return(new NewProgramCommand(commandText));
     }
     else if (string.Compare(commandText, "run", StringComparison.OrdinalIgnoreCase) == 0)
     {
         return(new RunProgramCommand(commandText));
     }
     else if (string.CompareOrdinal(commandText.ToLower(), 0, "load", 0, 4) == 0)
     {
         return(new LoadFileCommand(commandText));
     }
     else if (string.CompareOrdinal(commandText.ToLower(), 0, "save", 0, 4) == 0)
     {
         return(new SaveFileCommand(commandText));
     }
     else
     {
         SyntacticElement se = LineParser.Parse(commandText);
         SyntacticCommand sc = new SyntacticCommand(commandText, se);
         return(sc);
     }
 }
コード例 #9
0
ファイル: Program.cs プロジェクト: GeoffBowden/ZedLang
 public SyntacticCommand(string commandText, SyntacticElement command) : base(commandText)
 {
     this.Command = command;
 }