CompilerDev?

All off topic discussions go here. Everything from the funny thing your cat did to your favorite tv shows. Non-programming computer questions are ok too.
kutkloon7
Member
Member
Posts: 98
Joined: Fri Jan 04, 2013 6:56 pm

Re: CompilerDev?

Post by kutkloon7 »

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
no92
Member
Member
Posts: 307
Joined: Wed Oct 30, 2013 1:57 pm
Libera.chat IRC: no92
Location: Germany
Contact:

Re: CompilerDev?

Post by no92 »

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.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: CompilerDev?

Post by Combuster »

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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
iansjack
Member
Member
Posts: 4685
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: CompilerDev?

Post by iansjack »

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.
kutkloon7
Member
Member
Posts: 98
Joined: Fri Jan 04, 2013 6:56 pm

Re: CompilerDev?

Post by kutkloon7 »

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 :)
User avatar
AndrewAPrice
Member
Member
Posts: 2299
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: CompilerDev?

Post by AndrewAPrice »

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!
My OS is Perception.
User avatar
AndrewAPrice
Member
Member
Posts: 2299
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: CompilerDev?

Post by AndrewAPrice »

Have you hear of the C2 wiki? They have a lot of useful information on language design, programming patterns, and even compilers.
My OS is Perception.
kutkloon7
Member
Member
Posts: 98
Joined: Fri Jan 04, 2013 6:56 pm

Re: CompilerDev?

Post by kutkloon7 »

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.
Bencz
Member
Member
Posts: 27
Joined: Tue Nov 09, 2010 12:03 pm

Re: CompilerDev?

Post by Bencz »

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/0B1nFzH ... sp=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!
Bencz
Member
Member
Posts: 27
Joined: Tue Nov 09, 2010 12:03 pm

Re: CompilerDev?

Post by Bencz »

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

Code: Select all

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: Select all

#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: Select all

// 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...
User avatar
SoLDMG
Member
Member
Posts: 96
Joined: Wed Jul 23, 2014 8:00 am
Location: The Netherlands
Contact:

Re: CompilerDev?

Post by SoLDMG »

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.
My post is up there, not down here.
Bencz
Member
Member
Posts: 27
Joined: Tue Nov 09, 2010 12:03 pm

Re: CompilerDev?

Post by Bencz »

I'd love to be able to contribute with one forum specific to compiler development!
Bencz
Member
Member
Posts: 27
Joined: Tue Nov 09, 2010 12:03 pm

Re: CompilerDev?

Post by Bencz »

Can I create and host the site / forum / wiki

http://www.compdev.net

Good, ham...!
Columbus
Posts: 18
Joined: Sat Sep 13, 2014 2:26 am

Re: CompilerDev?

Post by Columbus »

Why didn't you create a Wiki?
It it were one, I'd contribute to it.
Bencz
Member
Member
Posts: 27
Joined: Tue Nov 09, 2010 12:03 pm

Re: CompilerDev?

Post by Bencz »

Oh!

Because I was testing a system that my friend developed!
Post Reply