-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support CRLF as newline for Move files (#90)
* [move-compiler] Support CRLF as newline for Move files Fix issue: starcoinorg/starcoin#3130 * feat: validate crlf in source * [move-compiler] Support CRLF as newline for Move files Fix issue: starcoinorg/starcoin#3130 * feat: fix test-ci fail Signed-off-by: sahithiacn <[email protected]> Closes: #328
- Loading branch information
Showing
10 changed files
with
202 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
language/move-compiler/tests/move_check/parser/newline_crlf.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/// This is a test. | ||
module 0x8675309::M { | ||
/** | ||
* One can have /* nested */ | ||
* // block comments | ||
*/ | ||
fun f() { } | ||
|
||
/* This is a nested /* regular comment // */ */ | ||
fun g() {} | ||
|
||
// This is a line comment which contains unbalanced /* delimiter. | ||
fun h() {} | ||
|
||
// Comments in strings are not comments at all. | ||
fun str(): vector<u8> { | ||
b"http://diem.com" | ||
} | ||
|
||
// This is a regular comment which appears where a doc comment would not be allowed. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
language/move-ir-compiler/transactional-tests/tests/parsing/crlf.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
processed 6 tasks | ||
|
||
task 0 'print-bytecode'. lines 1-6: | ||
// Move bytecode v5 | ||
script { | ||
|
||
|
||
main() { | ||
B0: | ||
0: Ret | ||
} | ||
} | ||
|
||
task 1 'print-bytecode'. lines 8-14: | ||
// Move bytecode v5 | ||
script { | ||
|
||
|
||
main() { | ||
B0: | ||
0: Ret | ||
} | ||
} | ||
|
||
task 2 'print-bytecode'. lines 16-20: | ||
// Move bytecode v5 | ||
script { | ||
|
||
|
||
main() { | ||
B0: | ||
0: Ret | ||
} | ||
} | ||
|
||
task 3 'print-bytecode'. lines 22-27: | ||
// Move bytecode v5 | ||
script { | ||
|
||
|
||
main() { | ||
B0: | ||
0: Ret | ||
} | ||
} | ||
|
||
task 4 'print-bytecode'. lines 29-36: | ||
Error: ParserError: Invalid Token: invalid token kind for statement Slash | ||
|
||
task 5 'print-bytecode'. lines 38-46: | ||
// Move bytecode v5 | ||
script { | ||
|
||
|
||
main() { | ||
B0: | ||
0: Ret | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
language/move-ir-compiler/transactional-tests/tests/parsing/crlf.mvir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
//# print-bytecode | ||
main() { | ||
label b0: | ||
// return; | ||
return; | ||
} | ||
|
||
//# print-bytecode | ||
main() { | ||
label b0: | ||
// return; | ||
// return; | ||
return; | ||
} | ||
|
||
//# print-bytecode | ||
main() { | ||
label b0: | ||
return; // return; | ||
} | ||
|
||
//# print-bytecode | ||
main() { | ||
label b0: | ||
// return; | ||
return; // return; | ||
} | ||
|
||
//# print-bytecode | ||
// In Move, /* */ are block comment delimiters. Not so in Move IR, so the `/*` below | ||
// cannot be parsed. | ||
main() { | ||
label b0: | ||
return; | ||
/* return; */ | ||
} | ||
|
||
//# print-bytecode | ||
// Since /* */ are not block comment delimiters, they do not behave in any unique way when | ||
// they appear within comments. | ||
main() { | ||
label b0: | ||
// /* | ||
return; | ||
// */ | ||
} |