mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
[FunC] Support traditional // and /**/ comments
They work alongside Lisp-style ;; and {--}, without any #pragma. Conceptually, a new syntax should be disabled by default and activated using a special compiler option. But now, we don't have an easy way to provide compiler options in func-js, blueprint, etc. Note, that introducing per-file #pragma is a wrong approach here, since if we want to fire human-readable error on using '//' without pragma, lexer should nevertheless work differently. (this could be controlled by a launch option, but see above)
This commit is contained in:
parent
a174f858be
commit
30572c77d6
6 changed files with 105 additions and 27 deletions
39
crypto/func/auto-tests/tests/comments.fc
Normal file
39
crypto/func/auto-tests/tests/comments.fc
Normal file
|
@ -0,0 +1,39 @@
|
|||
|
||||
_ get10();
|
||||
|
||||
int {-
|
||||
block comment
|
||||
/*
|
||||
nested
|
||||
*/
|
||||
;;;; -} main()
|
||||
|
||||
// inside a comment, {- doesn't start a new one
|
||||
{- but if ;; is inside, a comment may end at this line-} {
|
||||
var cc = "a string may contain {- or // or /*, not parsed";
|
||||
// return 1;
|
||||
return get10() + /*
|
||||
traditional comment /* may be also nested */
|
||||
// line comment
|
||||
// ends */1 +
|
||||
1;
|
||||
{- moreover, different comment styles
|
||||
may be used for opening and closing
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
first line
|
||||
//* nested
|
||||
//two-lined*/
|
||||
*/
|
||||
|
||||
int get10() method_id(10) {
|
||||
return 10;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
TESTCASE | 0 | | 12
|
||||
TESTCASE | 10 | | 10
|
||||
*/
|
11
crypto/func/auto-tests/tests/invalid-cmt-eof.fc
Normal file
11
crypto/func/auto-tests/tests/invalid-cmt-eof.fc
Normal file
|
@ -0,0 +1,11 @@
|
|||
int main() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
{-
|
||||
int ...
|
||||
|
||||
/*
|
||||
@compilation_should_fail
|
||||
@stderr comment extends past end of file
|
||||
*/
|
Loading…
Add table
Add a link
Reference in a new issue