You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So identifiers, types etc making my head spin quite a bit, and here is the mess I have created so far.
fastn_section::Span
This is our lowest level type, it actually represents any (contiguous) span of text found source. It does not keep track which module did the span come from though.
pubstructSpan{inner: arcstr::Substr,// this is a 32-byte struct.}
This is also type aliased as fastn_unresolved::Identifier.
fastn_unresolved::IdentifierReference
This is the "natural" identifier. This should be used when we are referencing something tho, not when we are defining things.
pubenumIdentifierReference{// fooLocal(Identifier),// bar.foo: module = bar, name: fooImported{module:Module,name:Identifier},// bar#foo: component using the absolute path.Absolute{module:Module,name:Identifier},}
The definition should be "simple" identifier, meaning no ./# in it etc, and I am currently thinking of using fastn_unresolved::Identifier for that.
Maybe we should rename this to fastn_unresolved::PlainIdentifier or fastn_unresolved::SimpleIdentifier.
fastn_unresolved::{Symbol, Module}
These are interned string based types.
pubstructSymbol{// 8 bytes/// this store the <package>/<module>#<name> of the symbolinterned: string_interner::DefaultSymbol,// u32/// length of the <package> part of the symbolpackage_len:u16,/// length of the <module> part of the symbolmodule_len:u16,}pubstructModule{// 6 bytes/// this store the <package>/<module>#<name> of the symbolinterned: string_interner::DefaultSymbol,// u32/// length of the <package> part of the symbolpackage_len:u16,}
fastn_unresolved::{PackageName, ModuleName}
These types were earlier used before we had interned string based stuff.
This is decent to keep around, just the inner values have to be switched to SimpleIdentifiers instead of spans, as both name and alias are not allowed to contain anything special.
fastn_section::{PackageName, ModuleName}
pubstructPackageName{pubname: fastn_section::Span,// for foo.com, the alias is `foo` (the first part before the first dot)// TODO: unless it is `www`, then its the second partpubalias: fastn_section::Span,}pubstructModuleName{pubpackage:PackageName,pubname:AliasableIdentifier,pubpath:Vec<Identifier>,// rest of the path}
I feel these should be deleted in favour of the intern based fastn_unresolved::Module. There is one place where we expect a package name without module name, which is the fastn.package declaration. Similarly in fastn.dependency and fastn.auto-import we expect packages and modules to be aliasable.
Both these types are only used when parsing FASTN.ftd, which we are keeping in fastn-core, so they should be removed from fastn_section/fastn_unresolved.
fastn_section:: QualifiedIdentifier
pubstructQualifiedIdentifier{// the part comes before `#`pubmodule:Option<ModuleName>,// the part comes after `#`pubterms:Vec<Identifier>,}
This too I added pretty early in 0.5 folder, and I am no longer sure we need it. The terms being available as Vec is useless. fastn_unresolved::Symbol is good enough. Terms did allow us to do foo.bar.baz tho, which we do not how to handle, and this type is the only one that has any handling of that.
fastn_section::Kind
It's not really an identifier, but it internally refers to identifier, and currently they are fastn_section::QualifiedIdentifier.
pubstructKind{// only kinded section / header can have docpubdoc:Option<fastn_section::Span>,pubvisibility:Option<fastn_section::Spanned<fastn_section::Visibility>>,pubname: fastn_section::QualifiedIdentifier,// during parsing, we can encounter `foo<>`, which needs to be differentiated from `foo`// therefore we are using `Option<Vec<>>` herepubargs:Option<Vec<Kind>>,}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
So identifiers, types etc making my head spin quite a bit, and here is the mess I have created so far.
fastn_section::Span
This is our lowest level type, it actually represents any (contiguous) span of text found source. It does not keep track which module did the span come from though.
fastn_section::Identifier
This is our main "identifier" type.
This is also type aliased as
fastn_unresolved::Identifier
.fastn_unresolved::IdentifierReference
This is the "natural" identifier. This should be used when we are referencing something tho, not when we are defining things.
The definition should be "simple" identifier, meaning no
.
/#
in it etc, and I am currently thinking of usingfastn_unresolved::Identifier
for that.Maybe we should rename this to
fastn_unresolved::PlainIdentifier
orfastn_unresolved::SimpleIdentifier
.fastn_unresolved::{Symbol, Module}
These are interned string based types.
fastn_unresolved::{PackageName, ModuleName}
These types were earlier used before we had interned string based stuff.
I think they have to be deleted in favour of
fastn_unresolved::{Symbol, Module}
.fastn_unresolved::Kind
fastn_section::AliasableIdentifier
This is decent to keep around, just the inner values have to be switched to
SimpleIdentifiers
instead of spans, as both name and alias are not allowed to contain anything special.fastn_section::{PackageName, ModuleName}
I feel these should be deleted in favour of the intern based
fastn_unresolved::Module
. There is one place where we expect a package name without module name, which is thefastn.package
declaration. Similarly infastn.dependency
andfastn.auto-import
we expect packages and modules to be aliasable.Both these types are only used when parsing
FASTN.ftd
, which we are keeping infastn-core
, so they should be removed fromfastn_section
/fastn_unresolved
.fastn_section:: QualifiedIdentifier
This too I added pretty early in 0.5 folder, and I am no longer sure we need it. The terms being available as Vec is useless.
fastn_unresolved::Symbol
is good enough. Terms did allow us to dofoo.bar.baz
tho, which we do not how to handle, and this type is the only one that has any handling of that.fastn_section::Kind
It's not really an identifier, but it internally refers to identifier, and currently they are
fastn_section::QualifiedIdentifier
.Beta Was this translation helpful? Give feedback.
All reactions