]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gm2/dynamic/pass/wc.mod
Merge modula-2 front end onto gcc.
[thirdparty/gcc.git] / gcc / testsuite / gm2 / dynamic / pass / wc.mod
1 (* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. *)
2 (* This file is part of GNU Modula-2.
3
4 GNU Modula-2 is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8
9 GNU Modula-2 is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License along
15 with gm2; see the file COPYING. If not, write to the Free Software
16 Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *)
17 MODULE wc ;
18
19
20 FROM StdIO IMPORT Read ;
21 FROM NumberIO IMPORT WriteCard ;
22 FROM StrIO IMPORT WriteLn ;
23 FROM ASCII IMPORT cr ;
24
25 CONST
26 Max = 1000 ;
27
28 VAR
29 a : ARRAY [0..Max] OF CHAR ;
30 words,
31 word : CARDINAL ;
32 chars: CARDINAL ;
33 ch : CHAR ;
34 BEGIN
35 word := 0 ;
36 words := 0 ;
37 chars := 0 ;
38 Read(ch) ;
39 WHILE ch#cr DO
40 INC(chars) ;
41 a[chars] := ch ;
42 IF ch#' '
43 THEN
44 IF word=0
45 THEN
46 word := 1 ;
47 INC(words)
48 END
49 ELSE
50 word := 0
51 END ;
52 Read(ch)
53 END ;
54 WriteLn ;
55 WriteCard(words, 4) ;
56 WriteLn ;
57 WriteCard(chars, 4) ;
58 WriteLn
59 END wc.