Skip to content

Commit

Permalink
jule: update enum syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Apr 9, 2024
1 parent 0196565 commit 92ba496
Show file tree
Hide file tree
Showing 13 changed files with 429 additions and 429 deletions.
22 changes: 11 additions & 11 deletions std/fs/file.jule
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ use sys for std::sys

// Seek whence values.
pub enum Seek: int {
Set = 0, // Seek relative to the origin of the file
Cur = 1, // Seek relative to the current offset
End = 2, // Seek relative to the end
Set: 0, // Seek relative to the origin of the file
Cur: 1, // Seek relative to the current offset
End: 2, // Seek relative to the end
}

// Flags to open wrapping those of the underlying system.
// Not all flags may be implemented on a given system.
// Exactly one of Rdonly, Wronly, or Rdwr must be specified.
pub enum OFlag: int {
Rdonly = sys::O_RDONLY, // Open the file read-only
Wronly = sys::O_WRONLY, // Open the file write-only
Rdwr = sys::O_RDWR, // Open the file read-write
Append = sys::O_APPEND, // Append data to the file when writing
Create = sys::O_CREAT, // Create a new file if none exists
Excl = sys::O_EXCL, // Used with OFlag.Create, file must not exist
Sync = sys::O_SYNC, // Open for synchronous I/O
Trunc = sys::O_TRUNC, // Truncate regular writable file when opened
Rdonly: sys::O_RDONLY, // Open the file read-only
Wronly: sys::O_WRONLY, // Open the file write-only
Rdwr: sys::O_RDWR, // Open the file read-write
Append: sys::O_APPEND, // Append data to the file when writing
Create: sys::O_CREAT, // Create a new file if none exists
Excl: sys::O_EXCL, // Used with OFlag.Create, file must not exist
Sync: sys::O_SYNC, // Open for synchronous I/O
Trunc: sys::O_TRUNC, // Truncate regular writable file when opened
}

// The file stream handle.
Expand Down
18 changes: 9 additions & 9 deletions std/jule/build/directive.jule
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ pub const DIRECTIVE_PREFIX = "jule:"

// Compiler directives.
pub enum Directive: str {
Cdef = "cdef",
Typedef = "typedef",
Derive = "derive",
Pass = "pass",
Build = "build",
Namespace = "namespace",
Deprecated = "deprecated",
Test = "test",
Cdef: "cdef",
Typedef: "typedef",
Derive: "derive",
Pass: "pass",
Build: "build",
Namespace: "namespace",
Deprecated: "deprecated",
Test: "test",
}

// All built-in derive defines.
pub enum Derive: str {
Clone = "Clone",
Clone: "Clone",
}

// Reports whether directive is top-directive.
Expand Down
524 changes: 262 additions & 262 deletions std/jule/build/log.jule

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions std/jule/build/platform.jule
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,33 @@

// List of all possible std::runtime::OS values:
enum RuntimeOs: str {
Windows = "windows",
Darwin = "darwin",
Linux = "linux",
Windows: "windows",
Darwin: "darwin",
Linux: "linux",
}

// List of all possible std::runtime::ARCH values:
enum RuntimeArch: str {
I386 = "i386",
Amd64 = "amd64",
Arm64 = "arm64",
I386: "i386",
Amd64: "amd64",
Arm64: "arm64",
}

// Operating Systems for file annotation kind.
pub enum Os: str {
Windows = "windows",
Linux = "linux",
Darwin = "darwin",
Unix = "unix",
Windows: "windows",
Linux: "linux",
Darwin: "darwin",
Unix: "unix",
}

// Architectures for file annotation kind.
pub enum Arch: str {
I386 = "i386",
Arm64 = "arm64",
Amd64 = "amd64",
X32 = "x32",
X64 = "x64",
I386: "i386",
Arm64: "arm64",
Amd64: "amd64",
X32: "x32",
X64: "x64",
}

// List of supported operating systems.
Expand Down
10 changes: 5 additions & 5 deletions std/jule/importer/var.jule
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ use build for std::jule::build

// Standard back-end compilers.
pub enum Compiler: str {
Clang = "clang",
GCC = "gcc",
Clang: "clang",
GCC: "gcc",
}

// Supported C++ standards.
pub enum CppStd: str {
Cpp14 = "cpp14",
Cpp17 = "cpp17",
Cpp20 = "cpp20",
Cpp14: "cpp14",
Cpp17: "cpp17",
Cpp20: "cpp20",
}

// Compile information.
Expand Down
4 changes: 2 additions & 2 deletions std/jule/lex/lex.jule
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use utf8 for std::unicode::utf8

// Lexer mode.
pub enum LexMode {
Standard = 0 << 0, // Standard mode.
Comment = 1 << 0, // Standard mode + comments.
Standard: 0 << 0, // Standard mode.
Comment: 1 << 0, // Standard mode + comments.
}

struct KindPair {
Expand Down
194 changes: 97 additions & 97 deletions std/jule/lex/token.jule
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ pub static ASSING_OPS: [...]TokenKind = [

// Special identifiers.
pub enum Ident: str {
Ignore = "_", // Ignore
Anon = "<anonymous>", // Anonymous
Ignore: "_", // Ignore
Anon: "<anonymous>", // Anonymous
}

// Token identities.
Expand Down Expand Up @@ -160,101 +160,101 @@ pub enum TokenId: uint {

// Token kinds.
pub enum TokenKind: str {
DblColon = "::",
Colon = ":",
Semicolon = ";",
Comma = ",",
TripleDot = "...",
Dot = ".",
PlusEq = "+=",
MinusEq = "-=",
StarEq = "*=",
SolidusEq = "/=",
PercentEq = "%=",
LshiftEq = "<<=",
RshiftEq = ">>=",
CaretEq = "^=",
AmperEq = "&=",
VlineEq = "|=",
Eqs = "==",
NotEq = "!=",
GreatEq = ">=",
LessEq = "<=",
DblAmper = "&&",
DblVline = "||",
Lshift = "<<",
Rshift = ">>",
DblPlus = "++",
DblMinus = "--",
Plus = "+",
Minus = "-",
Star = "*",
Solidus = "/",
Percent = "%",
Amper = "&",
Vline = "|",
Caret = "^",
Excl = "!",
Lt = "<",
Gt = ">",
Eq = "=",
LnComment = "//",
RangLComment = "/*",
RangRComment = "*/",
LParent = "(",
RParent = ")",
LBracket = "[",
RBracket = "]",
LBrace = "{",
RBrace = "}",
Hash = "#",
I8 = "i8",
I16 = "i16",
I32 = "i32",
I64 = "i64",
U8 = "u8",
U16 = "u16",
U32 = "u32",
U64 = "u64",
F32 = "f32",
F64 = "f64",
Uint = "uint",
Int = "int",
Uintptr = "uintptr",
Bool = "bool",
Str = "str",
Any = "any",
True = "true",
False = "false",
Nil = "nil",
Const = "const",
Ret = "ret",
Type = "type",
For = "for",
Break = "break",
Cont = "continue",
In = "in",
If = "if",
Else = "else",
Use = "use",
Pub = "pub",
Goto = "goto",
Enum = "enum",
Struct = "struct",
Co = "co",
Match = "match",
Self = "self",
Trait = "trait",
Impl = "impl",
Cpp = "cpp",
Fall = "fall",
Fn = "fn",
Let = "let",
Unsafe = "unsafe",
Mut = "mut",
Defer = "defer",
Static = "static",
Error = "error",
DblColon: "::",
Colon: ":",
Semicolon: ";",
Comma: ",",
TripleDot: "...",
Dot: ".",
PlusEq: "+=",
MinusEq: "-=",
StarEq: "*=",
SolidusEq: "/=",
PercentEq: "%=",
LshiftEq: "<<=",
RshiftEq: ">>=",
CaretEq: "^=",
AmperEq: "&=",
VlineEq: "|=",
Eqs: "==",
NotEq: "!=",
GreatEq: ">=",
LessEq: "<=",
DblAmper: "&&",
DblVline: "||",
Lshift: "<<",
Rshift: ">>",
DblPlus: "++",
DblMinus: "--",
Plus: "+",
Minus: "-",
Star: "*",
Solidus: "/",
Percent: "%",
Amper: "&",
Vline: "|",
Caret: "^",
Excl: "!",
Lt: "<",
Gt: ">",
Eq: "=",
LnComment: "//",
RangLComment: "/*",
RangRComment: "*/",
LParent: "(",
RParent: ")",
LBracket: "[",
RBracket: "]",
LBrace: "{",
RBrace: "}",
Hash: "#",
I8: "i8",
I16: "i16",
I32: "i32",
I64: "i64",
U8: "u8",
U16: "u16",
U32: "u32",
U64: "u64",
F32: "f32",
F64: "f64",
Uint: "uint",
Int: "int",
Uintptr: "uintptr",
Bool: "bool",
Str: "str",
Any: "any",
True: "true",
False: "false",
Nil: "nil",
Const: "const",
Ret: "ret",
Type: "type",
For: "for",
Break: "break",
Cont: "continue",
In: "in",
If: "if",
Else: "else",
Use: "use",
Pub: "pub",
Goto: "goto",
Enum: "enum",
Struct: "struct",
Co: "co",
Match: "match",
Self: "self",
Trait: "trait",
Impl: "impl",
Cpp: "cpp",
Fall: "fall",
Fn: "fn",
Let: "let",
Unsafe: "unsafe",
Mut: "mut",
Defer: "defer",
Static: "static",
Error: "error",
}

// Token is lexer token.
Expand Down
2 changes: 1 addition & 1 deletion std/jule/parser/parser.jule
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ impl Parser {
*i++
t = tokens[*i]
*i++
if t.id != TokenId.Op || t.kind != TokenKind.Eq {
if t.id != TokenId.Colon {
self.push_err(t, LogMsg.InvalidSyntax)
self.push_suggestion(LogMsg.ExpectedEqualsForAssign)
continue
Expand Down
4 changes: 2 additions & 2 deletions std/jule/sema/analysis.jule
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use std::jule::build::{Log}

// Flags for semantic analysis.
pub enum SemaFlag {
Default = 0, // Default semantic analysis of Jule.
Shadowing = 1 << 0, // Default + enable shadowing.
Default: 0, // Default semantic analysis of Jule.
Shadowing: 1 << 0, // Default + enable shadowing.
}

// Builds symbol table of AST.
Expand Down
Loading

0 comments on commit 92ba496

Please sign in to comment.