Exemple #1
0
 def test_alternating_array_declaration(self):
     simple_program_string = """
                    DECLARE a, b(2:10), c, d(3:4), e(-10:20) BEGIN
                    WRITE 50;
                    END
                    """
     ptree = parse(simple_program_string)
     pp(ptree)
Exemple #2
0
 def test_valid_if(self):
     simple_program_string = """
                       DECLARE a BEGIN
                        READ a;
                        IF a GE 10 THEN
                        WRITE 5;
                        ENDIF
                       END
                       """
     ptree = parse(simple_program_string)
     pp(ptree)
Exemple #3
0
 def test_valid_for_down_to(self):
     simple_program_string = """
                             DECLARE a BEGIN
                                READ a;
                               FOR i FROM 10 DOWNTO 0 DO 
                               a ASSIGN a PLUS 1;
                               ENDFOR
                                 WRITE a;
                               END
                                 """
     ptree = parse(simple_program_string)
     pp(ptree)
Exemple #4
0
 def test_valid_for_up(self):
     simple_program_string = """
                          DECLARE a BEGIN
                             READ a;
                            FOR i FROM 10 TO 50 DO 
                            a ASSIGN a PLUS 1;
                            ENDFOR
                            
                            END
                              """
     ptree = parse(simple_program_string)
     pp(ptree)
Exemple #5
0
 def test_valid_identifiers(self):
     simple_program_string = """
                    DECLARE a,b,c(-11:30) BEGIN
                    READ b;
                    READ a;
                    c(5) ASSIGN 10;
                    c(b) ASSIGN a;
                    c(-10) ASSIGN 10;
                    END
                    """
     ptree = parse(simple_program_string)
     pp(ptree)
Exemple #6
0
 def test_large_embedding_do_while(self):
     simple_program_string = """
                           DECLARE a BEGIN
                              READ a;
                             DO DO DO DO DO
                             READ a;
                             WHILE a GEQ 150  ENDDO
                              WHILE a GEQ 150 ENDDO
                               WHILE a GEQ 150 ENDDO
                                WHILE a GEQ 150 ENDDO
                                 WHILE a GEQ 150 ENDDO
                             END
                               """
     ptree = parse(simple_program_string)
     pp(ptree)
Exemple #7
0
 def test_valid_do_while(self):
     simple_program_string = """
                          DECLARE a BEGIN
                             READ a;
                            DO
                            READ a;
                            READ a;
                            READ a;
                            a ASSIGN a MINUS 1;
                            
                            WHILE a GEQ 150
                            ENDDO
                            END
                              """
     ptree = parse(simple_program_string)
     pp(ptree)
Exemple #8
0
 def test_valid_while(self):
     simple_program_string = """
                          DECLARE a BEGIN
                           READ a;
                           WHILE a GEQ 50 
                           
                           DO
                           
                           WRITE 5;
                           WRITE 10;
                           WRITE 30;
                                 ENDWHILE
                          END
                          """
     ptree = parse(simple_program_string)
     pp(ptree)
Exemple #9
0
 def test_large_embedding_for_to(self):
     simple_program_string = """
                             DECLARE a BEGIN
                                 READ a;
                               FOR i FROM 0 TO 100 DO 
                                 FOR j FROM 0 TO 100 DO
                                     FOR k FROM 0 TO 100 DO
                                         FOR l FROM 0 TO 100 DO
                                             FOR m FROM 0 TO 100 DO
                                                 FOR n FROM 0 TO 100 DO
                                                     FOR o FROM 0 TO 100 DO
                                                         WRITE 123;
                                                     ENDFOR
                                                 ENDFOR
                                             ENDFOR
                                         ENDFOR
                                     ENDFOR
                                 ENDFOR
                               ENDFOR
                               END
                                 """
     ptree = parse(simple_program_string)
     pp(ptree)
Exemple #10
0
 def test_large_embedding_while(self):
     simple_program_string = """
                                        DECLARE a, i,j,k,l,m,n,o BEGIN
                                            READ a; READ i; READ j; READ k; READ l; READ m; READ n; READ o;
                                          WHILE i GE 100 DO 
                                            WHILE j LE 0  DO
                                                WHILE k GEQ -500  DO
                                                    WHILE l LEQ -1024 DO
                                                        WHILE m EQ 500   DO
                                                            WHILE n NEQ 15  DO
                                                                WHILE o EQ 0 DO
                                                                    WRITE 123;
                                                                ENDWHILE
                                                            ENDWHILE
                                                        ENDWHILE
                                                    ENDWHILE
                                                ENDWHILE
                                            ENDWHILE
                                          ENDWHILE
                                          END
                                            """
     ptree = parse(simple_program_string)
     pp(ptree)