From: DeaDDooMER <deaddoomer@deadsoftware.ru> Date: Fri, 11 Aug 2017 11:50:26 +0000 (+0300) Subject: Подпрален FOR для соответствия стандарту X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=6d3cfbfd343c0d069896734e32a8c490f27cb7aa;p=dsw-obn.git Подпрален FOR для соответствия стандарту --- diff --git a/Test.obn b/Test.obn index 8c3a8d1..f0552a9 100644 --- a/Test.obn +++ b/Test.obn @@ -3,16 +3,13 @@ MODULE Test; IMPORT Out; VAR - msg : ARRAY 20 OF CHAR; + i : INTEGER; BEGIN Out.Open; - COPY("Hello World!", msg); - Out.String(msg); Out.Ln; - COPY("Hell!", msg); - Out.String(msg); Out.Ln; - COPY("The quick brown fox jumps over the lazy dog", msg); - Out.String(msg); Out.Ln; - msg := "Hello World!"; - Out.String(msg); Out.Ln; + i := 48; + FOR i := 32 TO i DO + Out.Int(i, 0); Out.Char(' '); + END; + Out.Ln; END Test. diff --git a/Test7.obn b/Test7.obn new file mode 100644 index 0000000..739ec97 --- /dev/null +++ b/Test7.obn @@ -0,0 +1,19 @@ +MODULE Test7; + +IMPORT Out; + +VAR + i : INTEGER; + +BEGIN + Out.Open; + i := 48; + FOR i := 32 TO i DO + Out.Int(i, 0); Out.Char(' '); + END; + Out.Ln; +END Test7. + +ÐÑовеÑка коÑÑекÑноÑÑи FOR. +СнаÑала должна вÑÑиÑлÑÑÑÑÑ Ð²ÑÑажение TO и ÑолÑко поÑом пÑиÑвоение индекÑа. +РезÑлÑÑÐ°Ñ Ð´Ð¾Ð»Ð¶ÐµÐ½ бÑÑÑ: 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 diff --git a/notes b/notes index ce31365..7d6b72b 100644 --- a/notes +++ b/notes @@ -1,5 +1,4 @@ - СделаÑÑ Ð¿ÑовеÑÐºÑ Ð¿Ð¾Ð²ÑоÑов в CASE и вÑполнÑÑÑ Ð¿ÑиÑÑвание пÑи оÑÑÑÑÑÑвии ELSE. -- Ð FOR ÑнаÑала должна вÑÑиÑлÑÑÑÑÑ Ð¿ÐµÑÐµÐ¼ÐµÐ½Ð½Ð°Ñ temp. - СделаÑÑ Ð²Ñполнение пÑеÑÑÐ²Ð°Ð½Ð¸Ñ Ð¿Ñи оÑÑÑÑÑÑвии ELSE в опеÑаÑоÑе WITH. - СделаÑÑ Ð½Ð¾ÑмалÑнÑÑ Ð¿ÑовеÑÐºÑ Ð½Ð°Ð»Ð¸ÑÐ¸Ñ RETURN. - ÐапÑеÑиÑÑ Ð¼Ð°ÑÑÐ¸Ð²Ñ Ð¸ запиÑи как ÑезÑлÑÑÐ°Ñ Ð¿ÑоÑедÑÑÑ-ÑÑнкÑии. diff --git a/obn-run-tests.sh b/obn-run-tests.sh index d809c75..404c840 100755 --- a/obn-run-tests.sh +++ b/obn-run-tests.sh @@ -33,3 +33,4 @@ maketest Test3 maketest Test4 maketest Test5 maketest Test6 +maketest Test7 diff --git a/rtl/SYSTEM.java b/rtl/SYSTEM.java index f98236b..38f4886 100644 --- a/rtl/SYSTEM.java +++ b/rtl/SYSTEM.java @@ -17,7 +17,6 @@ public class SYSTEM return i; } - /* ÐÑÑÑÐ¾ÐµÐ½Ð½Ð°Ñ Ð¿ÑоÑедÑÑа COPY(x, v) */ public static void COPY(byte[] x, byte[] v) { int len_x = LEN(x); diff --git a/src/oberon.c b/src/oberon.c index 1f33a03..36736a4 100644 --- a/src/oberon.c +++ b/src/oberon.c @@ -3644,11 +3644,11 @@ oberon_statement(oberon_context_t * ctx) index = oberon_ident_item(ctx, iname); oberon_assert_token(ctx, ASSIGN); from = oberon_expr(ctx); - oberon_assign(ctx, from, index); oberon_assert_token(ctx, TO); bound = oberon_make_temp_var_item(ctx, index -> result); to = oberon_expr(ctx); - oberon_assign(ctx, to, bound); + oberon_assign(ctx, to, bound); // ÑнаÑала temp + oberon_assign(ctx, from, index); // поÑом i if(ctx -> token == BY) { oberon_assert_token(ctx, BY);