diff --git a/src/julec/main.jule b/src/julec/main.jule index cf6ed6bef..5349716b7 100644 --- a/src/julec/main.jule +++ b/src/julec/main.jule @@ -28,7 +28,9 @@ static HELP_MAP: [...][2]str = [ [CMD_MOD, "Module management"], ] -fn print_error_message(msg: str) { outln(msg) } +fn print_error_message(msg: str) { + outln(msg) +} // Command: julec help fn help(&args: []str) { diff --git a/src/julec/obj/cxx/object.jule b/src/julec/obj/cxx/object.jule index 1813a9e79..da65ee912 100644 --- a/src/julec/obj/cxx/object.jule +++ b/src/julec/obj/cxx/object.jule @@ -85,7 +85,7 @@ impl ObjectCoder { // Returns location information of token as cstr bytes. fn loc_info(self, &t: Token): str { - let mut loc = t.file.path() + let mut loc = t.file.path // Normalize path if production compilation enabled. if env::PRODUCTION { diff --git a/src/julec/optimizing/scope.jule b/src/julec/optimizing/scope.jule index 567888db0..112f4bd13 100644 --- a/src/julec/optimizing/scope.jule +++ b/src/julec/optimizing/scope.jule @@ -58,7 +58,7 @@ impl ScopeOptimizer { let mut m = (&FnCallExprModel)(d.model) if env::PRODUCTION { if !m.func.is_builtin() && - is_std_package(m.func.decl.token.file.path(), "debug") { + is_std_package(m.func.decl.token.file.path, "debug") { self.set_current_stmt(nil) ret } diff --git a/std/jule/ast/node.jule b/std/jule/ast/node.jule index cd99bfd8b..fbfdc0e00 100644 --- a/std/jule/ast/node.jule +++ b/std/jule/ast/node.jule @@ -213,7 +213,9 @@ pub struct LitExpr { impl LitExpr { // Reports whether literal is nil value. - pub fn is_nil(self): bool { ret self.value == TokenKind.Nil } + pub fn is_nil(self): bool { + ret self.value == TokenKind.Nil + } } // Unsafe expression. @@ -307,7 +309,9 @@ pub struct FieldExprPair { impl FieldExprPair { // Reports whether pair targeted field. - pub fn is_targeted(self): bool { ret self.field.id != TokenId.Na } + pub fn is_targeted(self): bool { + ret self.field.id != TokenId.Na + } } // Struct literal instiating expression. @@ -324,7 +328,9 @@ pub struct BraceLit { impl BraceLit { // Reports whether literal is empty ( {} ). - pub fn is_empty(self): bool { ret self.exprs.len == 0 } + pub fn is_empty(self): bool { + ret self.exprs.len == 0 + } } // Key-value pair expression. @@ -343,7 +349,9 @@ pub struct SliceExpr { impl SliceExpr { // Reports whether slice is empty. - pub fn is_empty(self): bool { ret self.elems.len == 0 } + pub fn is_empty(self): bool { + ret self.elems.len == 0 + } } // Indexing expression. @@ -459,7 +467,9 @@ pub struct FnDecl { impl FnDecl { // Reports whether function is anonymous. - pub fn is_anon(self): bool { ret self.ident == Ident.Anon } + pub fn is_anon(self): bool { + ret self.ident == Ident.Anon + } } // Variable declaration. @@ -508,7 +518,9 @@ pub struct WhileKind { impl WhileKind { // Reports whether kind is while-next iteration. - pub fn is_while_next(self): bool { ret self.next != nil } + pub fn is_while_next(self): bool { + ret self.next != nil + } } // Range iteration kind. diff --git a/std/jule/importer/directive_eval.jule b/std/jule/importer/directive_eval.jule index 663aa5a0f..21a89502b 100644 --- a/std/jule/importer/directive_eval.jule +++ b/std/jule/importer/directive_eval.jule @@ -23,7 +23,7 @@ impl DirectiveEval { kind: LogKind.Error, row: t.row, column: t.column, - path: t.file.path(), + path: t.file.path, text: logf(fmt, args...), }) } diff --git a/std/jule/importer/importer.jule b/std/jule/importer/importer.jule index af926ee70..19ad4e736 100644 --- a/std/jule/importer/importer.jule +++ b/std/jule/importer/importer.jule @@ -118,7 +118,7 @@ impl Importer for JuleImporter { let _path = join(path, dirent.name) let mut file = new_file_set(_path) - file.fill(read_buff(file.path())) + file.fill(read_buff(file.path)) let mut errors = lex(file, LexMode.Standard) if errors.len > 0 { ret nil, errors diff --git a/std/jule/lex/buffer.jule b/std/jule/lex/file.jule similarity index 67% rename from std/jule/lex/buffer.jule rename to std/jule/lex/file.jule index 633580cde..44f1f9fcf 100644 --- a/std/jule/lex/buffer.jule +++ b/std/jule/lex/file.jule @@ -7,37 +7,37 @@ use path for std::fs::path // Fileset for lexing. pub struct File { - pub data: []byte - - _path: str - mut _tokens: []Token + pub path: str + pub data: []byte + pub tokens: []Token } impl File { // Reports whether file path is exist and accessible. pub fn is_ok(self): bool { - Status.of(self._path) else { ret false } + _ = Status.of(self.path) else { ret false } ret true } // Fill data. - pub fn fill(mut self, mut data: []byte) { self.data = data } - - // Returns path. - pub fn path(self): str { ret self._path } + pub fn fill(mut self, mut data: []byte) { + self.data = data + } // Returns directory of file's path. - pub fn dir(self): str { ret path::dir(self._path) } + pub fn dir(self): str { + ret path::dir(self.path) + } // Returns filename. - pub fn name(self): str { ret path::base(self._path) } + pub fn name(self): str { + ret path::base(self.path) + } // Returns self as uintptr. - pub fn addr(self): uintptr { ret uintptr(&self) } - - // Returns tokens of file. - // Tokens are mutable. - pub fn tokens(mut self): []Token { ret self._tokens } + pub fn addr(self): uintptr { + ret uintptr(&self) + } // Returns line (not include new-line char) by row. // Returns empty string if line is not buffer. @@ -49,7 +49,6 @@ impl File { if self.data[i] != '\n' { continue } - n++ if n == row { ret str(self.data[line_start:i]) @@ -63,6 +62,6 @@ impl File { // Returns new File points to Jule file. pub fn new_file_set(path: str): &File { ret &File{ - _path: path, + path: path, } } diff --git a/std/jule/lex/lex.jule b/std/jule/lex/lex.jule index c7bdfad95..80d9b9983 100644 --- a/std/jule/lex/lex.jule +++ b/std/jule/lex/lex.jule @@ -113,7 +113,7 @@ fn make_err(row: int, col: int, &f: &File, fmt: LogMsg, args: ...any): Log { kind: LogKind.Error, row: row, column: col, - path: f.path(), + path: f.path, text: logf(fmt, args...), } } @@ -562,12 +562,12 @@ impl Lex { self.column += 1 if self.pos+1 < self.file.data.len && r == '*' && self.file.data[self.pos+1] == '/' { + self.column += 2 + self.pos += 2 if self.mode & LexMode.Comment == LexMode.Comment { token.id = TokenId.Comment token.kind = str(self.file.data[start:self.pos]) } - self.column += 2 - self.pos += 2 ret } } @@ -848,6 +848,6 @@ pub fn lex(mut f: &File, mode: LexMode): []Log { ret lex.errors } - f._tokens = lex.tokens + f.tokens = lex.tokens ret nil } diff --git a/std/jule/parser/parser.jule b/std/jule/parser/parser.jule index 70a2c3cda..5ea667681 100644 --- a/std/jule/parser/parser.jule +++ b/std/jule/parser/parser.jule @@ -51,7 +51,7 @@ fn make_err(row: int, col: int, &f: &File, fmt: LogMsg, args: ...any): Log { kind: LogKind.Error, row: row, column: col, - path: f.path(), + path: f.path, text: logf(fmt, args...), } } @@ -196,7 +196,7 @@ fn compiler_err(&token: Token, &fmt: LogMsg, args: ...any): Log { kind: LogKind.Error, row: token.row, column: token.column, - path: token.file.path(), + path: token.file.path, text: logf(fmt, args...), line: token.file.get_row(token.row), } @@ -1929,13 +1929,12 @@ impl Parser { file: f, } - let mut tokens = f.tokens() - self.check_ranges(tokens) + self.check_ranges(f.tokens) if self.errors.len > 0 { ret } - let mut stmts = split_stmts(tokens) + let mut stmts = split_stmts(f.tokens) // Get top directives. let mut i = 0 diff --git a/std/jule/sema/sema.jule b/std/jule/sema/sema.jule index 9aa68c2f3..11e712cb2 100644 --- a/std/jule/sema/sema.jule +++ b/std/jule/sema/sema.jule @@ -47,7 +47,7 @@ fn compiler_err(&token: Token, line: bool, fmt: LogMsg, args: ...any): Log { kind: LogKind.Error, row: token.row, column: token.column, - path: token.file.path(), + path: token.file.path, text: logf(fmt, args...), } if line { @@ -2305,7 +2305,7 @@ impl Sema { } let s = sptr.elem.strct() - if s == nil || !is_std_package(s.decl.token.file.path(), "testing") { + if s == nil || !is_std_package(s.decl.token.file.path, "testing") { self.push_err(f.decl.token, LogMsg.WrongTestFnDecl) self.push_suggestion(LogMsg.UseExpectedTestFnDecl) ret