OSDev.org
https://forum.osdev.org/

CompilerDev?
https://forum.osdev.org/viewtopic.php?f=11&t=27178
Page 5 of 8

Author:  kutkloon7 [ Sun Aug 03, 2014 5:58 pm ]
Post subject:  Re: CompilerDev?

I'm thinking about registering the compilerdev.org domain and setting up a wiki, somewhere in the coming month. I've been messing with mediawiki on my local wamp server and it's really easy to set up. This is just a plan I started thinking about yesterday, so it's not something that I planned out carefully, but it feels like a good plan.

I've got a really rough sketch of the main page and the pages that look most important to me (I think that there need to be some basic pages before the wiki is open to everyone, because I would like to give the wiki a clear structure that is good for newbies to learn about the subject). Thing is, I'm really a newbie to compilers, so I would be kind of dependent on more experienced people to contribute to the wiki. I'd like to see that some people are suppporting (or opposing, I'd seriously like to hear your reasons if you're against the plan) the initiative before I spend a little money and a lot of effort on it. Especially, I'm hoping that there are some more experienced people willing to moderate. If I would set it up, the site would be unrelated to osdev.org (as in, you have to register as an user again, and there is no official relation with osdev.org). I don't plan to make a forum, but this is not too hard and if the compilerDev wiki seems alive enough, this is something that could be added later.

As for the design, I kind of copied it from osdev.org. I'm not sure about this, but I think this is OK (looking at the license at the bottom of the wiki).
For clarity: the screenshot is just for shits and giggles, the pages listed are currently non-existent and the structure is just a rough proposal that probably needs refinement, but seeing the topics in a structured way just got me really excited, and I hope it gets you guys too ;)

Anyway, this is something I didn't really think through, and I'm not really experienced with any of it (setting up a website, wiki's, compilers), but the first two things aren't too hard. Tips and help are more than welcome!

Attachments:
compilerdev.png
compilerdev.png [ 104.77 KiB | Viewed 5743 times ]

Author:  no92 [ Mon Aug 04, 2014 12:30 am ]
Post subject:  Re: CompilerDev?

I don't know whether we need a seperate compilerDev site. I mean, we've got the well-known OSDev.org and we can edit the Wiki (I already created a compiler section on the main page). I'd rather spend my efforts there, as the hosting/setup is already done years ago. And don't forget the forums, a Wiki without them wouldn't be as good as ours now.

In short, I'd prefer a compiler section over a seperate site.

Author:  Combuster [ Mon Aug 04, 2014 12:35 am ]
Post subject:  Re: CompilerDev?

A separate site always has problems with gaining the exposure you want. Especially if you template everything out with the conceptual grandness like you just did, it will look like one big empty place at first sight.

Author:  iansjack [ Mon Aug 04, 2014 1:35 am ]
Post subject:  Re: CompilerDev?

no92 wrote:
I don't know whether we need a seperate compilerDev site. I mean, we've got the well-known OSDev.org and we can edit the Wiki (I already created a compiler section on the main page). I'd rather spend my efforts there, as the hosting/setup is already done years ago. And don't forget the forums, a Wiki without them wouldn't be as good as ours now.

In short, I'd prefer a compiler section over a seperate site.

I think it is a mistake to conflate OS Development and Compiler Development. Although the two may often go together (and it is quite likely that someone interested in writing an OS may be interested in writing a compiler), this is not a given. A section on this Wiki misses the large audience who are interested in programming languages and compilers but have no interest in writing an OS.

I say go for it. Web hosting is cheap, or even free, and Wiki and forum software is readily available (definitely a good idea to have forums too). If it succeeds then great; if it fails then it's not the end of the world. Just be patient and realize that it may take time for people to find your site.

Author:  kutkloon7 [ Mon Aug 04, 2014 6:24 am ]
Post subject:  Re: CompilerDev?

Combuster wrote:
A separate site always has problems with gaining the exposure you want. Especially if you template everything out with the conceptual grandness like you just did, it will look like one big empty place at first sight.


Yes, that is what I'm afraid of: that people look at it, can't find what they want, and never return. I might take my time to write some necessary articles before I put anything online. I think that if I write the articles that are most helpful to newbies, and some articles that serve as a good reference, CompilerDev might a good resource to some people. But then, I don't know how far I'll get with writing the articles I want to write.

Eventually, the goal is, of course, to create a small community that reads and expands the wiki from time to time.

Btw, if you have any suggestions I'd be glad to hear them :)

Author:  AndrewAPrice [ Mon Aug 04, 2014 1:32 pm ]
Post subject:  Re: CompilerDev?

1) Get as many references, links to university courses etc, links to books, as you can. Maybe ask for permission if you can repost other peoples' work.

2) Start with a smaller homepage that emphasizes the info already on your wiki. Keep the one you have now somewhere else as a reference of what you'd like the aim for, but work towards it one article at a time. It's not good if your homepage is full of red links!

Author:  AndrewAPrice [ Tue Aug 05, 2014 10:19 pm ]
Post subject:  Re: CompilerDev?

Have you hear of the C2 wiki? They have a lot of useful information on language design, programming patterns, and even compilers.

Author:  kutkloon7 [ Wed Aug 06, 2014 3:30 pm ]
Post subject:  Re: CompilerDev?

Never heard of it before, no. Weird wiki :P There seem too be a lot of almost empty pages.
To avoid that on the compilerDev wiki, I started writing. It's probably gonna take more than a month before I have something that's worth to be put online.

Author:  Bencz [ Thu Aug 07, 2014 6:46 pm ]
Post subject:  Re: CompilerDev?

Develop a compiler, it is not a very simple task ... CAN BE SIMPLE, depending on what you are creating ....
If u want to create a simple compiler: https://drive.google.com/file/d/0B1nFzHmmj-jCWU8zRHVFUDV1aHc/edit?usp=sharing

But, developing a compiler, can be a very complex task... try to implement a LALR(1) parser.... Like used in C/C++ compiler... or in Elena language, developed by one friend, ( Elena Language site ), and try to implement in code-gen, a opcode generator, and not a simple asm text.... translate a high level languge to a low level... it's not so simple task TO...

U can study the TCC compiler..., for example, to develop a simple C compiler... u can start with developing a pre-processor system... after this, make a lexer, after parser and after an assembler!

Author:  Bencz [ Fri Aug 08, 2014 12:34 pm ]
Post subject:  Re: CompilerDev?

Look this simple, and very poor, sample..., it's is in C#

Code:
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPreProcessor
{
    public struct define
    {
        public string defName { get; set; }
        public string defValu { get; set; }
    }

    class PrePro
    {
        private string incDir = @"C:\cb\include\";
        private List<define> lsHash = new List<define>();
        //private StreamWriter sw;
        public PrePro(string fName)
        {
            //var fAux = fName.Split('.')[0] + ".ppo";
            //sw = new StreamWriter(fAux);
            parse(fName);
        }

        private void parse(string fileName)
        {
            var lines = File.ReadAllLines(fileName);

            foreach(var line in lines)
            {
                if (line.Trim().StartsWith("#include"))
                {
                    var aux = line.Replace("#include", "").Trim();

                    if (aux[0] == '<')
                        parse(incDir + (aux.Remove(0, 1).Remove(aux.Length - 2, 1)));
                    else if (aux[0] == '"')
                        parse(aux.Remove(0, 1).Remove(aux.Length - 2, 1));
                    else
                        throw new Exception("Erro");
                }
                else if (line.Trim().StartsWith("#define"))
                {
                    define def = new define();
                    bool findName = false;

                    for(int i=7;i<line.Length;i++)
                    {
                        if (line[i] == ' ')
                            continue;

                        if (findName == true)
                        {
                            def.defValu = line.Substring(i, line.Length - i);
                            break;
                        }
                        else
                        {
                            var temp = "";
                            for (int j = i; j < line.Length; j++)
                            {
                                if (line[j] == ' ')
                                {
                                    def.defName = temp;
                                    findName = true;
                                    i = j; // mode the index to correctly local
                                    break;
                                }
                                else
                                    temp += line[j];
                            }
                        }
                    }
                    lsHash.Add(def);
                }
                else
                {
                    for(int i=0;i<line.Length;)
                    {
                        if(line[i] == '"')
                            for(int j=i;j<line.Length;j++)
                            {
                                if (line[j] != '"')
                                {
                                    Console.Write(line[j]);
                                    i++;
                                }
                                else
                                {
                                    Console.Write(line[j]); // just to print the "
                                    i++;
                                    break;
                                }
                            }
                        else if(Char.IsNumber(line[i]))
                        {
                            do
                            {
                                Console.Write(line[i]);
                                i++;
                                if (i >= line.Length)
                                {
                                    break;
                                }
                            } while (Char.IsNumber(line[i]) || line[i] == '.');
                        }
                        else if(Char.IsLetter(line[i]) || line[i] == '_')
                        {
                            var aux = "";
                            do
                            {
                                aux += line[i];
                                i++;
                                if (i >= line.Length)
                                {
                                    break;
                                }
                            } while (Char.IsLetterOrDigit(line[i]) || line[i] == '_');

                            var temp = lsHash.Where(k => k.defName == aux).Select(t => t);
                            if (temp.Count() > 0)
                                Console.Write(temp.First().defValu);
                            else
                                Console.Write(aux);
                        }
                        else
                        {
                            Console.Write(line[i]);
                            i++;
                        }
                    }
                    Console.Write('\n');
                }
            }
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            new PrePro("main.c");
        }
    }
}


And the main.c code is that:
Code:
#include <stdio.h>

#define PI 3.14159

void main()
{
   int n;   // comment
   double sum = 0.0; /* comment */
  size_t test = 10;

   for (n = 1; n <= 10; n++) sum += PI / n;
   printf("sum = %.1f\n", sum);
}


The pre-processed source code is that:

Code:
// stdio.h


typedef struct _FILE {
    char*  _ptr;
    int    _cnt;
    char*  _base;
    int    _flag;
    int    _file;
    int    _charbuf;
    int    _bufsiz;
    char*  _tmpfname;
} FILE;

__declspec(import) FILE _iob[];

void    perror(const char *s);

int    printf(char *format, ...);
int    fprintf(FILE *fp, char *format, ...);
int    sprintf(char *str, char *format, ...);

int    scanf(char *format, ...);
int    sscanf(const char *str, const char *format, ...);

FILE    *fopen(char *filename, char *mode);
int    fclose(FILE *stream);
char    *fgets(char *s, int n, FILE *stream);
int    fread(void *buf, int size, int n, FILE *fp);
int  fwrite(const void *buf, int size, int n, FILE *fp);
char    *gets(char *s);
int    getchar();
int    putchar(int c);
int    puts(const char *s);
int    rename(const char *old, const char *new);
int     ungetc(int c, FILE *fp);


void main()
{
   int n;   // comment
   double sum = 0.0; /* comment */
  int test = 10;

   for (n = 1; n <= 10; n++) sum += 3.14159 / n;
   printf("sum = %.1f\n", sum);
}



Btw, with this, u just need to make the lexical and parser... in the parser u can make a simple PASM generator... just for study... in parser u will check the tokens and verify the semantics...

Author:  SoLDMG [ Fri Aug 08, 2014 2:13 pm ]
Post subject:  Re: CompilerDev?

I'd really like to have a compiler subforum. I'm willing to help people out since I'm writing my own toolchain from scratch, and the more knowledge that is shared the better the world becomes, right? It'd also help me out a lot, since I am growing sick of continuously searching shady pirate websites for bad quality PDFs of random books, like the poor cheapskate I am.

Author:  Bencz [ Fri Aug 08, 2014 2:52 pm ]
Post subject:  Re: CompilerDev?

I'd love to be able to contribute with one forum specific to compiler development!

Author:  Bencz [ Fri Aug 08, 2014 3:13 pm ]
Post subject:  Re: CompilerDev?

Can I create and host the site / forum / wiki

http://www.compdev.net

Good, ham...!

Author:  Columbus [ Sun Sep 14, 2014 4:40 am ]
Post subject:  Re: CompilerDev?

Why didn't you create a Wiki?
It it were one, I'd contribute to it.

Author:  Bencz [ Sun Sep 14, 2014 8:15 am ]
Post subject:  Re: CompilerDev?

Oh!

Because I was testing a system that my friend developed!

Page 5 of 8 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/