📄 test_05.mal
字号:
# Monet Mil to Mal compiler# Copyright (c) 2001-2004, CWI. All rights reserved.#Predefined code segment#The compiler can not guarantee an accurate compilation,#because MIL unlike MAL is a dynamically typed language.#A few guidelines to maximize usefullness.#- make the type of variables explicit, in particular 'nil'#- upon advice of M2m to remap identifiers, change it in your program directly#use the "mil_schema" for additional support routines# io.print("setoid(oid(20000000));"); aa_a := calc.oid(20000000); ba_a := calc.setoid(aa_a);# io.print("# escape sequences\n");# io.print("# first some basics, escaped characters are normalized\n");# io.print("print(\"got single quote ' .\");\t# remove superfluous escapes"); ca_a := io.print("got single quote ' .");# io.print("# remove superfluous escapes\n"); da_a := io.print("got single quote ' without escape");# io.print("print(\"got tab \t and single newline \n .\");"); ea_a := io.print("got tab \t and single newline \n .");# io.print("print(\"problem signalled before \\\"\");"); fa_a := io.print("problem signalled before \\\"");# io.print("var t0:= \"got single quote ' .\";\tt0.print();"); t0 := "got single quote ' ."; ga_a := io.print(t0);# io.print("var t1:= \"got single quote ' without escape\";\tt1.print();"); t1 := "got single quote ' without escape"; ha_a := io.print(t1);# io.print("var t2:= \"got tab \t and single newline \n .\"; t2.print();"); t2 := "got tab \t and single newline \n ."; ia_a := io.print(t2);# io.print("var t3:= \"problem signalled before \\\"\"; t3.print();"); t3 := "problem signalled before \\\""; ja_a := io.print(t3);# io.print("# character constants\n"); c0 := "\n"; ka_a := io.print(c0);# io.print("var c1:= \"'\"; c1.print();"); c1 := "'"; la_a := io.print(c1);# io.print("var c2:= \"\\\"; c2.print();"); c2 := "\\"; ma_a := io.print(c2);# io.print("var s:=new(int,str,100);"); s := bat.new(nil:int,nil:str,100);# io.print("s.insert(2,\" single quote ' got it\");"); na_a := bat.insert(s,2," single quote ' got it");# io.print("s.insert(4,\" backslash \\ \");"); oa_a := bat.insert(s,4," backslash \ ");# io.print("s.insert(3,\" single quote ' \");"); pa_a := bat.insert(s,3," single quote ' ");# io.print("s.print();"); qa_a := io.print(s);# io.print("# Monet printf should behave as in C\n"); ra_a := io.printf("got single quote ' .\n");# io.print("# remove superfluous escapes\n"); sa_a := io.printf("got single quote ' without escape\n");# io.print("printf(\"got tab \t and newline \n .\n\");"); ta_a := io.printf("got tab \t and newline \n .\n");# io.print("printf(\"problem signalled before \\\"\n\");"); ua_a := io.printf("problem signalled before \\\"\n");# io.print("quit();"); va_a := clients.quit();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -