Skip to content

Commit

Permalink
public release 4.0.4 on January 2nd 2022
Browse files Browse the repository at this point in the history
  • Loading branch information
ycaseau committed Jan 2, 2022
1 parent c41035e commit cd074d1
Show file tree
Hide file tree
Showing 58 changed files with 1,527 additions and 1,379 deletions.
2 changes: 1 addition & 1 deletion compile/goexp.cl
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ g_expression(self:Call_method,s:class) : void -> inline_exp(PRODUCER,self,s)
g_expression(a1, list),
g_expression(a2, integer),
g_expression(a3, any)) */
else if (m.selector = add_slot & getC(a1) % class)
else if (m.selector = add_slot & a1 % class)
printf("~IF_close_slot(~I.AddSlot(~I,~I,~I))", preCore?(),
g_expression(a1,class),
g_expression(a2,property), // property
Expand Down
6 changes: 5 additions & 1 deletion compile/gomain.cl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
printf(" -f <filename> : load <filename> \n"),
printf(" -n : do not load the init file \n"),
printf(" -m <module> : load <module> \n"),
printf(" -mx <module> : load <module> and launch main() \n"),
printf(" -v <int> : sets the verbosity level \n"),
printf(" -S <flag> : sets the global variable <flag> to true \n"),
printf(" -o <name> : sets the name of the executable \n"),
Expand All @@ -55,9 +56,12 @@
printf(" -D : debug mode \n"),
printf(" -safe : safe mode \n"),
printf(" -O : optimizing mode \n"),
printf(" -O2 : super optimizing mode (no bound checks) \n"),
printf(" -cm <module>: compiles a module -> executable \n"),
printf(" -cc <module>: compiles a module -> target go files \n"),
printf(" -cx <module> : generates system file associated to a module \n"),
printf(" -cx <module> : compiles a module & launch main() \n"),
printf(" -sf <module> : generates system file associated to a module \n"),
printf(" -sx <module> : generates system file that includes main() \n"),
exit(0) ]


Expand Down
4 changes: 3 additions & 1 deletion compile/ocall.cl
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ c_code(self:Call) : any -> c_code_call(self,void)
else if (s % OPT.to_remove // v2.4.12 c_interface is special
| (s = c_interface & length(l) = 2 &
not(get_module(s) % OPT.legal_modules))) nil
else if known?(d) d
else if known?(d) d // direct access case - THIS IS UGLY ! very old style, should be replaced ....
else if (m % method) c_inline(m, l, c_srange(m))
else if (s % {=, !=} & known?(daccess(l[1], true)))
c_code_hold(l[1].args[1] as property, l[1].args[2], l[2], s = =)
Expand Down Expand Up @@ -262,6 +262,8 @@ c_code(self:Call) : any -> c_code_call(self,void)
arg = c_code(l[2], psort(domain!(xs))),
test = false)
else unknown),
Call_method2 (if (self.arg.selector = get) daccess(Call(get,self.args),b)
else unknown), // v4.0 should work on optimized call
any unknown) ]

c_type(self:Call_slot) : type -> self.selector.range
Expand Down
2 changes: 1 addition & 1 deletion compile/ocontrol.cl
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ iterate(x:array,v:Variable,e:any) : any
while (%i <= %max) let v := %a[%i] in (e, %i :+ 1))

