The forum has been archived
While the forum may not be active, the community still lives on Discord! Click here to join us.

Notepad++ Custom Language Interpreter?

Phones, computers, tablets, and all other forms of electronic wizardry
Post Reply
User avatar
UC101
Member
Posts: 71
Joined: January 15th, 2014, 10:33 pm

Notepad++ Custom Language Interpreter?

Post by UC101 »

Hey people, I'm new to this forum and I have a question..
Notepad++ lets you define custom programing languages in the IDE, however I was wondering if it would be possible to create a configurable interpreter for the custom language that breaks it down to C++/C#? I'f it is possible I would love to know how!
We are anomalous.
We are region.
Forgive and forget.
Expecto patronum.
:?:
User avatar
Entity
Editorial Staff
Posts: 3097
Joined: November 29th, 2012, 9:41 pm
Design Competitions Voted: 1

Post by Entity »

Before I try and answer, let me make sure I understand your question:
  • You're writing a programming language (I'll refer to it as "Derp" for clarity)
  • "Derp" doesn't compile directly to an EXE
  • You want to write an interpreter to convert "Derp" sourcecode into C++/C# sourcecode
  • Then you can compile the C++/C# code into an EXE
Is this what you want?
:crate: :crate: :crate: :crate: :crate: :crate:
User avatar
UC101
Member
Posts: 71
Joined: January 15th, 2014, 10:33 pm

Post by UC101 »

yes
We are anomalous.
We are region.
Forgive and forget.
Expecto patronum.
:?:
User avatar
kroltan
Developer
Posts: 285
Joined: October 8th, 2012, 6:57 pm
Design Competitions Voted: 1

Post by kroltan »

No, that's not what Notepad++ does. All it does is highlight keywords in a pretty manner.
You'd use a Language Recognizer (a compiler compiler), such as ANTLR (with Java) or Irony (with .NET languages).
However, you'd still need to program the behaviours of your language using the languages inside the parentheses.
User avatar
Entity
Editorial Staff
Posts: 3097
Joined: November 29th, 2012, 9:41 pm
Design Competitions Voted: 1

Post by Entity »

Like Kroltan said, that's not possible with Notepad++. You can either write the interpreter manually, or use the libraries Kroltan suggested. Either way it's going to be somewhat of a hassle, depending on how complex your language is :P

Notepad++ is just a text editor though.
:crate: :crate: :crate: :crate: :crate: :crate:
User avatar
UC101
Member
Posts: 71
Joined: January 15th, 2014, 10:33 pm

Post by UC101 »

Entity wrote:Like Kroltan said, that's not possible with Notepad++. You can either write the interpreter manually, or use the libraries Kroltan suggested. Either way it's going to be somewhat of a hassle, depending on how complex your language is :P

Notepad++ is just a text editor though.
I knew It wasn't possible with notepad++ I was just asking if there were any programs to turn my custom syntax into an interpreter and or compiler
We are anomalous.
We are region.
Forgive and forget.
Expecto patronum.
:?:
User avatar
kroltan
Developer
Posts: 285
Joined: October 8th, 2012, 6:57 pm
Design Competitions Voted: 1

Post by kroltan »

Yeah, the closest you can get is with one of those libraries, where you define rules to parse the code, then you can act accordingly. An example in ANTLR for a simple math language supporting all the basic opeerations, but only one at a time (example use: calculators):

Code: Select all

grammar SimpleMath;
Operator: ('+' | '-' | '/' | '*');
Number: ('+' | '-')? [0..9]+ ('.' 0..9*)*;
Statement: Number Operator Number;
(See ANTLR's website for more info)
It would parse a string into a tree you can go trough with Java code. Example:
3.14159 * -1
Would turn out into this object tree (visualized):
V indicates the value of the token

Code: Select all

        Statement
        /    |    \
  Number Operator Number
      V      V      V
  3.14159    +      -1
Post Reply