作者enthos (影斯作业系统)
看板Programming
标题Re: [问题] 在自制语言中,如何表示函数和物件
时间Tue Apr 25 01:35:28 2017
ici 4.x 完全符合你的规格。
parse.c: 不用 yacc/bison:
http://ici.cvs.sourceforge.net/viewvc/ici/ici/parse.c\
?revision=1.51&content-type=text%2Fplain
object.c
http://ici.cvs.sourceforge.net/viewvc/ici/ici/object.c\
?revision=1.43&content-type=text%2Fplain
https://sourceforge.net/projects/ici/
https://en.wikipedia.org/wiki/ICI_(programming_language)
http://ici.sourceforge.net/faq.html
http://atrn.org/ici/
What is ICI?
ICI is a C-like, high level language originally developed by
Tim Long and placed into the public domain. ICI marries
C's expression syntax, control structures and overall feel ,
with a dynamic, garbage collected, object-based, data model.
Although ICI superficially resembles C, and is easy to
use for C programmers, its data model is very different,
higher level with types such as (real) strings,
regular expressions, dynamic arrays, sets and dictionaries (struct).
ICI's aggregate types are immediately useful without any extra
programming typically required in C. ICI's automatic module loading,
memory management and error handling frees the programmer from much
of the drudgery associated with developing in C and lets you
concentrate on what
the program is doing rather than how it is doing it.
With programs that are not overly performance critical
or are I/O bound ICI makes a useful alternative to compiled
languages. Even for performance critical applications the
use of native-code modules in the correct areas is typically
all that is required to allow development in a higher level language.
作者: 我 看板: 我的公开个版(SayYA 资讯站,已倒站?)
标题: [ici] ICI 简介
时间: Sun Jul 14 07:01:53 2002
ICI 简介.
ICI source code is in public domain.
Homepage:
http://www.zeta.org.au/~atrn/ici/
Files:
http://www.zeta.org.au/~atrn/ici/distfiles/ici-3.0.1.tar.bz2
http://www.zeta.org.au/~atrn/ici/distfiles/ici-modules-0.2.0.tar.bz2
ICI Main FTP Site: (ici2)
ftp://ftp.research.canon.com.au/pub/misc/ici/
ICI Mail List:
Send mail to "
[email protected]"
With the text "subscribe" in the body of the message.
http://www.escribe.com/software/ici/index.html
Freebsd ports: (ici3, 3.0.1)
su -
cd /usr/ports/lang/ici
make install
CVS: (ici4)
cvs -d:pserver:
[email protected]:/cvsroot/ici login
cvs -d:pserver:
[email protected]:/cvsroot/ici co ici
cvs -d:pserver:
[email protected]:/cvsroot/ici co ici-modules
Related work:
CINT
http://root.cern.ch/root/Cint.html
Python
http://www.python.org
EiC
http://www.kd-dev.com/~eic (Artistic License)
elastiC
http://www.elasticworld.org
ici-3.0.1 的安装 makefile 似乎有点问题.
cp *core*.ici /usr/local/lib/ici/
ln -s /usr/local/lib/ici /usr/local/lib/ici3
ln -s /usr/local/include/ici /usr/local/include/ici3
cvs 中的版本要手动将 Makefile.linux 中的 ici3 改成 ici4,
移除 wrap, skt.
ICI 使用起来较顺手. (如果熟练 C 的话.)
而且内含 PCRE (Perl-compatible regular expressions) library.
与 perl 主要的语法不同是 perl: /regexp/ ici: #regexp#
标题: [ici] perl01.ici
时间: Fri Oct 31 21:30:39 2003
// [ici] perl01.ici
/*
perlreftut (p3 of 16)
如何表述一个值为串列的杂凑,是 Perl 4 中常出现的一个问题。 当然,Perl
4 有杂凑,但值需为纯量﹔不能是串列。
为什麽你会需要一个串列的杂凑? 让我们看看一个例子: 你有一个城市和国家
名称的档案,像这样:
Chicago, USA
Frankfurt, Germany
Berlin, Germany
Washington, USA
Helsinki, Finland
New York, USA
而你希望产生一个如下的输出,每个国家印一次,然後是这个国家中照字母顺序
排列的城市清单:
Finland: Helsinki.
Germany: Berlin, Frankfurt.
USA: Chicago, New York, Washington.
这是早先我所提出的问题的答案,关於如何重新编排一个国家和城市名称的档案
。
1 while (<>) {
2 chomp;
3 my ($city, $country) = split /, /;
4 push @{$table{$country}}, $city;
5 }
6
7 foreach $country (sort keys %table) {
8 print "$country: ";
9 my @cities = @{$table{$country}};
10 print join ', ', sort @cities;
11 print ".\n";
12 }
*/
// join() from ici 3.x icipath.ici
extern join(head, sep)
{
auto vargs = [array];
auto comp;
if (typeof(head) == "array") {
vargs = interval(head, 1);
head = head[0];
}
forall (comp in vargs)
head = sprintf("%s%s%s", head, sep, comp);
return head;
}
table = struct();
while(s = getline(stdin)) {
// tmp = s ~~~ #(.*), (.*)#; // Using PCRE library.
tmp = gettokens(s, ",");
city = tmp[0];
country = tmp[1];
if (table[country]) {
push(table[country], city);
} else {
table[country] = array(city);
}
}
// perl01.ici, 56: argument 1 of sort() incorrectly supplied as a struct
// forall(value, key in sort(table)) {
forall(value, key in table) {
printf("%s: ", key);
cities = sort(value);
// printf("%s", str.join(cities, ", ")); // ici 4.x with str module.
printf("%s", join(cities, ", "));
printf(".\n");
}
/*
ici perl01.ici // ici 4.x with str module.
Chicago, USA
Frankfurt, Germany
Berlin, Germany
Washington, USA
Helsinki, Finland
New York, USA
(Ctrl-D)
Segmentation fault
*/
/*
ici perl01.ici
Chicago, USA
Frankfurt, Germany
Berlin, Germany
Washington, USA
Helsinki, Finland
New York, USA
(Ctrl-D)
Germany: Berlin, Frankfurt.
USA: Chicago, New York, Washington.
Finland: Helsinki.
*/
※ 引述《Neisseria (Neisseria)》之铭言:
: 小弟先前没事写一个计算机
: 目前写了 lexer, parser, interpreter
: 有自制的 AST (abstract syntax tree)
: 为了练功,这些功能没依赖 yacc 或其他外部套件
: 有以下功能:
: - 可处理整数和浮点数
: - 有变数的概念,可 chained assignemnt
: - 简易代数运算,像 (123 + 45)**(5 % 3)
: - 常见数学公式,像指对数、三角函数等
: (直接 call host language 的相关功能)
: 卡在函数 (function) 和物件 (class) 不知道如何表示
: 希望板上各位大大提示一些方向
: 目前先以 interpreter 为目标
: 因 compiler 还牵涉到转机械码的过程
: 目前对小弟来说太硬了
: 先在这里谢过各位大大
--
https://youtu.be/MMWBPklrRB4 小鸡逼逼(崩溃版)
https://youtu.be/KlZL1hqGxDg 《江南夜色》
https://youtu.be/WIW16vMdrZU 《告白气球》
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 1.163.17.145
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Programming/M.1493055404.A.3AA.html
1F:推 Neisseria: 感谢大大提供资讯,可以好好读一下 175.180.97.241 04/25 06:22
2F:→ Neisseria: ICI 的程式码来学习程式语言 175.180.97.241 04/25 06:23