UoY-RoboStar / robochart-textual

This repository contains the plugins for the RoboChart textual editor
Eclipse Public License 2.0
0 stars 1 forks source link

Trigger revision #23

Closed pefribeiro closed 3 years ago

pefribeiro commented 3 years ago

This pull request reflects the changes required in the textual language and the validator in light of the changes to the RoboChart metamodel in commit deb7cfed of the circus.robocalc.robochart.parent repository.

There is a breaking change in the RoboChart Textual language (.rct) in that the keyword trigger is now optional. It is only used if there is an actual trigger associated with the transition. The following example now flags up an error on the fourth line:

transition t1 {
    from From
    to j0
    trigger
    condition l == Loc::left
    action move( lv , Angle::Right)
}

To rectify such issues, it is possible to use Find/Replace of Eclipse over a whole workspace/project to quickly update one or more examples by proceeding as follows:

  1. Click on Search > File.
  2. Use the following regular expression: trigger\s*\n*(\<\{|\}|condition|#|action)
  3. Select Regular expression
  4. Select the appropriate Scope (eg. Workspace)
  5. Click on Replace
  6. Type $1 in the input box labelled With:, so that the match (...) in the regular expression can be substituted in place.

Alternatively the traditional Find/Replace dialog can be used to perform the same on a file-by-file basis.

If you hit a problem with a particular example, or would like help, please let me know.

RandallYe commented 3 years ago

@pefribeiro I found this shell command is very helpful to update all rct files together.

find . -name "*.rct" | xargs sed -i '/^\t*trigger$/d'

pefribeiro commented 3 years ago

Hi @RandallYe,

find . -name ".rct" | xargs sed -i '/^\ttrigger$/d'

Thanks for your suggestion.

I think that your solution only works for cases where the keyword trigger is followed by a new line? It could be followed by a sequence of one or more white spaces, followed by a clock reset, a deadline, or } or even the condition and action keywords. The other issue I see with sed is that usually it performs matches on a line-by-line basis, making multi-line matches somewhat tricky.

Thanks, Pedro

RandallYe commented 3 years ago

@pefribeiro,

Yes, the command may not work for all cases. In my case, I have 10+ RoboChart projects for different purposes,

This command works only for this case to remove all empty trigger lines in rct files under current folders. It cannot replace other cases as you mentioned.

Thanks.