Hi,
LoseThos wrote:How I started was by placing the text of files I wanted to compile inside my turbo asm's output kernel binary image. I then made an interpreter. For the command-line you need an interpreter and you probably want to parse batch-file scripts of some sort. The scripts I wanted done, i placed into the binary image before I had a file system.
For parser you make a lexical analyser which filters-out comments, gets the next tolken, a string, an indentifier, a number, etc. The parser must handle expressions. You can do a LR parse if you look it up, but it's not efficient. Anyway, you'll probably want to build an expression tree and a function to evaluate an expression.
Eventually, i converted from an interpreter to a compiler -- pretty easy. I made a file system. I have low level routines to read and write blocks, a routine to allocate a block (or cluster), routines to make a directory entry, delete a directory entry or find directory entries, read and write files by allocating clusters and storing data.
It's a lot of work. Are you doing it to have fun? You might want to use more stuff from other people, i don't know.
The rule of thumb on these forums is to
answer the question given, not one you make up so that you can give a commentary as to how you implemented something.
The OP asked a question. He expects an answer, not a paragraph on how you made a LR(1) parser.
LoseThos wrote:Why bother doing an operating system if you start with a standard library?
Some people prefer to implement parts at a time, and use pluggable components written by others that definitely work until they know the code that they wrote themselves works. It's a type of unit-design methodology.
Others prefer not to write every component of their
hobby OS project, and just write the stuff they are interested in, which may or may not include the grime of writing a C library (see Solar's PDCLib for how long a properly implemented and tested portable C library takes to implement).
Either way it is irrelevant to the OP's question.
Explain what your goals are.
I believe he explained his goal - to use newlib as the C library in his OS.
I use nothing standard and use not a single line of code from elsewhere.
That's very clever of you. I'm sure many people will pat you on the back for reinventing the wheel. I'm not one of them.
Suppose you speak spanish, make the key words spanish and non ASCII.
On what evidence do you base this supposition?
I laugh at all the people who are not patient and use other people's code. It give the appearance of getting stuff done fast, but in the end, you've accomplished nothing but plugged together a few modules. If you're playing around, set less ambitious goals. Be patient and do it from scratch.
I laugh at people who feel the only way to accomplish anything is to write every line of code yourself. Actually, that's a lie. I don't laugh at anyone because of their design methodologies and personal inclinations. You seem to, however.
Realistically using others' code in certain places in your own solution can be a good thing. It helps you learn to interface with prewritten code, and to read and understand specifications and documentation, which are essential life skills in the world of software engineering.
@quanganht:
Those functions are POSIX-standard. Look them up in the
POSIX specification to see how they should behave and what their proper signature is.
Normally you implement these functions yourself and "glue" them into newlib, using one of several methods. See
Porting Newlib for full documentation.
Cheers,
James