2

Following is the Promela code that I am writing.

491     byte api1[5];
492     byte api2[5];
493     byte api3[5];
494     byte reftask1[5]
495     byte reftask2[5];
496     byte reftask3[5];
497     byte rid1[5];
498     byte rid2[5];
499     byte rid3[5];
500
501
502 proctype init_call(){
503     byte i1 = 0;
504     do
505     :: (i1 == 5) -> break
506     :: else ->
507         select ( api1[i1]: 2 .. 9);
508         select ( api2[i1] : 2 .. 9);
509         select ( api3[i1] : 2 .. 9);
510         select ( reftask1[i1] : 1 .. 3);
511         select( reftask2[i1] : 1 .. 3);
512         select ( reftask3[i1] : 1 .. 3);
513         select ( rid[i1] : 0 .. 1);
514         select ( rid[i1] : 0 .. 1);
515         select ( rid[i1] : 0 .. 1);
516         i1++;
517     od
518 }

But if I try to simulate the code, I get the error message as following,

saw: '[', expected ':' spin: osek_sp2.pml:507, Error: expecting select ( name : constant .. constant ) near 'select'

However, according to the syntax definition, I can't find any problem.

SYNTAX
select '(' varref ':' expr '..' expr ')'

varref : name [ '[' any_expr ']' ] [ '.' varref ]

What is the reason of this error message?

jungyh0218
  • 558
  • 1
  • 4
  • 17
  • 2
    It looks like spin's internal parser is implemented differently from the online specification. Are you using the latest version of Spin? I would get in touch with the authors. – Patrick Trentin Sep 27 '16 at 16:29
  • I am not using the latest version. Now I am using 6.4.3 version. From the version it controls 'select' statement in preprocessor, not in grammar. And there is no update or new features of spinlex.c in later release logs. – jungyh0218 Sep 29 '16 at 03:24

1 Answers1

2

Patrick is right. I'd say that this is a bug. If you look into spinlex.c, you'll see that when it scans for name before : only alphanumeric characters are allowed:

scan_to(':', isalnum, name)

Anyway, select is just a shorthand for a sequence of assignments. So a work-around might be to write the assignments yourself, e.g.

api1[i1] = 2;
do
:: (api1[i1] < 9) -> api1[i1]++
:: break
od
dejvuth
  • 6,986
  • 3
  • 33
  • 36