Skip to content

Commit 053eab0

Browse files
committed
Remove quotes around STL module names
This commit introduces an extra state to the STL scanner in order to detect if the current identifier is a module name. If it is, the surrounding quotes are cut. The quotes are syntactically required but do not contribute to the module names being unique, therefore cutting them is allowed. Doing so simplifies both the user and the language interface. Existing regression tests were changed in a way that all directly refer to the default entry point which was introduced by a past commit. One test, Function_Call2, is now responsible for checking the --function flag.
1 parent c494b9c commit 053eab0

File tree

25 files changed

+53
-32
lines changed

25 files changed

+53
-32
lines changed

regression/statement-list/Add_Int/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ main.awl
33
--show-parse-tree
44
^EXIT=0$
55
^SIGNAL=0$
6-
^Name: "Add_Int"$
6+
^Name: Add_Int$
77
^Version: 0[.]1$
88
^ \* type: signedbv$
99
^ \* width: 16$

regression/statement-list/Add_Int2/main.awl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FUNCTION_BLOCK "Add_Int2"
1+
FUNCTION_BLOCK "Main"
22
VERSION : 0.1
33
VAR_INPUT
44
in1 : Int;

regression/statement-list/Add_Int2/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
main.awl
3-
--function \"Add_Int2\"
3+
44
^VERIFICATION SUCCESSFUL$
55
^EXIT=0$
66
^SIGNAL=0$

regression/statement-list/Arithmetic/main.awl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FUNCTION_BLOCK "Arithmetic"
1+
FUNCTION_BLOCK "Main"
22
VERSION : 0.1
33
VAR_TEMP
44
compResult : Bool;

regression/statement-list/Arithmetic/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
main.awl
3-
--function \"Arithmetic\"
3+
44
^VERIFICATION SUCCESSFUL$
55
^EXIT=0$
66
^SIGNAL=0$

regression/statement-list/Bool1/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ main.awl
33
--show-parse-tree
44
^EXIT=0$
55
^SIGNAL=0$
6-
^Name: "Bool1"$
6+
^Name: Bool1$
77
^Version: 0[.]1$
88
^ \* type: bool$
99
^ \* identifier: in1$

regression/statement-list/Bool2/main.awl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FUNCTION_BLOCK "Bool2"
1+
FUNCTION_BLOCK "Main"
22
VERSION : 0.1
33
VAR_INPUT
44
in1 : Bool;

regression/statement-list/Bool2/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
main.awl
3-
--function \"Bool2\"
3+
44
^EXIT=10$
55
^SIGNAL=0$
66
^SAT checker: instance is SATISFIABLE$

regression/statement-list/Bool3/main.awl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FUNCTION_BLOCK "Bool3"
1+
FUNCTION_BLOCK "Main"
22
VERSION : 0.1
33
VAR_INPUT
44
in1 : Bool;

regression/statement-list/Bool3/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
main.awl
3-
--function \"Bool3\"
3+
44
^EXIT=0$
55
^SIGNAL=0$
66
^\*\* 0 of 1 failed \(1 iterations\)$

regression/statement-list/Bool4/main.awl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FUNCTION_BLOCK "Bool4"
1+
FUNCTION_BLOCK "Main"
22
VERSION : 0.1
33
VAR_TEMP
44
temp1 : Bool;

regression/statement-list/Bool4/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
main.awl
3-
--function \"Bool4\"
3+
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$

regression/statement-list/Bool5/main.awl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FUNCTION_BLOCK "Bool5"
1+
FUNCTION_BLOCK "Main"
22
VERSION : 0.1
33
VAR_INPUT
44
in1 : Bool;

regression/statement-list/Bool5/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
main.awl
3-
--function \"Bool5\"
3+
44
^EXIT=0$
55
^SIGNAL=0$
66
^\*\* 0 of 1 failed \(1 iterations\)$

regression/statement-list/Div_Real/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ main.awl
33
--show-parse-tree
44
^EXIT=0$
55
^SIGNAL=0$
6-
^Name: "Div_Real"$
6+
^Name: Div_Real$
77
^Version: 0[.]1$
88
^ \* type: floatbv$
99
^ \* width: 32$

regression/statement-list/Function_Call1/test.desc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ main.awl
33
--show-parse-tree
44
^EXIT=0$
55
^SIGNAL=0$
6-
^Name: "Function_Call1"$
6+
^Name: Function_Call1$
77
^Version: 0[.]1$
8-
^statement_list_call "__Function"$
8+
^statement_list_call __Function$
99
^ param := In1$
1010
--
1111
^warning: ignoring

regression/statement-list/Function_Call2/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
main.awl
3-
--function \"Function_Call2\"
3+
--function Function_Call2
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$

regression/statement-list/Mul_DInt/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ main.awl
33
--show-parse-tree
44
^EXIT=0$
55
^SIGNAL=0$
6-
^Name: "Mul_DInt"$
6+
^Name: Mul_DInt$
77
^Version: 0[.]1$
88
^ \* type: signedbv$
99
^ \* width: 32$

regression/statement-list/Multiple_Elements/test.desc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ main.awl
33
--show-parse-tree
44
^EXIT=0$
55
^SIGNAL=0$
6-
^Name: "Mult_1"$
7-
^Name: "Mult_2"$
8-
^Name: "Mult_3"$
6+
^Name: Mult_1$
7+
^Name: Mult_2$
8+
^Name: Mult_3$
99
--
1010
^warning: ignoring

