flat assembler
Message board for the users of flat assembler.

Index > High Level Languages > Trying to make a higgh level language

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
Thaorius



Joined: 27 Jul 2006
Posts: 42
Thaorius
Hi!

Well, i'm trying to make my own high level programming language, with a compiler that generates asm code(fasm syntax) and then run fasm to make the executable files.

I being researching about this topic, and well... make some tests. The problem is, does Flex and Bison generated programs provide an output? the only thing I could finish was a basic english parser and lexer, but... the problem is that there was no tokenized output to work with. I don't kwon if you understand me, i'm just a little confused about input and output of flex and bison.

Does anyone have usefull information about them?

Thanks
Post 24 Aug 2006, 21:30
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
Kain



Joined: 26 Oct 2003
Posts: 108
Kain
You might get better answers on a flex/bison related forum. You could also take a look at the HLA sources. HLA is a high-level Assembler that can generate FASM code and is built around C/Flex/Bison.

Better yet, forget about Flex/Bison and do the whole thing in FASM! If I remember correctly, someone wrote a tiny-c compiler in FASM which may come in handy.
Post 25 Aug 2006, 02:14
View user's profile Send private message Reply with quote
bubach



Joined: 17 Sep 2004
Posts: 341
Location: Trollhättan, Sweden
bubach
Do you remeber where that tiny C compiler is? I would like to take a look at it.
Post 26 Aug 2006, 13:47
View user's profile Send private message Reply with quote
okasvi



Joined: 18 Aug 2005
Posts: 382
Location: Finland
okasvi
I believe that tiny-'C' compiler in fasm is Context 2.0:
http://www.avhohlov.narod.ru/p9810en.htm
Post 26 Aug 2006, 14:10
View user's profile Send private message MSN Messenger Reply with quote
Kain



Joined: 26 Oct 2003
Posts: 108
Kain
Here you can find a small-c compiler for Menuet

http://www.menuetos.org/stuff32.htm



There is also an LCC port to Menuet

http://meos.sysbin.com/viewtopic.php?t=535
Post 27 Aug 2006, 06:13
View user's profile Send private message Reply with quote
Jack



Joined: 16 Feb 2005
Posts: 21
Jack
have a look BDS C http://www.bdsoft.com/resources/bdsc.html
Quote:

I, Leor Zolman, hereby release all rights to BDS C
(all binary and source code modules, including compiler,
linker, library sources, utilities, and all documentation) into the Public Domain. Anyone is free to download, use,
copy, modify, sell, fold, spindle or mutilate any part of
this package forever more. If, however, anyone ever
translates it to BASIC, FORTRAN or C#, please don'ttell me.
Leor Zolman
9/20/2002
Post 27 Aug 2006, 23:15
View user's profile Send private message Reply with quote
Thaorius



Joined: 27 Jul 2006
Posts: 42
Thaorius
I'm going to do it in C/C++ because i want it to run on linux platform as well.

Basically i want an hybrid between c++/c#/java/php/lua.

I will look at the c compiler any way.

As far as i now:

-Lexer
-Parser
-Code Generation? do i need to do this if i just want to output fasm assembler? there is some program that generate the code generator like flex por lexer's and bison por parser's?

Thanks
Post 28 Aug 2006, 02:52
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
zubi



Joined: 27 Apr 2006
Posts: 25
Location: Turkey
zubi
Hi,

I have passed through a similar process. I made a compiler that generates asm code to be compiled with fasm.

I strongly recommend you to check out GOLD Parsing system, A Free, Multi-Programming Language, Parser at http://www.devincook.com/goldparser/. There are bunch of engines written for that program in different languages, that tokenize your input according to your grammar. I wrote a rudimentary assembly engine for GOLD which you can find at the downloads section of that site. Unfortunately it is written for MASM and it is buggy but if you decide to use that engine I can send you a bugfree version in obj format. Besides that, the source code is included so you can translate it to FASM, or modify to suit your needs.

You can create your grammar files in windows only, but because the engines are separate from the grammar file generator it can run on other OSes providing that you use a suitable engine for each OS.

regards
Post 30 Aug 2006, 17:37
View user's profile Send private message MSN Messenger Reply with quote
Thaorius



Joined: 27 Jul 2006
Posts: 42
Thaorius
It look's nice, but i want to do it my self, not using third party programs or anything.

Did you have any related information?
Post 31 Aug 2006, 00:25
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
zubi



Joined: 27 Apr 2006
Posts: 25
Location: Turkey
zubi
Oh, I thought you were going to use flex/bison, so my suggestion was only an alternative to them. If you're going to write the parser/lexer yourself too and not going to use a 3rd party stuff to handle that, I wish you plenty of spare time and patience then Smile

Related information upon compiler writing? Perhaps.. just tell me what areas of the whole process you are particularly interested in. I don't have much to say on writing a parser/lexer stuff as I never did that myself but I can provide some information about the other aspects such as building a parse tree, memory management and garbage collection, handling object oriented stuff and code generation...
Post 31 Aug 2006, 09:09
View user's profile Send private message MSN Messenger Reply with quote
ronware



Joined: 08 Jan 2004
Posts: 179
Location: Israel
ronware
Have you looked at Reva forth? It's written in FASM (and Reva). You can do something similar, or just write your language in Reva...
Post 31 Aug 2006, 14:43
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger Reply with quote
Thaorius



