OpenRoberta / openroberta-lab

The programming environment »Open Roberta Lab« by Fraunhofer IAIS enables children and adolescents to program robots. A variety of different programming blocks are provided to program motors and sensors of the robot. Open Roberta Lab uses an approach of graphical programming so that beginners can seamlessly start coding. As a cloud-based application, the platform can be used without prior installation of specific software but runs in any popular browser, independent of operating system and device.
Apache License 2.0
125 stars 121 forks source link

[NXT] "start" as a function name results in invalid NXC code #125

Closed stex closed 5 years ago

stex commented 6 years ago

Describe the bug

Naming a function start results in NXC compiler errors (probably because it's an existing identifier/keyword), so it should be excluded from valid function names.

To Reproduce Steps to reproduce the behavior:

  1. Create a program like the following:

    image
  2. Try to compile the NXC program (send to brick)

  3. ...

  4. Profit "The program could not be transformed into machine code."

The generated NXC code:

#define WHEELDIAMETER 5.6
#define TRACKWIDTH 12.0
#define MAXLINES 8 
#include "NEPODefs.h" // contains NEPO declarations for the NXC NXT API resources 

void start();

task main() {
    SetSensor(S1, SENSOR_TOUCH);
    SetSensor(S2, SENSOR_SOUND);
    SetSensor(S3, SENSOR_LIGHT);
    SetSensor(S4, SENSOR_TOUCH);
    start();
}

void start() {
}

The compiler errors:

# Error: Identifier expected
File "/home/pi/workspace/bug_start.nxc" ; line 6
#   void start(
#----------------------------------------------------------
# Error: Undefined Identifier (
File "/home/pi/workspace/bug_start.nxc" ; line 14
#    start()
#----------------------------------------------------------
# Error: Argument must be a task
File "/home/pi/workspace/bug_start.nxc" ; line 14
#    start()
#----------------------------------------------------------
# Error: ';' expected
File "/home/pi/workspace/bug_start.nxc" ; line 14
#    start();
#----------------------------------------------------------
# Error: Identifier expected
File "/home/pi/workspace/bug_start.nxc" ; line 17
#   void start(
#----------------------------------------------------------
# Status: NXC compilation failed.

Edit: start is a keyword in NXC to start another task (Thread).

Expected behavior

The generated NXC code can be compiled.

VinArt commented 5 years ago
bjost2s commented 5 years ago

solved in #35