I am creating a new language. Not like C# but a language specifically for plus,minus,multiply,division stuff

Any tuts related to this?

  • 1
  • 3
    How do you want to proceed, make an interpreter/compiler or just design the language?

    Designing is simple enough, the interpreter can be a bit of work.
  • 5
    Take a candy. You'll need it.

    so start off by designing your language like what you want on paper.
    Then, write a simple context free grammar for it. Then, write lexer/parser.
    I would Suggest you to make it interpreted - making it compiled for such easy paradigms is a waste of time.

    Interpreting something once you have a lexer/parser, It's a pretty easy job - especially if you know your lambdas.
    Simply make the parser call the lambdas with the specific arguments.

    Also; I would suggest you to only implement IO and keywords.

    The rest should be done by standard library.
  • 1
    @linuxer4fun Harder than I thought... Any tutorial suggestions? (even though i am pretty sure tuts are useless cuz all langs are different)
  • 1
    Just overload operators in c++ and use custom data types.
  • 2
    @codePatrol how does that answer the question?

    @CozyPlanes unfortunately, there aren't many good, practical and free learning resources out there (at least I yet have to find them). What I did: roughly learn the individual phases of an interpreter/compiler (lexing, parsing, semantic validation and code generation) and then, with a bit of logical thinking, trying to figure out how they could possibly work.

    Yes, that surely isn't the best way, but it works pretty well for me so far and I'm learning quite a lot
  • 2
    @byte lol its easy if you arent as clumsy as i was
  • 1
    @CozyPlanes O i can help you in pm
  • 1
    @codePatrol You can use yacc :P
    but i think he wants to do it for learning purposes
  • 2
    @linuxer4fun I honestly find using such tools to be more complicated and confusing than writing a simple parser on your own, *especially* when it's for learning purposes
  • 2
    @Krokoklemme yea ik. I was sarcastic :P

    I hate yacc too. lol
  • 2
    @Krokoklemme If he's only looking to do addition, multiplication etc then he can write a really simple interpreted language in c++ by using his own data types and overloading the + - / * operators which would save a shit ton of work. It's not everything he'd need to do but a really good start.
  • 2
    @linuxer4fun yacc is pretty cool. Seems like something interesting to read about or use.
  • 2
    @codePatrol automatisation. is. bad
Add Comment