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
|
@ -1822,7 +1822,14 @@ void parse_include(Lexer& lex, const src::FileDescr* fdescr) {
|
|||
|
||||
bool parse_source(std::istream* is, src::FileDescr* fdescr) {
|
||||
src::SourceReader reader{is, fdescr};
|
||||
Lexer lex{reader, true, ";,()[] ~."};
|
||||
Lexer lex{reader, ";,()[] ~."};
|
||||
// previously, FunC had lisp-style comments,
|
||||
// but starting from v0.5.0, it supports traditional (slash) comments alongside
|
||||
// (in IDE, the user has a setting, what comment style he prefers)
|
||||
// maybe, in some far future, we'll stop supporting lisp-style comments
|
||||
lex.set_comment_tokens(";;", "{-", "-}");
|
||||
lex.set_comment2_tokens("//", "/*", "*/");
|
||||
lex.start_parsing();
|
||||
while (lex.tp() != _Eof) {
|
||||
if (lex.tp() == _PragmaHashtag) {
|
||||
parse_pragma(lex);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue