Skip to content

Commit fefa61b

Browse files
committed
SMV: word constants
This adds NuSMV's word constants to scanner, parser, type checker.
1 parent a5a43bc commit fefa61b

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-1
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
word_constants1.smv
3+
--bound 0
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
MODULE main
2+
3+
SPEC uwconst(123, 8) = 0d8_123;
4+
SPEC uwconst(123, 8) = 0ud8_123;
5+
SPEC uwconst(123, 8) = 0h_7b;
6+
SPEC uwconst(123, 8) = 0uh_7b;
7+
SPEC uwconst(123, 8) = 0b_01111011;
8+
SPEC uwconst(123, 8) = 0ub_01111011;
9+
SPEC uwconst(123, 8) = 0b8_1111011;
10+
SPEC uwconst(123, 8) = 0ub8_1111011;
11+
12+
SPEC swconst(123, 8) = 0sd8_123;
13+
SPEC swconst(123, 8) = 0sh_7b;
14+
SPEC swconst(123, 8) = 0sb_01111011;
15+
SPEC swconst(123, 8) = 0sb8_1111011;

src/smvlang/parser.y

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "smv_parser.h"
77
#include "smv_typecheck.h"
88

9+
#include <util/bitvector_types.h>
910
#include <util/mathematical_types.h>
1011
#include <util/std_expr.h>
1112
#include <util/std_types.h>
@@ -320,8 +321,9 @@ static smv_parse_treet::modulet &new_module(YYSTYPE &module_name)
320321

321322
%token IDENTIFIER_Token "identifier"
322323
%token QIDENTIFIER_Token "quoted identifier"
323-
%token STRING_Token "quoted string"
324+
%token STRING_Token "quoted string"
324325
%token NUMBER_Token "number"
326+
%token WORD_CONSTANT_Token "word constant"
325327

326328
/* operator precedence, low to high */
327329
%right IMPLIES_Token
@@ -815,6 +817,7 @@ formula : basic_expr
815817

816818
constant : boolean_constant
817819
| integer_constant
820+
| word_constant
818821
;
819822

820823
boolean_constant:
@@ -841,6 +844,15 @@ integer_constant:
841844
}
842845
;
843846

847+
word_constant:
848+
WORD_CONSTANT_Token
849+
{
850+
init($$, ID_constant);
851+
stack_expr($$).set(ID_value, stack_expr($1).id());
852+
stack_expr($$).type() = bv_typet{0};
853+
}
854+
;
855+
844856
basic_expr : constant
845857
| identifier
846858
{

src/smvlang/scanner.l

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,11 @@ void newlocation(YYSTYPE &x)
188188
stack_expr(yysmvlval).id(yytext);
189189
return NUMBER_Token;
190190
}
191+
0[us]?[bBoOdDhH][0-9]*_[0-9a-fA-F][_0-9a-fA-F]* {
192+
newstack(yysmvlval);
193+
stack_expr(yysmvlval).id(yytext);
194+
return WORD_CONSTANT_Token;
195+
}
191196
\"[^\"]*\" {
192197
newstack(yysmvlval);
193198
std::string tmp(yytext);

0 commit comments

Comments
 (0)