Skip to content

Commit f83cf9e

Browse files
committed
juledoc: update to latest
1 parent bd633d3 commit f83cf9e

File tree

3 files changed

+48
-43
lines changed

3 files changed

+48
-43
lines changed

builder/commentmap.jule

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ fn BuildCommentMap(mut &tokens: []&token::Token): &CommentMap {
6363
mut i := 0
6464
for i < len(tokens) {
6565
token := tokens[i]
66-
if token.Id != token::Id.Comment {
66+
if token.Id != token::Comment {
6767
i++
6868
continue
6969
}

builder/formatter.jule

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Derived from julefmt. Stay up to date.
66

77
use "std/bytes"
8+
use "std/jule"
89
use "std/jule/ast"
910
use "std/jule/token"
1011
use "std/jule/types"
@@ -250,9 +251,9 @@ impl formatter {
250251
match {
251252
| i == 0:
252253
self.write(" ")
253-
| arg.Kind != token::Kind.RParent &&
254-
d.Args[i-1].Kind != token::Kind.LParent &&
255-
d.Args[i-1].Kind != token::Kind.Excl:
254+
| arg.Id != token::RParent &&
255+
d.Args[i-1].Id != token::LParent &&
256+
d.Args[i-1].Id != token::Excl:
256257
self.write(" ")
257258
}
258259
self.write(arg.Kind)
@@ -395,7 +396,7 @@ impl formatter {
395396
}
396397
self.write("self")
397398
} else {
398-
if !token::IsAnonIdent(p.Ident) {
399+
if !jule::IsBlank(p.Ident) {
399400
self.write(p.Ident)
400401
self.write(": ")
401402
} else if p.Reference {
@@ -443,7 +444,7 @@ impl formatter {
443444
self.write("unsafe ")
444445
}
445446
self.write("fn")
446-
if !token::IsAnonIdent(d.Ident) {
447+
if !jule::IsBlank(d.Ident) {
447448
self.write(" ")
448449
self.write(d.Ident)
449450
}
@@ -625,7 +626,7 @@ impl formatter {
625626
self.write("static ")
626627
} else if d.Constant {
627628
self.write("const ")
628-
} else if d.Setter == nil || d.Setter.Id == token::Id.Eq {
629+
} else if d.Setter == nil || d.Setter.Id == token::Eq {
629630
self.write("let ")
630631
}
631632
}
@@ -1046,7 +1047,7 @@ impl typeFormatter {
10461047
ret
10471048
}
10481049
if len(r.Idents) == 1 {
1049-
if token::IsAnonIdent(r.Idents[0].Kind) {
1050+
if jule::IsBlank(r.Idents[0].Kind) {
10501051
self.format(r.Kind.Kind)
10511052
ret
10521053
}
@@ -1061,7 +1062,7 @@ impl typeFormatter {
10611062
self.write("(")
10621063
for (i, mut t) in types {
10631064
ident := r.Idents[i]
1064-
if token::IsAnonIdent(ident.Kind) {
1065+
if jule::IsBlank(ident.Kind) {
10651066
self.format(t.Kind)
10661067
} else {
10671068
self.write(ident.Kind)
@@ -1443,37 +1444,37 @@ struct binaryFormatter {
14431444

14441445
impl binaryFormatter {
14451446
// Reports whether operator should take space for formatting.
1446-
static fn isOp(op: token::Id): bool {
1447-
ret op == token::Id.DblVline ||
1448-
op == token::Id.DblAmper ||
1449-
op == token::Id.Gt ||
1450-
op == token::Id.Lt ||
1451-
op == token::Id.LtEq ||
1452-
op == token::Id.GtEq ||
1453-
op == token::Id.Eqs ||
1454-
op == token::Id.NotEq
1447+
static fn isOp(op: int): bool {
1448+
ret op == token::DblVline ||
1449+
op == token::DblAmper ||
1450+
op == token::Gt ||
1451+
op == token::Lt ||
1452+
op == token::LtEq ||
1453+
op == token::GtEq ||
1454+
op == token::DblEq ||
1455+
op == token::NotEq
14551456
}
14561457

14571458
// Reports whether the operator is have high formatting precedence.
14581459
// Returns 1 for high precedence, otherwise returns 0.
1459-
static fn opPrec(op: token::Id): int {
1460+
static fn opPrec(op: int): int {
14601461
match op {
1461-
| token::Id.Shl
1462-
| token::Id.Shr
1463-
| token::Id.Star
1464-
| token::Id.Solidus
1465-
| token::Id.Percent
1466-
| token::Id.Amper:
1462+
| token::Shl
1463+
| token::Shr
1464+
| token::Star
1465+
| token::Solidus
1466+
| token::Percent
1467+
| token::Amper:
14671468
ret 1
14681469
|:
14691470
ret 0
14701471
}
14711472
}
14721473

14731474
// Reports whether operator zips operands.
1474-
static fn isHardZipOp(op: token::Id): bool {
1475-
ret op == token::Id.DblVline ||
1476-
op == token::Id.DblAmper
1475+
static fn isHardZipOp(op: int): bool {
1476+
ret op == token::DblVline ||
1477+
op == token::DblAmper
14771478
}
14781479

14791480
fn write(&self, s: str) {

src/main.jule

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ use "std/flag"
99
use "std/jule"
1010
use "std/jule/ast"
1111
use "std/jule/build"
12+
use "std/jule/directive"
13+
use "std/jule/dist"
1214
use "std/jule/parser"
1315
use "std/jule/token"
1416
use "std/os"
@@ -25,20 +27,20 @@ fn writeError(message: str) {
2527
// Derived from the "std/jule/importer", stay up to date.
2628
// Reports whether the arg is exist is distos.
2729
fn checkOs(arg: str): (exist: bool) {
28-
ret arg == build::DistOS.Windows ||
29-
arg == build::DistOS.Darwin ||
30-
arg == build::DistOS.Linux ||
31-
arg == build::DistOS.Unix
30+
ret arg == dist::Windows ||
31+
arg == dist::Darwin ||
32+
arg == dist::Linux ||
33+
arg == dist::Unix
3234
}
3335

3436
// Derived from the "std/jule/importer", stay up to date.
3537
// Reports whether the arg is exist is distarch.
3638
fn checkArch(arg: str): (exist: bool) {
37-
ret arg == build::DistArch.I386 ||
38-
arg == build::DistArch.Amd64 ||
39-
arg == build::DistArch.Arm64 ||
40-
arg == build::DistArch.X64 ||
41-
arg == build::DistArch.X32
39+
ret arg == dist::I386 ||
40+
arg == dist::AMD64 ||
41+
arg == dist::ARM64 ||
42+
arg == dist::X64 ||
43+
arg == dist::X32
4244
}
4345

4446
// Derived from the "std/jule/importer", stay up to date.
@@ -103,7 +105,7 @@ fn isPassFileAnnotation(mut p: str): bool {
103105

104106
fn containsBuildDirective(ast: &ast::AST): bool {
105107
for _, d in ast.TopDirectives {
106-
if d.Tag.Kind == build::Directive.Build {
108+
if d.Tag.Kind == directive::Build {
107109
ret true
108110
}
109111
}
@@ -113,7 +115,7 @@ fn containsBuildDirective(ast: &ast::AST): bool {
113115
fn getAST(path: str, mut data: []byte): (&ast::AST, &builder::CommentMap) {
114116
mut file := token::Fileset.New(path)
115117
unsafe { file.FillMut(data) }
116-
mut errors := token::Lex(file, token::LexMode.Comment)
118+
mut errors := token::Lex(file, token::Comments)
117119
if len(errors) > 0 {
118120
writeError("error: file could not formatted, have error(s): " + path)
119121
ret nil, nil
@@ -158,10 +160,11 @@ fn docFile(path: str) {
158160
writeError("error: no symbol to document: " + path)
159161
ret
160162
}
161-
mut ast, mut cm := getAST(path, os::ReadFile(path) else {
163+
mut ctx := os::ReadFile(path) else {
162164
writeError("error: file could not read: " + path)
163165
ret
164-
})
166+
}
167+
mut ast, mut cm := getAST(path, ctx)
165168
mut doc := builder::New().Build(ast, cm)
166169
bytes := docdoc(doc)
167170
if bytes == nil {
@@ -189,10 +192,11 @@ fn docPackage(path: str) {
189192
continue
190193
}
191194
filepath := filepath::Join(path, dirent.Name)
192-
mut ast, mut cm := getAST(filepath, os::ReadFile(filepath) else {
195+
mut ctx := os::ReadFile(filepath) else {
193196
writeError("error: file could not read: " + filepath)
194197
ret
195-
})
198+
}
199+
mut ast, mut cm := getAST(filepath, ctx)
196200
mut doc := builder.BuildPartial(ast, cm)
197201
if doc != nil {
198202
alldoc = append(alldoc, doc...)

0 commit comments

Comments
 (0)