iXML Community Group Test Suite

23 Oct 2023 (22 Nov 2023)

Top-level catalog for tests in the iXML Community Group Test Suite.

Tests have been contributed from several sources, but the core of the test collection are the tests contributed by Steven Pemberton in December 2021.

Misc tests 2

28 Jun 2022

Grammars 21-40.

Test grammars compiled manually in 2018 and 2019, re-packaged in 2022.

Added test cases where needed and moved to ixml test collection, June 2022.

sample.grammar.33

Created 08 Feb 2022 by cmsmcq

Grammar for the toy programming language Tosca.

From Susan Stepney, High integrity compilation: a case study. Hemel Hempstead: Prentice Hall International, 1993. Web edition. Tosca is defined in chapter 4; the concrete syntax is specified using Z, not using a grammar, and leaves some things undefined, so the grammar given here is a bit of a reconstruction.

Invisible XML Grammar

{ program is defined in section 4.8 }
program: S, decl**S, S, cmd, S.

{ Names are described in 4.3 but left indeterminate syntactically;
I've made them like the SGML reference concrete syntax. }
NAME: letter, namechar*.
-letter:  ["a"-"z"; "A"-"Z"].
-digit: ["0"-"9"].
-namechar:  letter; digit; ["-"; "."; "_"].

{ Types are described in 4.3 }
TYPE:  "int"; "bool".
boolean:  "true"; "false".
number:  digit+.

{ declarations:  section 4.4 }
decl:  NAME, S, -":", S, TYPE, S, -";".

{ operators, section 4.5 }
unaryOp: negate; not.  

negate: "-".
not: "not".

binaryOp: plus; minus; less; greater; equal; or; and.  
plus: -"+".
minus: -"-".
less: -"<".
greater: -">".
equal: -"=".
or: -"or".
and: -"and".

{ expressions:  4.6 }
expr:  constant; variable; unaryExpr; binaryExpr.
constant:  number; boolean.
variable:  NAME.
unaryExpr:  unaryOp, S, expr.
binaryExpr:  -"(", S, expr, S, binaryOp, S, expr, S, -")".

{ commands:  4.7 }
cmd: (skip; block; assign; choice; loop; input; output).
cmdseq: (cmd, S, -";", S)+.
skip: -"skip".
block:  -"begin", S, cmdseq, -"end".
assign: variable, S, -":=", S, expr.
choice: -"if", S, condition, S, -"then", S, iftrue, -"else", S, iffalse.
condition: -expr.
iftrue: cmd.
iffalse: cmd.
loop: -"while", S, expr, S, -"do", S, cmd.
input: -"input", S, NAME.
output: -"output", S, expr.

{ Stepney does not specify whitespace or comment rules. }
-S: (ws; comment)*.
-ws: -[#20; #0A; #09; #0D].
comment: -"/*", nonstar*, ("*", nonstarnonslash*)*, -"*/".
nonstar: ~["*"]. 
nonstarnonslash: ~["*"; "/"]. 

Test case: g33.c01

Repository URI: …/tests/misc/misc-021-040-catalog.xml

Created 12 Jun 2022 by cmsmcq

This sample 'squares' program is Stepney's running example. The input string is transcribed from the concrete-syntax version on page 44.

Input string (324 characters)


	n : int ; sq : int ; limit : int ;
        begin
	     n := 1 ; sq := 1 ;
	     input limit ;
             output sq ;
             while ( n < limit ) do
             begin
                  sq := ( ( sq + 1 ) + ( n + n ) ) ;
                  n := ( n + 1 ) ;
                  output sq ;
             end ;
	end
      

Expected result

<program>
   <decl>
      <NAME>n</NAME>
      <TYPE>int</TYPE>
   </decl>
   <decl>
      <NAME>sq</NAME>
      <TYPE>int</TYPE>
   </decl>
   <decl>
      <NAME>limit</NAME>
      <TYPE>int</TYPE>
   </decl>
   <cmd>
      <block>
         <cmdseq>
            <cmd>
               <assign>
                  <variable>
                     <NAME>n</NAME>
                  </variable>
                  <expr>
                     <constant>
                        <number>1</number>
                     </constant>
                  </expr>
               </assign>
            </cmd>
            <cmd>
               <assign>
                  <variable>
                     <NAME>sq</NAME>
                  </variable>
                  <expr>
                     <constant>
                        <number>1</number>
                     </constant>
                  </expr>
               </assign>
            </cmd>
            <cmd>
               <input>
                  <NAME>limit</NAME>
               </input>
            </cmd>
            <cmd>
               <output>
                  <expr>
                     <variable>
                        <NAME>sq</NAME>
                     </variable>
                  </expr>
               </output>
            </cmd>
            <cmd>
               <loop>
                  <expr>
                     <binaryExpr>
                        <expr>
                           <variable>
                              <NAME>n</NAME>
                           </variable>
                        </expr>
                        <binaryOp>
                           <less/>
                        </binaryOp>
                        <expr>
                           <variable>
                              <NAME>limit</NAME>
                           </variable>
                        </expr>
                     </binaryExpr>
                  </expr>
                  <cmd>
                     <block>
                        <cmdseq>
                           <cmd>
                              <assign>
                                 <variable>
                                    <NAME>sq</NAME>
                                 </variable>
                                 <expr>
                                    <binaryExpr>
                                       <expr>
                                          <binaryExpr>
                                             <expr>
                                                <variable>
                                                   <NAME>sq</NAME>
                                                </variable>
                                             </expr>
                                             <binaryOp>
                                                <plus/>
                                             </binaryOp>
                                             <expr>
                                                <constant>
                                                   <number>1</number>
                                                </constant>
                                             </expr>
                                          </binaryExpr>
                                       </expr>
                                       <binaryOp>
                                          <plus/>
                                       </binaryOp>
                                       <expr>
                                          <binaryExpr>
                                             <expr>
                                                <variable>
                                                   <NAME>n</NAME>
                                                </variable>
                                             </expr>
                                             <binaryOp>
                                                <plus/>
                                             </binaryOp>
                                             <expr>
                                                <variable>
                                                   <NAME>n</NAME>
                                                </variable>
                                             </expr>
                                          </binaryExpr>
                                       </expr>
                                    </binaryExpr>
                                 </expr>
                              </assign>
                           </cmd>
                           <cmd>
                              <assign>
                                 <variable>
                                    <NAME>n</NAME>
                                 </variable>
                                 <expr>
                                    <binaryExpr>
                                       <expr>
                                          <variable>
                                             <NAME>n</NAME>
                                          </variable>
                                       </expr>
                                       <binaryOp>
                                          <plus/>
                                       </binaryOp>
                                       <expr>
                                          <constant>
                                             <number>1</number>
                                          </constant>
                                       </expr>
                                    </binaryExpr>
                                 </expr>
                              </assign>
                           </cmd>
                           <cmd>
                              <output>
                                 <expr>
                                    <variable>
                                       <NAME>sq</NAME>
                                    </variable>
                                 </expr>
                              </output>
                           </cmd>
                        </cmdseq>
                     </block>
                  </cmd>
               </loop>
            </cmd>
         </cmdseq>
      </block>
   </cmd>
</program>