Iterate(x:class,v:Variable,e:any) : any
=> (for %v_1 in x.descendents
=> (for %v_1 in x.descendants
let %v_2 := (for v in %v_1.instances e) in (if %v_2 break(%v_2)))

Iterate(x:..[tuple(integer, integer)],v:Variable,e:any) : any
Expand Down
14 changes: 7 additions & 7 deletions compile/odefine.cl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//+-------------------------------------------------------------+
//| CLAIRE |
//| odefine.cl |
//| Copyright (C) 1994 - 2013 Yves Caseau. All Rights Reserved |
//| Copyright (C) 1994 - 2022 Yves Caseau. All Rights Reserved |
//| cf. copyright info in file object.cl: about() |
//+-------------------------------------------------------------+

Expand Down Expand Up @@ -130,7 +130,7 @@ c_code(self:Definition,s:class) : any
-> let ins?:boolean := ((c.open = 3 | c.open = 1) & not(lp)), // PATCH! (lp non nil <=> thing => c.instances taken care of)
r := list<any>{ (let p := x.args[1], y := x.args[2],
s := (p @ c), special? := (p.open = 0 & s % slot) in
(lp :add p,
(lp :add! p,
Call((if special? put else write),
list(p, self,
(if (not(special?) | c_type(y) <= s.range) y
Expand All @@ -152,7 +152,7 @@ c_code(self:Definition,s:class) : any

// creation of a new named object
c_code(self:Defobj,s:class) : any
-> let %c := self.arg, o := get(self.Language/ident),
-> let %c := self.arg, o := value(self.Language/ident),
%v := (if (known?(o) & not(o % global_variable)) o
else Variable!(*name*, (OPT.max_vars :+ 1, 0), %c)),
%y1 := Call(object!, list(self.Language/ident, %c)),
Expand All @@ -170,7 +170,7 @@ c_code(self:Defobj,s:class) : any

// creation of a new named object
[c_code(self:Defclass,s:class) : any
-> let %name := self.Language/ident, o := get(%name),
-> let %name := self.Language/ident, o := value(%name),
%create := (if known?(o) Call(class!, list(%name, self.arg))
else error("[internal] cannot compile unknown class ~S",%name)),
%x := Do( %create cons
Expand Down Expand Up @@ -374,7 +374,7 @@ compile_lambda(self:string,l:lambda,m:any) : any
// how to compile an table definition
[c_code(self:Defarray) : any
-> let a := (self.arg as Call).args,
%a := get(extract_symbol(a[1])),
%a := value(extract_symbol(a[1])),
%v := (case %a (table %a, any error("[internal] the table ~S is unknown", a[1]))),
s := %a.domain,
e := (let l := cdr(a),
Expand Down Expand Up @@ -553,7 +553,7 @@ Compile/lexical_num(self:any,n:integer) : void
-> (case self
(Call lexical_num(self.args, n),
Instruction let %type:class := self.isa in
(if (%type % Instruction_with_var.descendents)
(if (%type % Instruction_with_var.descendants)
(put(index, self.var, n),
n := n + 1,
if (n > *variable_index*) *variable_index* := n),
Expand All @@ -568,7 +568,7 @@ c_type(self:Defrule) : type -> any

// compile a rule definition
c_code(self:Defrule,s:class) : any
-> let ru := get(self.iClaire/ident), l := list<any>() in
-> let ru := value(self.iClaire/ident), l := list<any>() in
(//[5] compile a rule ~S // ru,
for r in Language/relations[ru]
(if not(Language/eventMethod?(r)) Tighten(r)), // ensures better code generation
Expand Down
2 changes: 1 addition & 1 deletion compile/osystem.cl
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ claire/OPT :: meta_OPT(
simple_operations = set<property>(+, -, /, *), // v3.3
non_identifiable_set =
Id(set<class>{c in ((class but integer) but float) |
exists(c2 in c.descendents | c2.ident? = false)}))
exists(c2 in c.descendants | c2.ident? = false)}))


// pragma for the compiler => MOVED TO LANGUAGE in CLAIRE 4
Expand Down
2 changes: 1 addition & 1 deletion compile/otool.cl
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ get_indexed(c:class) : list -> c.slots


// OPT.non_identifiable_set: those sets who are identifiable (closure)
// set<class>{c in class | exists(c2 in c.descendents | c2.ident? = false)})
// set<class>{c in class | exists(c2 in c.descendants | c2.ident? = false)})

// equality is identity?
[Compile/identifiable?(self:any) : boolean
Expand Down
Binary file added docs/CLAIRE-EPITA-Février2014.pdf
Binary file not shown.
Binary file added docs/CompilerTable.pptx
Binary file not shown.
Binary file added docs/claire-4-0.pdf
Binary file not shown.
Binary file added docs/claire98.pdf
Binary file not shown.
7 changes: 6 additions & 1 deletion init.cl
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,15 @@ bu14 :: module( uses = list(Reader), source = *bsrc*,
bu15 :: module( uses = list(Reader), source = *bsrc*,
made_of = list("bstub", "bug15"))

// sudoku example : need to put in the doc - good example of rules & branch
// sudoku example : shown in the tutorial - good example of rules & branch
bu16 :: module( uses = list(Reader), source = *bsrc*,
made_of = list("bstub", "sudoku"))

// other examples from rge claire manual : need to put in the doc - good example of rules & branch
bu17 :: module( uses = list(Reader), source = *bsrc*,
made_of = list("bstub", "manual"))



// ***************************************************************************
// * Part 4: Simple rule examples *
Expand Down
10 changes: 5 additions & 5 deletions meta/control.cl
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ self_print(self:For) : void
self_eval(self:For) : any
-> (let x := eval(self.set_arg) in
(try case x
(class for y in x.descendents
(class for y in x.descendants
for z in y.instances
(write_value(self.var, z), eval(self.arg)),
list for z in x
Expand Down Expand Up @@ -230,7 +230,7 @@ self_eval(self:Collect) : any
-> (let x := eval(self.set_arg),
res:list := empty_list((if known?(of,self) self.of else {})) in
(case x
(class for y in x.descendents
(class for y in x.descendants
for z in y.instances
(write_value(self.var, z), res :add eval(self.arg)),
list for y in x
Expand Down Expand Up @@ -276,7 +276,7 @@ self_eval(self:Select) : any
-> (let x := eval(self.set_arg),
res:set := empty_set((if known?(of,self) self.of else {})) in
(case x
(class for y in x.descendents
(class for y in x.descendants
for z in y.instances
(write_value(self.var, z),
if (eval(self.arg) != false) res :add z),
Expand Down Expand Up @@ -305,7 +305,7 @@ self_eval(self:Lselect) : any
-> (let x := eval(self.set_arg),
res:list := (case x (list empty(x), any list())) in
(case x
(class for y in x.descendents
(class for y in x.descendants
for z in y.instances
(write_value(self.var, z),
if (eval(self.arg) != false) res :add z),
Expand Down Expand Up @@ -339,7 +339,7 @@ self_eval(self:Exists) : any
b := self.other,
res:any := b in
(case x
(class for y in x.descendents
(class for y in x.descendants
for z in y.instances
(write_value(self.var, z),
if (eval(self.arg) != false)
Expand Down
10 changes: 5 additions & 5 deletions meta/define.cl
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ self_eval(self:Defobj) : any
// creation of a new named object
// note that final() is the marker of a forward definition in CLAIRE4
self_eval(self:Defclass) : any
-> (if (get(self.ident) % class &
( (get(self.ident) as class).open != final() | // new in v2.5
self.arg != (get(self.ident) as class).superclass))
-> (if (value(self.ident) % class &
( (value(self.ident) as class).open != final() | // new in v2.5
self.arg != (value(self.ident) as class).superclass))
error("[107] class re-definition is not valid: ~S",self)
else let %o := class!(self.ident, self.arg) in
(for x in self.args
Expand Down Expand Up @@ -535,7 +535,7 @@ eval_rule :: property(open = 3)
self_eval(self:Defrule) : any
-> (if (self.args[1] != system) eval_rule(self) // hook for ClaireRules engine
else let %condition := self.arg,
ru := get(self.iClaire/ident) in // name of the rule
ru := value(self.iClaire/ident) in // name of the rule
(put(isa, ru, rule_object),
add!(rule_object.instances,ru),
let (R,lvar) := make_filter(%condition) in
Expand Down Expand Up @@ -766,5 +766,5 @@ makeCallMatch(x:restriction,lt:list) : boolean
method.open := final(),
slot.open := final(),
boolean.open := -1,
for x in Instruction.descendents (x.open := default())) // instuctions are ephemeral
for x in Instruction.descendants (x.open := default())) // instuctions are ephemeral

6 changes: 3 additions & 3 deletions meta/file.cl
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ reader :: meta_reader(space = 202,
// reads a variable
//
extract_variable(self:any) : Variable
-> (if (case self (Variable get(self.mClaire/pname) != self))
-> (if (case self (Variable value(self.mClaire/pname) != self))
(put(range, self as Variable, extract_type(self.range)),
self as Variable)
else let v := Variable(mClaire/pname = extract_symbol(self)) in
Expand All @@ -109,7 +109,7 @@ extract_variable(self:any) : Variable
// create a variable and add it to the lexical environment
bind!(self:meta_reader,%v:Variable) : list
-> (put(index, %v, self.index),
let value := get(%v.mClaire/pname) in
let value := value(%v.mClaire/pname) in
(put(index, self, self.index + 1),
if (self.index > self.maxstack) put(maxstack, self, self.index),
put(%v.mClaire/pname, %v),
Expand Down Expand Up @@ -380,7 +380,7 @@ claire/kill(self:object) : any

claire/kill(self:class) : any
-> (while self.instances kill(self.instances[1]),
for x in self.descendents (if (x.superclass = self) kill(x)),
for x in self.descendants (if (x.superclass = self) kill(x)),
kill@object(self))

// our two very special inline methods
Expand Down
2 changes: 1 addition & 1 deletion meta/function.cl
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ claire/unsafe(x:any) : any -> x
// declares a class as ephemeral: the member set is not maintained
// v3.2.14 recusively applies to subclasses
ephemeral(self:class) : any
-> (for c in self.descendents
-> (for c in self.descendants
(if c.instances error("[187] cannot declare ~S as ephemeral because of ~S has instances",self,c)
else put(open, c, system.default)))

Expand Down
2 changes: 1 addition & 1 deletion meta/method.cl
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ uniform(p:property) : boolean
[hashinsert(m:restriction) : any
-> // if (verbose() = 4) //[0] hashinsert(~S) // m,
let c := (domain!(m) as class) in
for c2 in c.descendents hashinsert(c2, (m as method)) ]
for c2 in c.descendants hashinsert(c2, (m as method)) ]

// insert into the hash table - since the order is not garanteed when we build the dictionary, we
// need to check that m is more suited than anything that could be there
Expand Down
6 changes: 3 additions & 3 deletions meta/pretty.cl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ iClaire/index :: mClaire/index
self_print(self:unbound_symbol) : void
-> printf("~A", self.name)
self_eval(self:unbound_symbol) : any
-> (if (get(self.name) % thing) eval(get(self.name))
-> (if (value(self.name) % thing) eval(value(self.name))
else error("[145] the symbol ~A is unbound", self.name))

// A lexical variable is defined by a "Let" or inside a method's definition
Expand Down Expand Up @@ -164,7 +164,7 @@ lexical_build(self:any,lvar:list,n:integer) : any
(put(selector, self, call),
put(args, self, s cons self.args))),
Instruction let %type:class := self.isa in
(if (%type % Instruction_with_var.descendents)
(if (%type % Instruction_with_var.descendants)
(put(index, self.var, n),
n := n + 1,
if (n > *variable_index*)
Expand Down Expand Up @@ -219,7 +219,7 @@ make_a_property(self:any) : property
-> (case self
(global_variable make_a_property(value(self)),
property self,
symbol let x := get(self) in
symbol let x := value(self) in
(case x (property make_a_property(x),
global_variable make_a_property(value(x)),
any let p := (mClaire/new!(property, self) as property) in
Expand Down
8 changes: 4 additions & 4 deletions meta/types.cl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ claire/-- :: operation(precedence = precedence(..))
set list!(self),
array list!(self),
class let l := list<object>() in
(for c in self.descendents l := l /+ c.instances, l),
(for c in self.descendants l := l /+ c.instances, l),
Interval --!(self.arg1,self.arg2),
integer list!(make_set(self)),
collection list!(set!(self)), // TODO : change to list!(self)
Expand Down Expand Up @@ -231,15 +231,15 @@ size(x:list) : integer -> size(set!(x))
// class -> return a read-only list (v3.2)
set!(x:class) : set
-> let rep := list() in
(for c in x.descendents
(for c in x.descendants
(if (inherit?(c,primitive) & c != boolean)
error("[178] cannot enumerate ~S",c)
else rep := rep /+ c.instances),
set!(rep))

size(self:class) : integer
-> let n:integer := 0 in
(for x in self.descendents n :+ length(x.instances), n)
(for x in self.descendants n :+ length(x.instances), n)


// Union
Expand Down Expand Up @@ -562,7 +562,7 @@ claire/make_set(x:integer) : set -> {i in (0 .. 29) | x[i]}
// we create some types that we need
(set_range(subclass, class, set<class>),
set_range(ancestors, class, list<class>),
set_range(descendents, class, set<class>),
set_range(descendants, class, set<class>),
set_range(definition, property, list<restriction>),
set_range(restrictions, property, list<restriction>),
set_range(domain,restriction,list<type_expression>),
Expand Down
Loading

0 comments on commit cd074d1

Please sign in to comment.