Joined: 27 Jul 2006
Posts: 42
Thaorius
zubi wrote:
Oh, I thought you were going to use flex/bison, so my suggestion was only an alternative to them. If you're going to write the parser/lexer yourself too and not going to use a 3rd party stuff to handle that, I wish you plenty of spare time and patience then Smile

Related information upon compiler writing? Perhaps.. just tell me what areas of the whole process you are particularly interested in. I don't have much to say on writing a parser/lexer stuff as I never did that myself but I can provide some information about the other aspects such as building a parse tree, memory management and garbage collection, handling object oriented stuff and code generation...


I need information about the whole process, about the lexer and parsers yes, it could be, i prefer to write my own parser/lexer but anyway i'm going to use flex and bison in a beggining.

about goldparser, is gpl? if that the case i will look at the sources.

And about Reva, i'm looking it right now.

Thanks
Post 31 Aug 2006, 15:34
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
Thaorius



Joined: 27 Jul 2006
Posts: 42
Thaorius
Hey, here is a draft of my language:

Code:
gimp API.IO; 
gimp API.Crypto;

API.Runtime.State PilotMain( API.Runtime.Args );
{
     Printf("First draft\n");
     return(API.Runtime.State.OK)
}
    


API - Main api group
Runtime - Runtime group
State - Return State class
OK - Static variable on State class

gimp - Group import(group = namespace)

does anyone have suggestions or something?

Thanks
Post 31 Aug 2006, 16:46
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
Suggestions?


  • first choose all OSes you are targetting
  • base it on languages you like (Ada ??, I presume, from your draft)
  • don't start from scratch, (re)write a specific portion or two of another compiler first


P.S. Read (or skim) the Crenshaw tutorial.

P.P.S. Check out Draak (multi-language macro compiler).
Post 01 Sep 2006, 03:28
View user's profile Send private message Visit poster's website Reply with quote
zubi



Joined: 27 Apr 2006
Posts: 25
Location: Turkey
zubi
the source for Goldparser is not avaialable but that is irrelevant because what it does is to create binary grammar file for you. There are many engines that actually parses your code according to the grammar and almost all of them has source code with it.

I also suggest not to start from scratch because I assure you that it is not going to be the world's simplest project. Crenshaw tutorial was the first thing that I read, it is really helpful.

Another suggestion I may give is that never do cowboy coding until you completely know what features you will need. It is a general suggestion anyway, but it becomes incredibly important while you design the language. When you realize that some features or syntax is not coherent with the other parts, it becomes too late or require too much extra effort to change them, plus you waste significant amount of time and energy.

I might also suggest you, for your spare time entertainment, to read information about garbage collection schemes, optimization in generated code, vtables and other stuff that you'll be using.
Post 01 Sep 2006, 11:11
View user's profile Send private message MSN Messenger Reply with quote
Thaorius



Joined: 27 Jul 2006
Posts: 42
Thaorius
I'm basing it on C,C++,Java,C#,PalmOS develpment classess; anyway, of course I'm going to design the language before doing it.

Other thing, i wan't that the output executables can run without any virtual machine or runtime environment. So, i have to found the way to.

Target systems? GNU/Linux, Micro$oft Windows

To make the program run in the different oses, i want the main API package, so with minor modiffication, like paths, and executable format it will work on linux.

I also get a copy of the Dragon book, it looks pretty interesting.

Garbage collection, require a run time?

About code generation and linking, for example, i can generate mscoff files and then link them, but how do i link them? and how the linker knows where is my PilotMain and how to start it.
I think is beder a language that just have a single main file and includes everything from the include files like fasm programs, but for a modern language this is not a choice. Or not? and on linux platform what intermediate object format can i make with fasm?

Oh, a last questions, the API should have, I/O,Sound,GUI,XML, what else?

P/D: Looking at the links right now

Thanks
Post 01 Sep 2006, 13:09
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
Maverick



Joined: 07 Aug 2006
Posts: 251
Location: Citizen of the Universe
Maverick
Why do you need Garbage Collection?
Post 01 Sep 2006, 16:02
View user's profile Send private message Visit poster's website Reply with quote
Thaorius



Joined: 27 Jul 2006
Posts: 42
Thaorius
I don't know :S, i don't think i really need it, because the user can delete by himself what hi doesn't use anymore. What is it functions exactly?

I Started reading the Dragon's Book, now is much more than pretty intresting Smile
Post 01 Sep 2006, 16:09
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
Maverick



Joined: 07 Aug 2006
Posts: 251
Location: Citizen of the Universe
Maverick
The function and purpose of GC is to make the system less efficient and to make the programmer less experienced, less aware and more easily distractible. At such, GC is an invaluable tool, expecially when used together with Microsoft languages such as VisualBasic and C#.
Post 01 Sep 2006, 16:46
View user's profile Send private message Visit poster's website Reply with quote
strcpy()



Joined: 23 Aug 2006
Posts: 5
Location: Mar del Plata / Argentina
strcpy()
Hi!
hehhee Smile
i send you the compiler: principles techniques and tools
some questions:
Are you coding in C ?
or are u using some kind of clon of Flex/Bison ?
sourcer ?
why do u choose to make a translator from your language to ASM ?

im coding a compiler too, but in C#

bye!
Post 02 Sep 2006, 12:41
View user's profile Send private message MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.