implement: unit identity -- dotted paths, name rules, source path
Units start here, with the part that needs no import graph: what a unit is called and where it must live. The parser only ever read a single identifier after `unit` and `import`, so `unit game.main;` and `import std.io;` were syntax errors -- which is why the dotted fixtures failed at the semicolon. It now reads a dotted path and stores it canonically, dots included, since that spelling is the unit's identity everywhere else. `import a.b as c;` parses too, with the alias on the node. resolve.c is the new pass between parsing and checking, for the questions that span files. It carries SPEC 8.1 so far: each path segment is ASCII lowercase, starts with a letter, continues with letters, digits or underscore, and is at most eight characters; and the dotted path must match the source path it was read from, so game.world.map has to come from game/world/map.fe. The source side is folded to lowercase before comparing, because a case-insensitive host must not let two spellings become two units. That rule then applied to the fixtures, which were not obeying it: 57 declared a unit name unrelated to their file, left over from the milestone directories, and eight had names too long to be legal. Both are now aligned -- the rule is worth having only if the tree follows it. units: badupper, badlong and unitbad pass. 138 -> 146 of 188. The rest of units/ needs the import graph, which is the next piece: resolution, cycles, bindings and visibility.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
unit keywords_and_builtins;
|
||||
unit keybuilt;
|
||||
|
||||
pub fn demo() {
|
||||
let a = true and not false;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
// ERROR:logical operator
|
||||
unit old_logic;
|
||||
unit logical;
|
||||
fn main() { let x = true && false; }
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
// ERROR:expected ';'
|
||||
unit broken;
|
||||
unit misssemi;
|
||||
fn main() { let x: i32 = 1 }
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
// ERROR:unterminated block comment
|
||||
unit broken;
|
||||
unit unclcomm;
|
||||
/* no ending delimiter
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
unit v012_forms;
|
||||
unit v012form;
|
||||
|
||||
shared atomic var ticks: u16 = 0;
|
||||
packed struct Packet {
|
||||
|
||||
Reference in New Issue
Block a user