Re: more idle thinking: SiMPL
- From: "Rod Pemberton" <do_not_have@xxxxxxxxxxxxx>
- Date: Fri, 25 Sep 2009 17:47:29 -0400
"BGB / cr88192" <cr88192@xxxxxxxxxxx> wrote in message
consider running C on something like the ActionScript VM.
the lack of a byte-centric memory model is likely to put a bit of a cramp
pi=&x; //what, you mean I can't do this?...
Well, it might be possible to construct an artificial C style address
start by me making some wild assumptions based on info from Wikipedia's
1) strings are available
2) arrays are available
3) memory for strings and arrays are dynamicly allocated, or actually hidden
behind some object action, like .push()
4) the memory allocated for each object, like strings and arrays, is
contiquous or sequentially allocated
5) strings and arrays are indexable/subscriptable...
6) the language is object-oriented, so an .length action should be available
for strings and arrays... (?)
So, to create an address system, you need to have a unique address for each
object and an index/offset/subscript where necessary. You also need the
size of objects. A hash function could generate unique "addresses" from an
object's name, e.g., to simulate the & address operator. A reverse hash
could return the object's name from the address, e.g., to simulate
dereferencing done by the * indirection operator. The strings and arrays
should be indexable or subscriptable with native language features. And,
the sizeof() the object could come from the .length action, or a "fake"
value table for int's since it should be fairly easy to determine sizes for
them. I think that should be about enough to comply with C, in theory...
areas...Technically, the spec.'s don't mandate a memory model. However, yeah,
of issues you have to solve if you're not on a "byte-centric" machine...
Obviously, the proper way is to rewrite the C without pointer usage, using
"arrays" or the subscript (or offset) operator, and then port it.
usually, this is done through keeping the syntax regular andparty
context-independent, but at the same time, this may cost some in terms of
"syntactic niceties", since these niceties are often special-case hacks in
the parser, and as such, adding them makes it more work to write a 3rd
parser (since they will also have to deal with all these littlespecial-case
Well, you could parse the language, and then add extra info where it's
needed to the source code. E.g., you could insert implicit int's, or add a
keyword to indicate typedef's, or convert "long long" to a single word.
That would make it easier for other parsers. If they don't what your extra
info, they just use a C pre-processor to #define it away.
You could also take the idea I'm using in my assembler and emit unique
characters infront of keywords, variables, hex integers, octal integers,
strings, characters, etc. so someone else's parser could be much simpler to
implement. E.g., if the parser sees ".while", it uses "." to indicate a
keyword immediately follows. Or, you might be able to emit and embed the
important info from the AST into the source code.
- Prev by Date: Re: more idle thinking: SiMPL
- Next by Date: Re: Comparison of programming language features
- Previous by thread: Re: more idle thinking: SiMPL
- Next by thread: Re: more idle thinking: SiMPL