[Seed7-users] What's wrong?
Interpreter and compiler for the Seed7 programming language.
Brought to you by:
thomas_mertes
From: Thomas M. <tho...@gm...> - 2012-09-16 09:32:25
|
On Fri, 14 Sep 2012 22:22:23 +0200, Renato Lenzi <re...@gm...> wrote: > Here is a very simple code: > > > $ include "seed7_05.s7i"; > $ include "char.s7i"; > const proc: main is func > begin > end func; > > and here is what compiler says (Win7 64): There are some issues 1. Only the first include command, the one which includes "seed7_05.s7i", needs a $ sign. Later include commands should not use a $ sign. The include commands without $ maintain, what was already included and therefore they do not include something twice. 2. It is not necessary to include "char.s7i", since it is already included from "seed7_05.s7i". 3. The construct func begin ... end func; assumes that there are one or more statements between 'begin' and 'end'. Omitting the statement(s) between 'begin' and 'end' is like omitting a function parameter. For a missing function parameter you will get an error message. Likewise you get an error message when the statement(s) between 'begin' and 'end' are omitted. The empty statement is 'noop'. Just omitting a statement is not considered correct. > HI INTERPRETER Version 4.5.9553 Copyright (c) 1990-2012 Thomas Mertes > *** /d/seed7/lib/char.s7i(33):34: "char" declared twice > const type: char is subtype DISCRETE; > -----------------------------------------------^ Because "char.s7i" is included twice the type 'char' is defined twice. > *** /d/seed7/lib/char.s7i(129):34: (in integer param) chr declared twice > const func char: chr (in integer: number) is action > "CHR_CHR > "; > -------------------------------------------------------------------------------- > --^ Because "char.s7i" is included twice the function 'chr' is defined twice. > *** /d/seed7/lib/char.s7i(217):34: "EOF" declared twice > const char: EOF is chr(-1); > ---------------------------^ Because "char.s7i" is included twice the constant 'EOF' is defined twice. > *** char02.sd7(5):30: Expression expected found "func" > end func; > --------------^ This error is written, because there should be one or more statements between 'begin' and 'end'. The other errors below are triggered by this error message. > *** char02.sd7(5):47: "end" expected found "func" > end func; > --------------^ > *** char02.sd7(5):47: "func" expected found ";" > end func; > ---------------^ > *** char02.sd7(5):46: ";" expected found "END OF FILE" > > ^ > *** char02.sd7(3):51: Match for {func begin {end } } failed > begin > > > may be it's too late but i don't understand.... No problem. Hopefully the explanation helps. Currently const proc: main is func begin end func; and if condition then end if; are illegal. The legal versions of the examples above are const proc: main is func begin noop; end func; and if condition then noop; end if; Maybe there should be versions of statements, where statement parameters can be omitted. Regards, Thomas Mertes |