Skip to content

Commit

Permalink
feat(std): map->dict (data-type, to avoid confusion with Map component)
Browse files Browse the repository at this point in the history
  • Loading branch information
emil14 committed Sep 22, 2024
1 parent 536ec23 commit b9eb543
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 39 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"out": true // set this to false to include "out" folder in search results
},
"cSpell.words": [
"ambig",
"axxxbyc",
"cnctr",
"cprogram",
Expand Down
6 changes: 3 additions & 3 deletions e2e/const_refs_verbose/main/main.neva
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
type NumsStruct struct {
l list<int>
m map<int>
d dict<int>
}

const one int = 1
const two int = 2
const three int = 3
const numsList list<int> = [one, two, three]
const numsMap map<int> = { key: one }
const numsMap dict<int> = { key: one }
const numsStruct NumsStruct = {
l: numsList,
m: numsMap
d: numsMap
}

flow Main(start) (stop) {
Expand Down
6 changes: 3 additions & 3 deletions examples/const_refs/main.neva
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
type NumsStruct struct {
l list<int>
m map<int>
d dict<int>
}

const one int = 1
const two int = 2
const three int = 3
const numsList list<int> = [one, two, three]
const numsMap map<int> = { key: one }
const numsMap dict<int> = { key: one }
const numsStruct NumsStruct = {
l: numsList,
m: numsMap
d: numsMap
}

flow Main(start) (stop) {
Expand Down
12 changes: 6 additions & 6 deletions internal/compiler/parser/smoke_test/happypath/005_type.args.neva
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ type MyVec vec<int>

pub type MyVec2 Vec<int>

pub type MyMap map<string, int>
pub type MyMap dict<string, int>

type MyMap map<string, int>
type MyMap dict<string, int>

type MyInt int

type MyMap1<T, Y> map<T, Y>
type MyMap1<T, Y> dict<T, Y>

type MyMap2<T int, Y> map<T, Y>
type MyMap2<T int, Y> dict<T, Y>

type MyMap3<T int, Y vec<float>> map<T, Y>
type MyMap3<T int, Y vec<float>> dict<T, Y>

type MyMap3<T int, Y vec<float>> map<T, vec<Y>>
type MyMap3<T int, Y vec<float>> dict<T, vec<Y>>
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,35 @@ pub type Rec struct {

pub type Rec struct {
foo vec<int>
bar map<string, int>
bar dict<string, int>
}

pub type Rec struct {
foo map<string, int>
foo dict<string, int>
bar vec<enum { Monday, Tuesday, Wednesday, Thursday, Friday }>
}

pub type Rec struct {
foo map<string, int>
foo dict<string, int>
bar vec<enum {
Monday, Tuesday, Wednesday, Thursday, Friday }>
}

pub type Rec struct {
foo map<string, int>
foo dict<string, int>
bar vec<enum { Monday, Tuesday, Wednesday, Thursday, Friday
}>
}

pub type Rec struct {
foo map<string, int>
foo dict<string, int>
bar vec<enum {
Monday, Tuesday, Wednesday, Thursday, Friday
}>
}

pub type Rec struct {
foo map<string, int>
foo dict<string, int>
bar vec<enum {
Monday,
Tuesday,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub type Rec4Lvl1 struct {
rec4Lvl2 struct {
foo vec<struct {
bar vec<struct {
baz map<string, struct { baz bool }>
baz dict<string, struct { baz bool }>
}>
}>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,26 @@ type bar vec<i32
type bar vec<
i32 | vec<i32>
>
type bar vec<i32 | vec<i32>> | map<i32, i32 | f32>
type bar vec<i32 | vec<i32>> | dict<i32, i32 | f32>

type bar vec<
i32 | vec<i32>> | map<i32, i32 | f32
i32 | vec<i32>> | dict<i32, i32 | f32
>

type bar vec<
i32 | vec<i32>
> | map<i32, i32 | f32>
> | dict<i32, i32 | f32>

type bar vec<i32 | vec<i32>> | map<
type bar vec<i32 | vec<i32>> | dict<
i32, i32 | f32
>
type bar vec<i32 | vec<i32 | f32>> | map<i32, i32 | vec<f32>>
type bar vec<i32 | vec<i32 | f32>> | dict<i32, i32 | vec<f32>>

type bar vec<
i32 | vec<i32 | f32>> | map<i32, i32 | vec<f32>
i32 | vec<i32 | f32>> | dict<i32, i32 | vec<f32>
>

pub type bar vec<
i32 |
vec<i32 | f32>
> | map<i32, i32 | vec<f32>>
> | dict<i32, i32 | vec<f32>>
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ flow Doer<T>(x int) (y T) {
simpleAbsNode INode
absNodeWithTypeArgs INode<
int,
map<
dict<
string, vec<bool>
>
>
Expand Down Expand Up @@ -83,7 +83,7 @@ flow Doer<T>(x int) (y T) {
flow Doer<T>(x int) (y T) {
concreteNodeWithDIAndTypeArgs Node1<
int,
map<
dict<
string,
vec<bool>
>
Expand All @@ -99,7 +99,7 @@ flow Doer<T>(x int) (y T) {

absNodeWithTypeArgs INode<
int,
map<
dict<
string, vec<bool>
>
>
Expand All @@ -108,7 +108,7 @@ flow Doer<T>(x int) (y T) {

concreteNodeWithDIAndTypeArgs Node1<
int,
map<
dict<
string,
vec<bool>
>
Expand Down
2 changes: 1 addition & 1 deletion std/builtin/collections.neva
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// for maps it returns number of keys,
// for for strings it returns number of utf-8 characters.
#extern(list list_len, map map_len)
pub flow Len<T list<any> | map<any> | string>(data T) (res int)
pub flow Len<T list<any> | dict<any> | string>(data T) (res int)

// List receives stream and sends list with all elements from the stream.
#extern(stream_to_list)
Expand Down
19 changes: 11 additions & 8 deletions std/builtin/types.neva
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
pub type any
pub type bool
pub type int
pub type float
pub type string
pub type map<T> // TODO rename to dict
pub type list<T>
pub type maybe<T>
pub type any // any possible type
pub type bool // 1-byte for true/false
// pub type byte // 8-bit unsigned integer // TODO?
pub type int // 64-bit signed integer
pub type float // 64-bit floating point
pub type string // UTF-8 encoded string
pub type dict<T> // unordered set of key-value pairs
pub type list<T> // ordered sequence of elements
pub type maybe<T> // optional value

// error type
pub type error struct {
text string
child maybe<error>
}

// stream type
pub type stream<T> struct {
data T
idx int
Expand Down

0 comments on commit b9eb543

Please sign in to comment.