Closed Veercodeprog closed 3 months ago
Thank you for your interest in Salam language! We appreciate you opening your first issue. Contributions like yours help make Salam language better.
What is your compiler? What is your OS? and how are you compiling?
in my Windows laptop, I have WSL SO:
1- Open cmd
2- type wsl and enter
3- git clone the repository and cd to the project
4- run ./b.sh
and finally it's working.
output is:
salam.c: In function ‘read_token’:
salam.c:1042:17: warning: format not a string literal and no format arguments [-Wformat-security]
1042 | print_error(messages[language][MESSAGE_LEXER_TOKEN_READ_UNICODE]);
| ^~~~~~~~~~~
salam.c: In function ‘unread_token’:
salam.c:1069:17: warning: format not a string literal and no format arguments [-Wformat-security]
1069 | print_error(messages[language][MESSAGE_LEXER_TOKEN_UNREAD_UNICODE]);
| ^~~~~~~~~~~
salam.c: In function ‘read_number’:
salam.c:1098:25: warning: format not a string literal and no format arguments [-Wformat-security]
1098 | print_error(messages[language][MESSAGE_LEXER_NUMBER_FLOAT_NEED_NUMBER_AFTER_DOT]);
| ^~~~~~~~~~~
salam.c: In function ‘read_comment_multiline’:
salam.c:1143:25: warning: format not a string literal and no format arguments [-Wformat-security]
1143 | print_error(messages[language][MESSAGE_LEXER_COMMENT_MULTI_NOT_CLOSED]);
| ^~~~~~~~~~~
salam.c: In function ‘read_string’:
salam.c:1170:33: warning: format not a string literal and no format arguments [-Wformat-security]
1170 | print_error(messages[language][MESSAGE_LEXER_STRING_READ_MEMORY]);
| ^~~~~~~~~~~
salam.c:1191:33: warning: format not a string literal and no format arguments [-Wformat-security]
1191 | print_error(messages[language][MESSAGE_LEXER_STRING_UNKNOWN_ESCAPE]);
| ^~~~~~~~~~~
salam.c:1199:33: warning: format not a string literal and no format arguments [-Wformat-security]
1199 | print_error(messages[language][MESSAGE_LEXER_STRING_CONVERT_MULTIBYTE]);
| ^~~~~~~~~~~
salam.c: In function ‘read_identifier’:
salam.c:1237:25: warning: format not a string literal and no format arguments [-Wformat-security]
1237 | print_error(messages[language][MESSAGE_LEXER_IDENTIFIER_CONVERT_MULTIBYTE]);
| ^~~~~~~~~~~
salam.c: In function ‘nud_array’:
salam.c:2460:25: warning: format not a string literal and no format arguments [-Wformat-security]
2460 | print_error(messages[language][MESSAGE_LEXER_ARRAY_NOT_CLOSED]);
| ^~~~~~~~~~~
salam.c: In function ‘parser_block’:
salam.c:2567:33: warning: format not a string literal and no format arguments [-Wformat-security]
2567 | print_error(messages[language][MESSAGE_PARSER_BLOCK_MEMORY_ISSUE]);
| ^~~~~~~~~~~
salam.c: In function ‘interpreter_interpret_once’:
salam.c:3161:25: warning: format not a string literal and no format arguments [-Wformat-security]
3161 | print_message(messages[language][MESSAGE_INTERPRETER_UNKNOWN_NODE_AS_INTERPRETER_ONCE]);
| ^~~~~~~~~~~~~
salam.c: In function ‘interpreter_interpret’:
salam.c:3213:17: warning: format not a string literal and no format arguments [-Wformat-security]
3213 | print_message(messages[language][MESSAGE_INTERPRETER_MAIN_RETURN_CODE]);
| ^~~~~~~~~~~~~
salam.c:3216:17: warning: format not a string literal and no format arguments [-Wformat-security]
3216 | print_error(messages[language][MESSAGE_INTERPRETER_MAIN_NORETURN]);
| ^~~~~~~~~~~
salam.c: In function ‘interpreter_expression_data_type’:
salam.c:3232:42: warning: return discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
3232 | return messages[language][MESSAGE_TOKEN_UNKNOWN];
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
salam.c:3234:42: warning: return discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
3234 | return messages[language][MESSAGE_TOKEN_NULL];
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
salam.c:3236:42: warning: return discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
3236 | return messages[language][MESSAGE_TOKEN_NUMBER_INT];
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
salam.c:3238:42: warning: return discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
3238 | return messages[language][MESSAGE_TOKEN_NUMBER_FLOAT];
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
salam.c:3240:42: warning: return discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
3240 | return messages[language][MESSAGE_TOKEN_BOOL];
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
salam.c:3242:42: warning: return discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
3242 | return messages[language][MESSAGE_TOKEN_STRING];
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
salam.c:3244:42: warning: return discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
3244 | return messages[language][MESSAGE_TOKEN_ARRAY];
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
salam.c:3246:42: warning: return discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
3246 | return messages[language][MESSAGE_TOKEN_UNKNOWN];
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
salam.c: In function ‘interpreter_expression_data’:
salam.c:3253:17: warning: format not a string literal and no format arguments [-Wformat-security]
3253 | printf(messages[language][MESSAGE_TOKEN_UNKNOWN]);
| ^~~~~~
salam.c:3256:17: warning: format not a string literal and no format arguments [-Wformat-security]
3256 | printf(messages[language][MESSAGE_TOKEN_NULL]);
| ^~~~~~
salam.c:3288:17: warning: format not a string literal and no format arguments [-Wformat-security]
3288 | printf(messages[language][MESSAGE_TOKEN_UNKNOWN]);
| ^~~~~~
salam.c: In function ‘interpreter_block’:
salam.c:3339:25: warning: format not a string literal and no format arguments [-Wformat-security]
3339 | print_error(messages[language][MESSAGE_INTERPRETER_CANNOT_HAVE_RET_BREAK_CON_OUT_OF_LOOP]);
| ^~~~~~~~~~~
salam.c: In function ‘interpreter_expression_binary’:
salam.c:3426:17: warning: format not a string literal and no format arguments [-Wformat-security]
3426 | print_error(messages[language][MESSAGE_INTERPRETER_EXPRESSION_INVALID_VALUE_IN_BINARY]);
| ^~~~~~~~~~~
salam.c:3509:25: warning: format not a string literal and no format arguments [-Wformat-security]
3509 | print_error(messages[language][MESSAGE_INTERPRETER_EXPRESSION_CANNOT_COMPARE_THIS_KIND_OF_VALUE_TYPES]);
| ^~~~~~~~~~~
salam.c:3531:25: warning: format not a string literal and no format arguments [-Wformat-security]
3531 | print_error(messages[language][MESSAGE_INTERPRETER_EXPRESSION_CANNOT_AND_FOR_THIS_VALUES]);
| ^~~~~~~~~~~
salam.c:3554:25: warning: format not a string literal and no format arguments [-Wformat-security]
3554 | print_error(messages[language][MESSAGE_INTERPRETER_EXPRESSION_CANNOT_OR_FOR_THIS_VALUES]);
| ^~~~~~~~~~~
salam.c:3559:17: warning: format not a string literal and no format arguments [-Wformat-security]
3559 | print_error(messages[language][MESSAGE_INTERPRETER_EXPRESSION_CANNOT_BINARY_OP_FOR_NON_INT]);
| ^~~~~~~~~~~
salam.c:3607:33: warning: format not a string literal and no format arguments [-Wformat-security]
3607 | print_error(messages[language][MESSAGE_INTERPRETER_EXPRESSION_CANNOT_MODULE_OP_FOR_FLOAT]);
| ^~~~~~~~~~~
salam.c:3617:33: warning: format not a string literal and no format arguments [-Wformat-security]
3617 | print_error(messages[language][MESSAGE_INTERPRETER_EXPRESSION_CANNOT_DIVIDE_BY_ZERO]);
| ^~~~~~~~~~~
salam.c: In function ‘interpreter_function_run’:
salam.c:3662:25: warning: format not a string literal and no format arguments [-Wformat-security]
3662 | print_error(messages[language][MESSAGE_INTERPRETER_FUNCTION_CALL_NUMBER_ARGS_IS_MORE]);
| ^~~~~~~~~~~
salam.c:3664:25: warning: format not a string literal and no format arguments [-Wformat-security]
3664 | print_error(messages[language][MESSAGE_INTERPRETER_FUNCTION_CALL_NUMBER_ARGS_IS_LESS]);
| ^~~~~~~~~~~
salam.c: In function ‘interpreter_expression_function_call’:
salam.c:3836:17: warning: format not a string literal and no format arguments [-Wformat-security]
3836 | print_error(messages[language][MESSAGE_INTERPRETER_FUNCTION_NOT_EXISTS]);
| ^~~~~~~~~~~
salam.c: In function ‘interpreter_expression_assignment’:
salam.c:3882:17: warning: format not a string literal and no format arguments [-Wformat-security]
3882 | print_error(messages[language][MESSAGE_INTERPRETER_CANNOT_ASSIGN_VARIABLE_WITH_A_NON_IDENTIFIER_AS_NAME]);
| ^~~~~~~~~~~
<?xml version="1.0" encoding="UTF-8"?>
<AST>
<Functions>
<FunctionDeclaration>
<Name>سلام</Name>
<Arguments />
<Block>
<StatementPrint>
<Expression>
<BinaryOperator>
<Operator>+</Operator>
<Left>
<Expression>
<Literal>
<Type>INT</Type>
<Value>1</Value>
</Literal>
</Expression>
</Left>
<Right>
<Expression>
<Literal>
<Type>INT</Type>
<Value>3</Value>
</Literal>
</Expression>
</Right>
</BinaryOperator>
</Expression>
</StatementPrint>
</Block>
</FunctionDeclaration>
</Functions>
<Expressions />
</AST>
====================================
4
مقدار بازگشتی از تابع اصلی وجود ندارد، استفاده از پیشفرض.
====================================
free interpreter
end interpreter free
free parser
Free function سلام
ast_node_free
node type: 0
free ast function
free function name
free function arguments
free function body
ast_node_free
node type: 9
free ast block
ast_node_free
node type: 4
free ast print
free print expr
ast_expression_free
---- expr type: 4
ast_expression_free_binary
free print expr value
check expr value of print
ast_expression_free_data
start checking type on ast_expression_free_data 1
free expression data
free expression data main
ast_expression_free_data main
let's free it's at all
*parser is null 1
parser is null 0
end parser free
free lexer
end lexer free
=================================================================
==689==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 24 byte(s) in 1 object(s) allocated from:
#0 0x7fdf4fa0c887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
#1 0x564b739e7099 in led_plus_minus /mnt/c/Users/MAX/salam/salam.c:2385
#2 0x564b739e4cdb in parser_expression_pratt /mnt/c/Users/MAX/salam/salam.c:2302
#3 0x564b739e4322 in parser_expression /mnt/c/Users/MAX/salam/salam.c:2280
#4 0x564b739dff30 in parser_statement_print /mnt/c/Users/MAX/salam/salam.c:2046
#5 0x564b739e3ac2 in parser_statement /mnt/c/Users/MAX/salam/salam.c:2246
#6 0x564b739ea5ce in parser_block /mnt/c/Users/MAX/salam/salam.c:2558
#7 0x564b739df155 in parser_function /mnt/c/Users/MAX/salam/salam.c:2010
#8 0x564b739ebaff in parser_parse /mnt/c/Users/MAX/salam/salam.c:2606
#9 0x564b73a0e6ad in main /mnt/c/Users/MAX/salam/salam.c:4084
#10 0x7fdf4f123d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 48 byte(s) in 1 object(s) allocated from:
#0 0x7fdf4fa0c887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
#1 0x564b739e7b93 in nud_number /mnt/c/Users/MAX/salam/salam.c:2417
#2 0x564b739e4804 in parser_expression_pratt /mnt/c/Users/MAX/salam/salam.c:2296
#3 0x564b739e4322 in parser_expression /mnt/c/Users/MAX/salam/salam.c:2280
#4 0x564b739dff30 in parser_statement_print /mnt/c/Users/MAX/salam/salam.c:2046
#5 0x564b739e3ac2 in parser_statement /mnt/c/Users/MAX/salam/salam.c:2246
#6 0x564b739ea5ce in parser_block /mnt/c/Users/MAX/salam/salam.c:2558
#7 0x564b739df155 in parser_function /mnt/c/Users/MAX/salam/salam.c:2010
#8 0x564b739ebaff in parser_parse /mnt/c/Users/MAX/salam/salam.c:2606
#9 0x564b73a0e6ad in main /mnt/c/Users/MAX/salam/salam.c:4084
#10 0x7fdf4f123d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 48 byte(s) in 1 object(s) allocated from:
#0 0x7fdf4fa0c887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
#1 0x564b739e7b93 in nud_number /mnt/c/Users/MAX/salam/salam.c:2417
#2 0x564b739e4804 in parser_expression_pratt /mnt/c/Users/MAX/salam/salam.c:2296
#3 0x564b739e6fa1 in led_plus_minus /mnt/c/Users/MAX/salam/salam.c:2379
#4 0x564b739e4cdb in parser_expression_pratt /mnt/c/Users/MAX/salam/salam.c:2302
#5 0x564b739e4322 in parser_expression /mnt/c/Users/MAX/salam/salam.c:2280
#6 0x564b739dff30 in parser_statement_print /mnt/c/Users/MAX/salam/salam.c:2046
#7 0x564b739e3ac2 in parser_statement /mnt/c/Users/MAX/salam/salam.c:2246
#8 0x564b739ea5ce in parser_block /mnt/c/Users/MAX/salam/salam.c:2558
#9 0x564b739df155 in parser_function /mnt/c/Users/MAX/salam/salam.c:2010
#10 0x564b739ebaff in parser_parse /mnt/c/Users/MAX/salam/salam.c:2606
#11 0x564b73a0e6ad in main /mnt/c/Users/MAX/salam/salam.c:4084
#12 0x7fdf4f123d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 16 byte(s) in 1 object(s) allocated from:
#0 0x7fdf4fa0c887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
#1 0x564b739e7aa9 in nud_number /mnt/c/Users/MAX/salam/salam.c:2414
#2 0x564b739e4804 in parser_expression_pratt /mnt/c/Users/MAX/salam/salam.c:2296
#3 0x564b739e4322 in parser_expression /mnt/c/Users/MAX/salam/salam.c:2280
#4 0x564b739dff30 in parser_statement_print /mnt/c/Users/MAX/salam/salam.c:2046
#5 0x564b739e3ac2 in parser_statement /mnt/c/Users/MAX/salam/salam.c:2246
#6 0x564b739ea5ce in parser_block /mnt/c/Users/MAX/salam/salam.c:2558
#7 0x564b739df155 in parser_function /mnt/c/Users/MAX/salam/salam.c:2010
#8 0x564b739ebaff in parser_parse /mnt/c/Users/MAX/salam/salam.c:2606
#9 0x564b73a0e6ad in main /mnt/c/Users/MAX/salam/salam.c:4084
#10 0x7fdf4f123d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 16 byte(s) in 1 object(s) allocated from:
#0 0x7fdf4fa0c887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
#1 0x564b739e7aa9 in nud_number /mnt/c/Users/MAX/salam/salam.c:2414
#2 0x564b739e4804 in parser_expression_pratt /mnt/c/Users/MAX/salam/salam.c:2296
#3 0x564b739e6fa1 in led_plus_minus /mnt/c/Users/MAX/salam/salam.c:2379
#4 0x564b739e4cdb in parser_expression_pratt /mnt/c/Users/MAX/salam/salam.c:2302
#5 0x564b739e4322 in parser_expression /mnt/c/Users/MAX/salam/salam.c:2280
#6 0x564b739dff30 in parser_statement_print /mnt/c/Users/MAX/salam/salam.c:2046
#7 0x564b739e3ac2 in parser_statement /mnt/c/Users/MAX/salam/salam.c:2246
#8 0x564b739ea5ce in parser_block /mnt/c/Users/MAX/salam/salam.c:2558
#9 0x564b739df155 in parser_function /mnt/c/Users/MAX/salam/salam.c:2010
#10 0x564b739ebaff in parser_parse /mnt/c/Users/MAX/salam/salam.c:2606
#11 0x564b73a0e6ad in main /mnt/c/Users/MAX/salam/salam.c:4084
#12 0x7fdf4f123d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 2 byte(s) in 1 object(s) allocated from:
#0 0x7fdf4f9b39a7 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:454
#1 0x564b739e72f0 in led_plus_minus /mnt/c/Users/MAX/salam/salam.c:2386
#2 0x564b739e4cdb in parser_expression_pratt /mnt/c/Users/MAX/salam/salam.c:2302
#3 0x564b739e4322 in parser_expression /mnt/c/Users/MAX/salam/salam.c:2280
#4 0x564b739dff30 in parser_statement_print /mnt/c/Users/MAX/salam/salam.c:2046
#5 0x564b739e3ac2 in parser_statement /mnt/c/Users/MAX/salam/salam.c:2246
#6 0x564b739ea5ce in parser_block /mnt/c/Users/MAX/salam/salam.c:2558
#7 0x564b739df155 in parser_function /mnt/c/Users/MAX/salam/salam.c:2010
#8 0x564b739ebaff in parser_parse /mnt/c/Users/MAX/salam/salam.c:2606
#9 0x564b73a0e6ad in main /mnt/c/Users/MAX/salam/salam.c:4084
#10 0x7fdf4f123d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
SUMMARY: AddressSanitizer: 154 byte(s) leaked in 6 allocation(s).
max@DESKTOP-SSI3MPL:/mnt/c/Users/MAX/salam$
There are a lots of warnings and some memory leaks issues, but it's working. these are warnings and not errors.
mac M g++ compiler and gcc , on compiling with gcc it gives me this error, different error with g++ i am running gcc command for salaam.cpp
on running this in mac : /b.sh ./b.sh: line 14: cls: command not found
./b.sh: line 22: ldconfig: command not found efence library is missing Install efence - Electric Fence Malloc Debugger
Oh, it's because your machine is a Mac. it would help if you changed cls
to clear
in the b.sh
file.
=> Fixed
Easiest way is to run the following command:
gcc -g -fsanitize=undefined,address -Walloca -o "s" "salam.c"
@Veercodeprog problem has been fixed? please confirm.
no, still getting the similar error
^
salam.c:3836:15: warning: format string is not a string literal (potentially insecure) [-Wformat-security]
print_error(messages[language][MESSAGE_INTERPRETER_FUNCTION_NOT_EXISTS]);
^~~~~~~~~~~~~~~
salam.c:17:47: note: expanded from macro 'print_error'
^~~
salam.c:3836:15: note: treat the string as an argument to avoid this print_error(messages[language][MESSAGE_INTERPRETER_FUNCTION_NOT_EXISTS]); ^ "%s", salam.c:17:47: note: expanded from macro 'print_error'
^
salam.c:3882:15: warning: format string is not a string literal (potentially insecure) [-Wformat-security] print_error(messages[language][MESSAGE_INTERPRETER_CANNOT_ASSIGN_VARIABLE_WITH_A_NON_IDENTIFIER_AS_NAME]);
salam.c:17:47: note: expanded from macro 'print_error'
#define print_error(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
^~~
salam.c:3882:15: note: treat the string as an argument to avoid this
print_error(messages[language][MESSAGE_INTERPRETER_CANNOT_ASSIGN_VARIABLE_WITH_A_NON_IDENTIFIER_AS_NAME]);
^
"%s",
salam.c:17:47: note: expanded from macro 'print_error'
#define print_error(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
it seems these are warnings and not errors. so that is fine to compile and run Salam. is it true? @Veercodeprog
yes ./s
خوش آمدید به زبان برنامهنویسی سلام! سلام اولین زبان اسکریپتی ایرانی فارسی/عربی برای کامپیوتر است.
استفاده:
salam
مثال: salam my_script.salam # اجرای اسکریپت سلام به نام 'my_script.salam'
با استفاده از سلام، به کشف و خلق بپردازید! برای اطلاعات بیشتر، به وبسایت ما مراجعه کنید: https://salamlang.ir
Happy to help.
Let's MAKE THIS PROGRAMMING language better sooner together,
Since the issue is resolved and you have successfully built and implemented the language, we can close this issue for now.
If you have any questions, ask anytime.
running salaam.c with gcc gives me lots of print errors salam.c:17:47: note: expanded from macro 'print_error'
define print_error(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
salam.c:3531:16: warning: format string is not a string literal (potentially insecure) [-Wformat-security] print_error(messages[language][MESSAGE_INTERPRETER_EXPRESSION_CANNOT_AND_FOR_THIS_VALUES]);
can you help setting the project? , i want to contribute to this project seriously