Omnimaga

General Discussion => Other Discussions => Miscellaneous => Topic started by: blue_bear_94 on May 15, 2013, 05:01:37 pm

Title: Language Construction!
Post by: blue_bear_94 on May 15, 2013, 05:01:37 pm
Recently, I've been having an upsurge in conlanging, so I'd like to share my constructed language with you:
VE3ENCS:
pdf (http://derpy.me/ve3encs)

I'd also like to see your interests in constructing languages, if any.
Title: Re: Language Construction!
Post by: TheBassetHound on May 15, 2013, 09:45:42 pm
So you made a programming language... With what? Java? TELL ME HOW THIS SOUNDS LIKE FUN!!! :-D I've seen a tutorial on how to create a programming language in Java... Is this different?
Title: Re: Language Construction!
Post by: blue_bear_94 on May 15, 2013, 10:10:14 pm
Not a programming language, but rather one that you'd actually speak. (VE1ENCS is short for Vletmata erse Myn eas Necarasso Cryssesa, which translates to The First Revision of the Cressia Language.)
Title: Re: Language Construction!
Post by: shmibs on May 16, 2013, 12:02:44 pm
for programming languages, if you want to learn how to make your own you're going to have to learn how to write a compiler. all languages other than machine code running on bare metal are compiled. the three options for this are to write a compiler which converts your code directly into machine code (which is very difficult, and becomes exponentially more so if you want it to work on multiple architectures), a compiler which converts your code into some other language, which is then compiled (which is a bit roundabout and messy, so it isn't very popular), or a compiler which converts your code into bytecode that is executed by a virtual machine written in some other language (which is the most widespread method today).

every good compiler needs to have a few basic parts:

-a lexer this converts plain text files into strings of tokens, with associated types (string literal, type identifier, list, etc) which the language uses. there are plenty of dedicated lexers out there that you can easily include directly in a new language. flex (http://flex.sourceforge.net/) is a particularly popular one.

-a parser this takes your now-tokenised source and searches for illegal statements (something like: int "tasty";, for example, if you're writing C). there is a lot of interesting theory behind the best methods of doing this, but again, you'd be best off just using one of the many pre-made parsers out there. bison (https://www.gnu.org/software/bison/) is a popular one

-a method for organising data elements (symbol table) and recursive statements (syntax tree). this step will be as easy or as difficult as the complexity level of the program you're writing. if you're making a simple, purely functional language you can use whatever structure you want to store your symbol table. even a giant list would do, though you'd probably want to use something like a heap (https://en.wikipedia.org/wiki/Heap_%28data_structure%29) in order to reduce lookup times. the syntax tree does pretty much have to be a tree structure. this is because it breaks code up into a hierarchical structure so that everything afterwards knows the correct order in which to read your source code. if you had the following code, for example:
Code: [Select]
For(A,0,2)
   A→C
   If A=B
      <do foo>
   Else
      <do bar>
   End
End
it might be translated into a pre-order (https://en.wikipedia.org/wiki/Tree_traversal#Pre-order) syntax tree like this:
Code: [Select]
          [<rest of program above>]
                      |
                [For loop]
               /     |    \
  [initialiser]   [body]  [increment]
    /                |               \
[0→A]        [If statement]          [A++]
             /            \
    [condition]          [body]
         |              /      \
       [A≤2]       [A→C]         \
                         [two part If statement]
                         /          |          \
                 [condition]   [then part]   [else part]
                      |             |             |
                    [A=B]       [<do foo>]    [<do bar>]
obviously, if you want to work with objects, variable scope, etcetera, this all gets more complicated.

-semantic checking. traverse your tree and find any inconsistencies (like a function that expects two parameters being passed three instead or a statement like "string literal" == integer, where integer is of type int).

-code generation part. if you're writing a simple, functional language, this part is really easy. just directly translate your now, organised program into its counterpart in whatever other language you're using (converting to machine code, some other language, or bytecode for a virtual machine), looking up variables in your symbol table as you encounter them while traversing the syntax tree and inserting references to them in your generated code (direct addresses for machine code or a virtual machine or names if you're translating to some other language).

-code optimisation part. scan over your generated code and apply any optimisations you can find. obviously, this part isn't necessary, but you will get slow results without it.
Title: Re: Language Construction!
Post by: harold on May 16, 2013, 12:25:40 pm
I've never constructed a language that wasn't a programming language. (as for programming languages, I did a small tutorial on compiler construction here (http://ourl.ca/18348))

Maybe I'll make a spoken language someday, because I'm annoyed at the limited expressiveness of existing ones. Everyone seems to agree that language should be a one-dimensional string of either sound of text with perhaps the occasional back-reference, but I don't particularly agree with that - I certainly don't think that way. Of course sound that has more than one dimension is sort of tricky ;)
But I'll work around that somehow.
Title: Re: Language Construction!
Post by: Juju on May 16, 2013, 12:26:38 pm
As BB94 said, it's not about programming languages, but actually an actual communication language (like English). I've began skimming through the document in the OP, it looks very interesting.

EDIT: Correct me if I'm wrong, but E enara alyrynssyd issos sylorssa. Damn. I really like how it sounds.
Title: Re: Language Construction!
Post by: Scipi on May 16, 2013, 01:08:15 pm
Well damn, that's very impressive O_o

You can see my own Kakrii language here: http://ourl.ca/18644 (http://ourl.ca/18644)

Mine is not as far along as your is, but it's got the basics nailed down. Also, "atoro menehess cypra" yeah, I really like how this language sounds as well :P

Edit:

Quote
E enara alyrynssyd issos sylorssa

Damn it, e enara alyrynssyd. <_<
Title: Re: Language Construction!
Post by: ElementCoder on May 16, 2013, 01:20:14 pm
This looks really impressive. I've always liked the idea of creating a new language (in fact I still need to :P) but I never get around it how to do it. Skimming the document now, it looks great.
Title: Re: Language Construction!
Post by: blue_bear_94 on May 16, 2013, 04:00:17 pm
As BB94 said, it's not about programming languages, but actually an actual communication language (like English). I've began skimming through the document in the OP, it looks very interesting.

EDIT: Correct me if I'm wrong, but E enare alyrynssyd issos sylorssa. Damn. I really like how it sounds.
Here's another example:
Spoiler For Spoiler:
Yr iss enva acrynala, iss enva erse ermessacveryssan, eas merseda erse enefa, eas elsse erse aplamysenrotacveryssanallasmafssalia, enarass ylmayd. Myron enva emte, enarass re nass tecto enva emte.
On the dark day of February 22, 2013, we panicked. After that day, we did what we did before.
Note: this phrase includes terms not found in the VE1ENCS. They will be included in the VE2ENCS.
Title: Re: Language Construction!
Post by: harold on May 17, 2013, 04:06:48 am
Hey BB84, could you make a pdf version of that document?
Title: Re: Language Construction!
Post by: blue_bear_94 on May 17, 2013, 03:59:19 pm
I will for VE2ENCS.
Title: Re: Language Construction!
Post by: TheBassetHound on May 25, 2013, 10:15:20 pm
Oops... It was all caps so I thought it was a programming language. Plus I didn't read the article (That tells a lot about me) :P. I thought about doing so in, like, 3rd grade, but I never actually started it just because it was such a huge project. But thanks shmibs for the tutorial!
Title: Re: Language Construction!
Post by: blue_bear_94 on May 29, 2013, 06:13:58 pm
Surprise! Look at the OP for some insight.
P. S. VE2ENCS is the name of the document teaching you how to speak the language.