Charm (programming language)
≈ 3 min read
Names in other languages
No names in other languages are held for this entry yet.
Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.
Charm is a computer programming language devised in the early 1990s with similarities to the RTL/2, Pascal and C languages in addition to containing some unique features of its own. The Charm language is defined by a context-free grammar amenable to being processed by recursive descent parser as described in seminal books on compiler design. A set of Charm tools including a compiler, assembler and linker was made available for Acorn's RISC OS platform. Charm reworked for RISC OS platforms has subsequently been reviewed in Archive magazine. Charm is further described in the e-book Programming in Charm on the Raspberry Pi.
Charm is a computer programming language devised in the early 1990s with similarities to the RTL/2, Pascal and C languages in addition to containing some unique features of its own. The Charm language is defined by a context-free grammar amenable to being processed by recursive descent parser as described in seminal books on compiler design. A set of Charm tools including a compiler, assembler and linker was made available for Acorn's RISC OS platform. Charm reworked for RISC OS platforms has subsequently been reviewed in Archive magazine. Charm is further described in the e-book Programming in Charm on the Raspberry Pi. References to data constructs and procedures may be made using the keyword. These can be dereferenced using the keyword. When using reference variables, comparison operators are available to check whether two reference variables refer to the same item of data ( :=: ) or whether the data they point to is the same ( = ). ext proc write_string (ref array char); module hello; ent proc start (); write_string ("Hello world"); end_proc; end_module; and the equivalent latest version following evolutionary syntactic language changes is: import lib.Out; module Hello { export proc ~start () { Out.vdu.str ("Hello world"). nl(); } } The Charm compiler is a recursive descent single pass compiler which parses Charm source code to generate quadruples of the form result := lhs op rhs in an intermediate language that supports arithmetic, logical and flow of control operations. Data is stored in temporaries which are assigned to registers and memory locations in the back end of the compiler. Two back ends are currently in existence, one generating Motorola 68000 assembly language, and the other generating ARM architecture. The quadruple output from the hello world example is: param l1$ call write_string[proc (ref array char) void] and the assembler output is: string "hello" xdef _start align _start xref _write_string stmfd sp!,{rp} adr r0,_l1$ bl _write_string ldmfd sp!,{pc} address align _l1$ string "Hello world" direct end In more recent releases of Charm, the I/O procedures have been split into their own modules In and Out. Other standard library procedures are organised into a set of records with procedure references as fields. As part of this reorganisation, the write_string method is now invoked through the run time library module Out via static member reference .vdu as procedure str i.e. in the hello world example above write_string ("Hello world") becomes Out.vdu.str ("Hello world") .
Text derived from https://en.wikipedia.org/w/index.php?oldid=1311023135 under CC BY-SA 4.0; modifications have been made.