Creating Keywords

So my students are all novice programmers. In the past we have been sucessful with RobotC. However VCS C++ is a bit much. Lets face it: RightMotor.rotateTo(360,rotationUnits::deg,50,velocityUnits::pct); has a lot more room for error then startMotor did. So I wrote a library to be able to recreate the style of RobotC (shown below). It lets my students use the context of robotC with the capabilities of VCS C++.

What I would like to do is find a way to make the keywords change color. I imagine that somewhere in the code theres a list of keywords that trigger the color change. I just don’t know where, or how to implement it.

(Also if anyone is interested in the library I can share it. Or if you want to collaborate to expand and improve it I’d appreciate the help)

wow that is a cool library! I’d want that tbh I’m gonna miss robotC next year.

With PROS, you can get as close as: [class]Motor(3) = 100;

. If you set up the right macros or variables, you can get 

Motor(port3) = 100;

 or 

Motor(leftMotor) = 100;

. 

If you were insistent on having the 

motor[motorC]

 syntax, you could probably mess around with operator overloading to get this to work (*should* also be possible in VCS, but I don't know if they have any weird flags/compiler versions going on).

I’ve been waiting for someone to create a robotc wrapper. I actually wrote a robotc class several months ago, you could emulate almost exactly a robot program, for example,


#include "v5.h"
#include "robotc.h"

using namespace robotc;

task testTask() {
    int count = 0;
    
    while(1) {
      displayBigStringAt( 10, 90, "Task %d", count++ );
    
      wait1Msec( 500 );
      clearTimer( T1 );
    }
}

int main() {
    writeDebugStreamLine("Hello from v5");

    startTask( testTask );
    
    while(1) {
      motor[0] = vexRT Ch3 ];
      motor[1] = vexRT Ch2 ];
      wait1Msec( 20 );

      int t = time1 T1 ];
      
      displayBigStringAt( 10, 50, "Time %6d %6d", nPgmTime(), t );      
      displayBigStringAt( 10, 10, "Sensor %6d", (int)sensorValue[0] );      
    }

    return 0;
}

would work.

bad news is I have no plans on releasing it, we don’t want to confuse things and prefer everyone to use the new V5 APIs.

In terms of adding keywords, that’s not possible. The tokenizer and VCS language extensions are an integral part of VCS, we generate all the necessary information from the C++ class headers as VCS is built.

I believe if you use a third party text editor geared toward programming like C++ to do your writing and editing, then just transfer it to VCS to compile and run, you can configure your own keywords and how they highlight. Notepad++ is a good one. You will have to look for tutorials on how to configure the keywords, or pull apart an existing language file. I know there are instructions available to add a new key word config file.

Not a perfect solution, since you would then be editing in one program and then testing in another, but it would be the easiest way i could think of to get the desired effect, since VCS apparently doesn’t allow access to edit this.