Overview CastleCode portray
When translating CastleCode into RPy code, a valid RPY identifier is needed for every name (like an ‘ID’) used in the source code. On one hand, this translation should be stable, repeatable & predicable. But at the same time any valid CastleCode should result in a valid RPy (aka python) name – and never in a keyword of the backend.
We call this transformation “to portray”; describe and depict the source-code in an particular way (so that can be used by the (selected) Translator
The Sieve: CastleCode & RPy
In this article we study the well known The Sieve (basic variant).
See that link for the used code: chapter: Castle implementation; Tab: Sieve.
AIGR |
“CC text” |
RPY in |
portray: |
notes |
|---|---|---|---|---|
|
“implement Sieve {” |
|
|
see remark on __init__ |
|
“int myPrime;” |
|
a line in __init__ |
|
|
“int myPrime;” |
init(onPrime: |
TypeHint (only) |
“typing” needs more design |
|
“init (int:onPrime)” |
|
special: for init |
See note on __init__ |
|
“init(int: onPrime )” |
self._castle_init( |
in __init__
|
|
:class:` .ID==‘’` |
“ line id” |
|
|
_note_ |
:class:` .ID==‘’` |
“ line id” |
|
|
_note_ |
:class:` .ID==‘’` |
“ line id” |
|
|
_note_ |
:class:` .ID==‘’` |
“ line id” |
|
|
_note_ |
Castle Code (context) |
text (focus) |
(AIGR) Type/context |
RPY |
portray: |
notes |
|---|---|---|---|---|---|
implement Sieve { |
“Sieve” |
|
|
|
|
implement Sieve { |
|
The init method is generated as part of “implement” |
The ‘init’ in castleCode results in |
||
int myPrime; |
“myPrime” |
|
|
||
init(int:onPrime) { |
“init” |
|
|
special |
see remark on __init__; which calls |
init(int:onPrime) { |
“onPrime” |
|
|
||
super.init(); |
“super” |
|
|
In RPy: call |
Never a call/parameters in CastleCode; in RPY always empty call |
super.init(); |
“init” |
|
|
special |
see remark on __init__ |
.myPrime := onPrime; |
“myPrime” |
:class`Become` (targets) |
|||
.myPrime := onPrime; |
“onPrime” |
:class`Become` (targets) |
|||
“SimpleSieve.input(try) on .try” |
|
|
mangle/RPY style |
the AIGR-ID may be used as guidance |
|
“try” |
|
|
|
try is reserved in python |
|
“” |
:class:`` |
|
|
_note_ |
|
“” |
:class:`` |
|
|
_note_ |
|
“” |
:class:`` |
|
|
_note_ |
Comments
comments powered by Disqus