regression/statement-list/Sub_DInt/main.awl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FUNCTION_BLOCK "Sub_DInt"
1+
FUNCTION_BLOCK "Main"
22
VERSION : 0.1
33
VAR_INPUT
44
in1 : DInt;

regression/statement-list/Sub_DInt/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
main.awl
3-
--function \"Sub_DInt\"
3+
44
^EXIT=10$
55
^SIGNAL=0$
66
^SAT checker: instance is SATISFIABLE$

regression/statement-list/Var_Declaration/test.desc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ main.awl
33
--show-parse-tree
44
^EXIT=0$
55
^SIGNAL=0$
6-
^Name: "Var_assign_FB"$
7-
^Name: "Var_assign_FC"$
6+
^Name: Var_assign_FB$
7+
^Name: Var_assign_FC$
88
^Version: 0[.]1$
99
^ \* type: bool$
1010
^ \* type: floatbv$

src/statement-list/scanner.l

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include <util/pragma_wnull_conversion.def>
2222
#include <util/pragma_wdeprecated_register.def>
2323

24+
#include <algorithm>
25+
2426
// Visual Studio
2527
#if defined _MSC_VER
2628
// Disable warning for signed/unsigned mismatch.
@@ -75,6 +77,7 @@ void statement_list_scanner_init()
7577

7678
%x GRAMMAR
7779
%x TAG_NAME
80+
%x MODULE_NAME
7881
%x TAG_ATTRIBUTES
7982
%x VERSION_ANNOTATION
8083

@@ -90,9 +93,9 @@ void statement_list_scanner_init()
9093
TAG { loc(); BEGIN(TAG_NAME); return TOK_TAG; }
9194
BEGIN { loc(); return TOK_BEGIN; }
9295
VERSION { loc(); BEGIN(VERSION_ANNOTATION); return TOK_VERSION; }
93-
FUNCTION_BLOCK { loc(); return TOK_FUNCTION_BLOCK; }
96+
FUNCTION_BLOCK { loc(); BEGIN(MODULE_NAME); return TOK_FUNCTION_BLOCK; }
9497
END_FUNCTION_BLOCK { loc(); return TOK_END_FUNCTION_BLOCK; }
95-
FUNCTION { loc(); return TOK_FUNCTION; }
98+
FUNCTION { loc(); BEGIN(MODULE_NAME); return TOK_FUNCTION; }
9699
END_FUNCTION { loc(); return TOK_END_FUNCTION; }
97100
VAR_INPUT { loc(); return TOK_VAR_INPUT; }
98101
VAR_OUTPUT { loc(); return TOK_VAR_OUTPUT; }
@@ -110,7 +113,7 @@ void statement_list_scanner_init()
110113
Void { loc(); return TOK_VOID; }
111114
L { loc(); return TOK_LOAD; }
112115
T { loc(); return TOK_TRANSFER; }
113-
CALL { loc(); return TOK_CALL; }
116+
CALL { loc(); BEGIN(MODULE_NAME); return TOK_CALL; }
114117
NOP { loc(); return TOK_NOP; }
115118
SET { loc(); return TOK_SET_RLO; }
116119
CLR { loc(); return TOK_CLR_RLO; }
@@ -292,6 +295,24 @@ void statement_list_scanner_init()
292295
}
293296
END_TAG { loc(); BEGIN(GRAMMAR); return TOK_END_TAG; }
294297
}
298+
299+
<MODULE_NAME>{
300+
[\t\r\n ] ;
301+
\"[^\"\r\t\n]+\" {
302+
newstack(yystatement_listlval);
303+
std::string str{yytext};
304+
str.erase(
305+
std::remove(begin(str), end(str), '\"' ),
306+
end(str));
307+
parser_stack(yystatement_listlval) =
308+
convert_identifier(str);
309+
PARSER.set_source_location(
310+
parser_stack(yystatement_listlval));
311+
BEGIN(GRAMMAR);
312+
return TOK_IDENTIFIER;
313+
}
314+
}
315+
295316
<TAG_ATTRIBUTES>{
296317
[\t\r," ] ;
297318
([t|T][R|r][u|U][e|E])|([f|F][a|A][l|L][s|S][e|E]) ;

src/statement-list/statement_list_typecheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ Author: Matthias Weiss, [email protected]
3030
/// Postfix for the type of a data block.
3131
#define DATA_BLOCK_TYPE_POSTFIX "_db"
3232
/// Name of the CBMC assert function.
33-
#define CPROVER_ASSERT "\"" CPROVER_PREFIX "assert\""
33+
#define CPROVER_ASSERT CPROVER_PREFIX "assert"
3434
/// Name of the CBMC assume function.
35-
#define CPROVER_ASSUME "\"" CPROVER_PREFIX "assume\""
35+
#define CPROVER_ASSUME CPROVER_PREFIX "assume"
3636
/// Name of the RLO symbol used in some operations.
3737
#define CPROVER_TEMP_RLO CPROVER_PREFIX "temp_rlo"
3838

src/util/irep_ids.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ IREP_ID_TWO(statement_list, Statement List)
766766
IREP_ID_ONE(statement_list_type)
767767
IREP_ID_ONE(statement_list_function)
768768
IREP_ID_ONE(statement_list_function_block)
769-
IREP_ID_TWO(statement_list_main_function, "Main")
769+
IREP_ID_TWO(statement_list_main_function, Main)
770770
IREP_ID_ONE(statement_list_data_block)
771771
IREP_ID_ONE(statement_list_version)
772772
IREP_ID_ONE(statement_list_var_input)

0 commit comments

Comments
 (0)