Page 1 of 3 123 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2009
    Posts
    43
    Rep Power
    0

    Talking Create my own programming language


    I started reading "The Programming Language Wiki" and i read First Steps and it says you need to have a game programming language and game engine.

    I want to know how to make my own game engine and my own game programming language, but if someone gives my any help of making my own programming language or game engine, i can proceed on reading!

    What program could make my own program language, like C++ or vb but i want to make my own!

    Please, i need help!
  2. #2
  3. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2004
    Location
    Switzerland
    Posts
    1,152
    Rep Power
    1902
    Since you insist on trying this I'll give you small overview... I'm a little rusty on the subject so maybe someone else can add corrections/additions to what I'm saying...

    First you need to define your language syntax. This means you define operators for addition, subtraction etc, specify how you write and call methods, how loops and if's look or how you work with variables. You decide if you operators have different priority (* before +) or not (you have to group operations with parentheses). Are there classes and interfaces? How is inheritance defined? What types are there? Strong-typed like C or loosely typed like PHP? Do you need to declare variables in order to use them (C) or can you create them adhoc (PHP)? How do comments look? How do you create and destroy objects? How do you reference and call external libraries? And so on...

    Then you need to bring that into a structured form from which you can start producing a parser. The EBNF is commonly used for that.
    Code:
    An example for some simple computations could look like:
    
    Expr = Mult , { ( "+" | "-" ),  Mult }
    Mult = Num , { ( "*" | "/" ),  Num }
    Num = ("(" , Expr, ")" ) | ( DigitNZ , {Digit} )
    Digit = DigitNZ | "0"
    DigitNZ = "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
    When you have that you need to write a scanner/tokenizer that takes a source code and converts a the stream of characters into a stream of syntax objects:
    KEYWORD_IF, IDENTIFIER('strlen'), OPERATOR('('), LITERAL_STRING('foo'), OPERATOR(')'), OPERATOR('>'), LITERAL_INT('0'), KEYWORD_THEN, KEYWORD_ENDIF

    Then you can use your scanner/tokenizer to feed a parser that in a first version just checks if your program is syntactically correct. In a second version you'll have to improve the parser to build a syntax tree.
    Code:
    Using the above EBNF the expression "(0 - 12) * 5 + 1" would result in the following tree:
    
    Expr ? + ?
    +-Mult ? * ?
    |  +- Num ( ? )
    |  |  +- Expr ? - ?
    |  |     +- "0"
    |  |     +- "12"
    |  +- "5"
    +- "1"
    Then as a last step you need to write either a compiler or an interpreter. An interpreter takes your syntax tree and executes it step by step. This is probably the simpler option but will not perform as well as a compiled program. The other option would be to write a compiler that takes the syntax tree and converts that into a windows executable.

    -------------------------------------------------------------

    If you really want to try this i strongly suggest you first try to implement the simple computation example of mine to get a glimpse of what's ahead of you. If you manage to do that you can start to expand your language with additional operators then variables, flow control statements etc...
    Last edited by Hugh of Borg; May 18th, 2009 at 08:48 AM.
    - Hugh of Borg

    The first thing young borg are taught: Keep away from Microsoft software!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2009
    Posts
    43
    Rep Power
    0
    OK, what program could you use to make your own operators such as:

    +
    -
    /
    *
    if
    then
    else
    and so on and convert it into your script..

    ..and for the compilier, do I need to design a compiler using vb2008? If so, i need help on making a compilier...

    Can someone please tell me any program that could make your operators work for your own game programming language, AND Help for vb on making my own compilier, please??
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 2006
    Posts
    2,270
    Rep Power
    1737
    OK, what program could you use to make your own operators such as:
    You don't. Let me give you a comparison. Let's say, you looked at English, and French, and Spanish, and said, I want to make a new language.

    And you said, how can I create a word that means "house". It's like you think that the languages are all about the vocabulary. It's true that you are going to have vocabulary as part of the language, but what's really interesting is the grammar. Do you remember concepts like nouns, adjectives, and verbs? The English language has certain grammar rules. It is defined by the grammar, and the vocabulary you use falls into some aspect of that grammar.

    So when you talk about implementing operators in a programming language, what you really need to be thinking is the grammatical equivalent of an operator. What is the grammar of your language? How do operators fall into play? It's not necessarily as simple as hardcoding it, by the way.

    ..and for the compilier, do I need to design a compiler using vb2008? If so, i need help on making a compilier...
    Of course you need help on making a compiler. Certainly, you don't seem to understand what you are dealing with yourself. If you really are into this stuff, consider getting the Dragon Book. This is the kind of material you need to work through.

    Comments on this post

    • Sarah_S agrees
    When you ask a question, be prepared to tell us: what have you tried? If you think you don't need to try anything, we will never be interested in helping you. If you agree with the link, and you refuse to answer that question, you are being a hypocrite.

    Need help with broken code? Your question should be like a good bug report: (1) It has the smallest number of steps to reproduce the problem you see (2) It tells us precisely what you expected to see and (3) It tells us what you saw and how it differed from what you expected. We need all three to help you.
    Want better answers? Tell us what you Googled for and what steps you took to answer your own question.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2009
    Posts
    43
    Rep Power
    0
    About creating your language and making up a new identifier like "House" or another identifier replacing other ones. How can you do that, do you just use vb6C++ or do i need some sort of code to input into notepad??
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 2006
    Posts
    2,270
    Rep Power
    1737
    How can you do that
    To create your own language. Get a pen. Get paper. Write down the grammar. You create a language by describing it with a pen and paper standard.
    When you ask a question, be prepared to tell us: what have you tried? If you think you don't need to try anything, we will never be interested in helping you. If you agree with the link, and you refuse to answer that question, you are being a hypocrite.

    Need help with broken code? Your question should be like a good bug report: (1) It has the smallest number of steps to reproduce the problem you see (2) It tells us precisely what you expected to see and (3) It tells us what you saw and how it differed from what you expected. We need all three to help you.
    Want better answers? Tell us what you Googled for and what steps you took to answer your own question.
  12. #7
  13. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2004
    Location
    Switzerland
    Posts
    1,152
    Rep Power
    1902
    Originally Posted by Buzzy661
    About creating your language and making up a new identifier like "House" or another identifier replacing other ones. How can you do that, do you just use vb6C++ or do i need some sort of code to input into notepad??
    Source code can be written in any kind of text editor. There's no magical power that requires you to use Visual Studio or Eclipse. Source code is nothing more than text. The only thing you need to make it into a program is a compiler and it doesn't care if you used a 70 KB notepad or a 3 GB Visual Studio to write the source code.

    Your question tells me that you didn't quite understand what Oler1s tried to say. To make a computer understand a language it has to follow very clear and specific rules. Humans are pretty good at interpreting sentences even broken very it much is if.

    Computers require any sentence to follow some clear pattern - the syntax. While in English you can say "What is the time?" or "What time is it?" or "Yo man! *points to wrist*" to inquire about the time a computer is less flexible.

    That's the heart of a language - natural or programming language. You first need to decide on the pattern that form a sentence. When you've done that you already have a programming language. But it's still empty. Before you can write any kind of literature (programs) with it you need a vocabulary (an API). You need to create words (classes, interfaces, enumerations, etc) before you can write a novel. In time others might start to use your language and find that it lacks some words so they create them (write additional classes).

    So first you need to create the syntax like i told you in my first post here.

    Only after you completed the compiler you can start building the API (the vocabulary) by creating standard classes to work with.
    - Hugh of Borg

    The first thing young borg are taught: Keep away from Microsoft software!
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2009
    Posts
    43
    Rep Power
    0

    Red face


    If I am going to make my programming language, what code things am I suppose to write in my text editor like special identifiers or do I just write:

    Code:
    "
    '
    ?
    +
    -
    Hello
    ""
    And any other identifiers i need in code.

    Also about the compilier, if I make it my self to make it compile the text above, well what scripting stuff do you need to make a compilier for visual studio 2008 (visual basic). Need tips for DRAGON BOOK)):

    please help!
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2009
    Posts
    43
    Rep Power
    0
    If you really are into this stuff, consider getting the Dragon Book.
    Is there any vb2008 tutorials here?

    When you have that you need to write a scanner/tokenizer that takes a source code and converts a the stream of characters into a stream of syntax objects:
    KEYWORD_IF, IDENTIFIER('strlen'), OPERATOR('('), LITERAL_STRING('foo'), OPERATOR(')'), OPERATOR('>'), LITERAL_INT('0'), KEYWORD_THEN, KEYWORD_ENDIF
    Can someone list me all variables and identifiers to convert to my own identifier?

    Also do i need to write it like this:

    KEYWORD_IF, identifier "If"
    KEYWORD_THEN, identifier "Then"
    KEYWORD_END, identifier "End If"
    But if i write it like this:

    KEYWORD_IF, identifier "Hello"
    KEYWORD_THEN, identifier "Next"
    KEYWORD_END, identifier "Eliminate"

    And would it appear like this in the code
    Instead of

    If ........ Then
    ....
    End If

    Replaced by

    Hello........Next
    ...
    Eliminate

    ??? Will it actully replace those identifiers?
    What code are you suppose to input into my text editor if i make up a code?

    please
  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2009
    Posts
    43
    Rep Power
    0
    About the
    Dragon Book
    What chapter are you suppose to find the scripting for vb2008?
  20. #11
  21. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2004
    Location
    Switzerland
    Posts
    1,152
    Rep Power
    1902
    When you have that you need to write a scanner/tokenizer that takes a source code and converts a the stream of characters into a stream of syntax objects:
    KEYWORD_IF, IDENTIFIER('strlen'), OPERATOR('('), LITERAL_STRING('foo'), OPERATOR(')'), OPERATOR('>'), LITERAL_INT('0'), KEYWORD_THEN, KEYWORD_ENDIF
    This was just a highly simplified illustration on what a tokenizer does... There's a lot more to it in practice.

    But alright. I'm gonna dig up my old CS stuff when I get home and provide you with a small challenge. If you manage to do that we'll see how to proceed from there.

    As a first thing I'd like you to the following things:
    1. Post why you want to create your own programming language.
    2. Post what you want your language for and how it will be different from what's already out there.
    3. Post a small example of how code in your programming language should look. Try to include a number of different things (like variables, objects, array, computations, ifs, loops, etc) in your example if it's supposed to produce output post that too.
    - Hugh of Borg

    The first thing young borg are taught: Keep away from Microsoft software!
  22. #12
  23. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2009
    Posts
    43
    Rep Power
    0

    Talking


    1. Post why you want to create your own programming language.
    So I could use my own programming language to create my Game Engine and then I could make my 2d and 3d games.
    2. Post what you want your language for and how it will be different from what's already out there.
    Other languages like vbC++ or python ok but I decide to make my own programming language so I could understand it easier for my scripting.
    3. Post a small example of how code in your programming language should look. Try to include a number of different things (like variables, objects, array, computations, ifs, loops, etc) in your example if it's supposed to produce output post that too.
    Ok, I'll show you the codes:

    Code:
    Comments look like:
    //
    Example:
    
    \\This is an example code of a comment.
    
    Math signs look like:
    
    +, -, \ (divide), *(multiply), ~ (Round-up answer)
    They will appear blue text
    Example:
    
    5 + 4  \ 3
    
    On the code the answer will be 3.
    
    IF you round your answer:
    
    5.4 +4.91 ~ (1)
    
    Your answer will be 10.31 but the rounding to 1 decimal will make it 10.3.
    
    ~ = round-up
    (1) = round decimals
    
    If you wanted to define text:
    
    Integer as [test_text]
    
    then you can input without errors:
    
    test_text = 
    
    Adding a word like "Interger" and the string [Your_string] will define your word.
    
    Showing message boxes:
    
    ShowMsgbox("Your text here", ButtonsOKCancel, Exclamation, "Msgbox test" -noclosebutton)
    
    Parameters (special):
    The - define the parameter such as for msgboxes:
    
    -noclosebutton
    -opaquebox #
    -showhelpbutton
    -addbutton, "Testtext", [TEST01]
    TEST01 = Code
    
    Starting a code:
    Start {
    Ending a code:
    End }
    
    If's, thens, ends, else
    
    If <ADDTEXT> Then
    <ADDTEXT>
    Else
    <ADDTEXT>
    End If
    
    the <ADDTEXT> areas are where you add your txt.
    
    If you want a word to be nothing you just input:
    Void
    
    The use of OR:
    
    <ADDTEXT> or <ADDTEXT>
    
    Running applications, including files:
    
    Run "\MYAPP.exe" or Run "$GAMEDIR\MyApp.exe"
    
    Include Test.bzc
    
    The BZC files are the script file extension.
    You can also include files in the same folder as the code:
    
    Include Test01.bzc
    
    Or
    
    Include Folder01\Test02.bzc
    
    The "print" function:
    
    Print "123"
    
    Color function:
    
    ColorRed, ColorBlue or
    
    Color0, 0, 0, 0 (ColorRed, Green, Blue, Alpha)
    
    Loops:
    Loops=repeats
    Example:
    
    ShowMsgbox("Test") Loop [U]
    U = If file("Test.txt") *exists
    
    (don't know much about loops)
    
    Files existing
    
    If "Text1.txt" exists Then
    	<ADDTEXT>
    Else
    	ShowMsgbox("Test")
    End If
    
    Eliminating/Adding objects:
    
    Eliminate object.test
    Add object.test at position(X,Y,Z)
    
    Object properties:
    
    Example: pressbutton
    
    Pressbutton01.Text ("Pressbutton")
    
    Output a file:
    
    outputfile > ("\$APPDIR\", "Test", *.txt)
    
    Output folder, name and extension. Many more codes.
    In game code:

    Code:
    Showing a message when picked up item (medikit)
    Item.medikit.pickup {
    Print("You picked up a medikit")
    AddPlayerHealth "25"
    PickupSound("\Sounds\Items\MediPickup25.wav")
    
    That is just an simple medi-kit pickup.
    }
    
    Some Variables:
    
    AddPlayerHealth #
    AddPlayerArmor #
    AddPlayerAmmo #
    
    # = Enter a value
    Thats all.
    --These codes might change...
  24. #13
  25. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2009
    Posts
    43
    Rep Power
    0
    And for arrays, loops, and many others i need to learn a bit more about them before i can convert them into code!
  26. #14
  27. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2009
    Posts
    43
    Rep Power
    0
    ok. All i just need is a list of all the keywords that you input into a text editor and a compilier.

    Please, i need all of the keywords like:

    Code:
    Expr = Mult , { ( "+" | "-" ),  Mult }
    Mult = Num , { ( "*" | "/" ),  Num }
    Num = ("(" , Expr, ")" ) | ( DigitNZ , {Digit} )
    Digit = DigitNZ | "0"
    DigitNZ = "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
    I just wand all of the keywords, please?

    Also:
    Code:
    When you have that you need to write a scanner/tokenizer that takes a source code and converts a the stream of characters into a stream of syntax objects:
    Where are you suppose to find a scanner/tokenizer or do i just make it my self with some help.
  28. #15
  29. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2009
    Posts
    43
    Rep Power
    0
    To create your own language. Get a pen. Get paper. Write down the grammar. You create a language by describing it with a pen and paper standard.
    Ok, I did that.
    What do I need to do now?
Page 1 of 3 123 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo