@@ -130,14 +130,14 @@ impl parser {
130130
131131// Checks the mandatory module information.
132132#disable nilptr
133- fn checkMod(modfile: str, mod: &Mod, mut &logs: *[]log::Log) {
133+ fn checkMod(options: ParseOptions, modfile: str, mod: &Mod, mut &logs: *[]log::Log) {
134134 if mod.Name == "" {
135135 *logs = append(*logs, log::Log{
136136 Kind: log::Error,
137137 Text: "module file must be have name",
138138 Path: modfile,
139139 })
140- } else if mod.Name == "std" {
140+ } else if !options.AllowStd && mod.Name == "std" {
141141 *logs = append(*logs, log::Log{
142142 Kind: log::Error,
143143 Text: "module name \"std\" is a reserved name",
@@ -147,8 +147,14 @@ fn checkMod(modfile: str, mod: &Mod, mut &logs: *[]log::Log) {
147147 }
148148}
149149
150+ // Options for the module file parsing.
151+ struct ParseOptions {
152+ // Allows using the reserved "std" module name.
153+ AllowStd: bool
154+ }
155+
150156// Parse module from the module file path.
151- fn ParseFile(path: str): (&Mod, []log::Log) {
157+ fn ParseFile(path: str, options: ParseOptions ): (&Mod, []log::Log) {
152158 modfile := filepath::Join(path, jule::ModuleFile)
153159 mut bytes := os::ReadFile(modfile) else {
154160 ret nil, [{
@@ -170,7 +176,7 @@ fn ParseFile(path: str): (&Mod, []log::Log) {
170176 if len(parser.logs) > 0 {
171177 ret parser.mod, parser.logs
172178 }
173- checkMod(parser.modfile, parser.mod, &parser.logs)
179+ checkMod(options, parser.modfile, parser.mod, &parser.logs)
174180 ret parser.mod, parser.logs
175181}
176182
0 commit comments