2022-01-04 10:21:08 +01:00
|
|
|
// Copyright (c) 2019-2022 Alexander Medvednikov. All rights reserved.
|
2020-04-17 18:01:02 +02:00
|
|
|
// Use of this source code is governed by an MIT license
|
|
|
|
// that can be found in the LICENSE file.
|
|
|
|
module parser
|
|
|
|
|
|
|
|
import v.ast
|
|
|
|
import v.token
|
2020-05-06 12:26:00 +02:00
|
|
|
import v.util
|
2020-04-17 18:01:02 +02:00
|
|
|
|
2020-04-22 20:20:49 +02:00
|
|
|
fn (mut p Parser) struct_decl() ast.StructDecl {
|
2020-06-06 17:47:16 +02:00
|
|
|
p.top_level_statement_start()
|
2020-08-04 20:10:22 +02:00
|
|
|
// save attributes, they will be changed later in fields
|
|
|
|
attrs := p.attrs
|
2020-11-17 21:25:54 +01:00
|
|
|
p.attrs = []
|
2022-01-26 11:36:28 +01:00
|
|
|
start_pos := p.tok.pos()
|
2020-04-17 18:01:02 +02:00
|
|
|
is_pub := p.tok.kind == .key_pub
|
|
|
|
if is_pub {
|
|
|
|
p.next()
|
|
|
|
}
|
|
|
|
is_union := p.tok.kind == .key_union
|
|
|
|
if p.tok.kind == .key_struct {
|
2020-05-07 06:51:36 +02:00
|
|
|
p.next()
|
2020-04-17 18:01:02 +02:00
|
|
|
} else {
|
|
|
|
p.check(.key_union)
|
|
|
|
}
|
2020-05-19 17:12:47 +02:00
|
|
|
language := if p.tok.lit == 'C' && p.peek_tok.kind == .dot {
|
2021-04-02 00:57:09 +02:00
|
|
|
ast.Language.c
|
2020-05-19 17:12:47 +02:00
|
|
|
} else if p.tok.lit == 'JS' && p.peek_tok.kind == .dot {
|
2021-04-02 00:57:09 +02:00
|
|
|
ast.Language.js
|
2020-05-19 17:12:47 +02:00
|
|
|
} else {
|
2021-04-02 00:57:09 +02:00
|
|
|
ast.Language.v
|
2020-05-19 17:12:47 +02:00
|
|
|
}
|
|
|
|
if language != .v {
|
2020-04-22 20:20:49 +02:00
|
|
|
p.next() // C || JS
|
|
|
|
p.next() // .
|
2020-04-17 18:01:02 +02:00
|
|
|
}
|
2022-01-26 11:36:28 +01:00
|
|
|
name_pos := p.tok.pos()
|
2020-12-08 17:52:24 +01:00
|
|
|
p.check_for_impure_v(language, name_pos)
|
2020-06-29 20:09:09 +02:00
|
|
|
mut name := p.check_name()
|
2020-08-16 19:16:59 +02:00
|
|
|
// defer {
|
|
|
|
// if name.contains('App') {
|
|
|
|
// println('end of struct decl $name')
|
|
|
|
// }
|
|
|
|
// }
|
2020-06-29 20:09:09 +02:00
|
|
|
if name.len == 1 && name[0].is_capital() {
|
2020-07-01 20:07:33 +02:00
|
|
|
p.error_with_pos('single letter capital names are reserved for generic template types.',
|
2020-07-14 18:52:51 +02:00
|
|
|
name_pos)
|
2020-12-04 19:34:05 +01:00
|
|
|
return ast.StructDecl{}
|
2020-06-29 20:09:09 +02:00
|
|
|
}
|
2022-02-26 08:52:40 +01:00
|
|
|
if name == 'IError' && p.mod != 'builtin' {
|
|
|
|
p.error_with_pos('cannot register struct `IError`, it is builtin interface type',
|
|
|
|
name_pos)
|
|
|
|
}
|
2022-04-05 17:39:49 +02:00
|
|
|
// append module name before any type of parsing to enable recursion parsing
|
|
|
|
p.table.start_parsing_type(p.prepend_mod(name))
|
|
|
|
defer {
|
|
|
|
p.table.reset_parsing_type()
|
|
|
|
}
|
2021-11-09 08:25:57 +01:00
|
|
|
generic_types, _ := p.parse_generic_types()
|
2020-06-29 20:09:09 +02:00
|
|
|
no_body := p.tok.kind != .lcbr
|
2020-05-19 17:12:47 +02:00
|
|
|
if language == .v && no_body {
|
2020-04-17 18:01:02 +02:00
|
|
|
p.error('`$p.tok.lit` lacks body')
|
2020-12-04 19:34:05 +01:00
|
|
|
return ast.StructDecl{}
|
2020-04-17 18:01:02 +02:00
|
|
|
}
|
2022-02-05 23:16:02 +01:00
|
|
|
if language == .v && !p.builtin_mod && !p.is_translated && name.len > 0 && !name[0].is_capital()
|
|
|
|
&& !p.pref.translated && !p.is_translated {
|
2020-07-14 18:52:51 +02:00
|
|
|
p.error_with_pos('struct name `$name` must begin with capital letter', name_pos)
|
2020-12-04 19:34:05 +01:00
|
|
|
return ast.StructDecl{}
|
2020-05-12 13:39:32 +02:00
|
|
|
}
|
2020-05-27 16:00:00 +02:00
|
|
|
if name.len == 1 {
|
2020-07-14 18:52:51 +02:00
|
|
|
p.error_with_pos('struct names must have more than one character', name_pos)
|
2020-12-04 19:34:05 +01:00
|
|
|
return ast.StructDecl{}
|
2020-05-27 16:00:00 +02:00
|
|
|
}
|
2021-06-28 09:26:09 +02:00
|
|
|
if name in p.imported_symbols {
|
|
|
|
p.error_with_pos('cannot register struct `$name`, this type was already imported',
|
|
|
|
name_pos)
|
|
|
|
return ast.StructDecl{}
|
|
|
|
}
|
2021-01-09 01:33:36 +01:00
|
|
|
mut orig_name := name
|
|
|
|
if language == .c {
|
|
|
|
name = 'C.$name'
|
|
|
|
orig_name = name
|
|
|
|
} else if language == .js {
|
|
|
|
name = 'JS.$name'
|
|
|
|
orig_name = name
|
|
|
|
} else {
|
|
|
|
name = p.prepend_mod(name)
|
|
|
|
}
|
2020-04-26 09:17:13 +02:00
|
|
|
mut ast_fields := []ast.StructField{}
|
2021-04-02 00:57:09 +02:00
|
|
|
mut fields := []ast.StructField{}
|
|
|
|
mut embed_types := []ast.Type{}
|
2020-12-23 19:12:49 +01:00
|
|
|
mut embeds := []ast.Embed{}
|
|
|
|
mut embed_field_names := []string{}
|
2020-04-22 20:20:49 +02:00
|
|
|
mut mut_pos := -1
|
|
|
|
mut pub_pos := -1
|
|
|
|
mut pub_mut_pos := -1
|
2020-04-29 13:32:39 +02:00
|
|
|
mut global_pos := -1
|
2021-01-17 05:39:44 +01:00
|
|
|
mut module_pos := -1
|
2020-04-27 22:53:26 +02:00
|
|
|
mut is_field_mut := false
|
|
|
|
mut is_field_pub := false
|
|
|
|
mut is_field_global := false
|
2022-01-26 11:36:28 +01:00
|
|
|
mut last_line := p.prev_tok.pos().line_nr + 1
|
2020-06-23 18:01:56 +02:00
|
|
|
mut end_comments := []ast.Comment{}
|
2020-04-17 18:01:02 +02:00
|
|
|
if !no_body {
|
|
|
|
p.check(.lcbr)
|
|
|
|
for p.tok.kind != .rcbr {
|
2020-06-23 18:01:56 +02:00
|
|
|
mut comments := []ast.Comment{}
|
|
|
|
for p.tok.kind == .comment {
|
|
|
|
comments << p.comment()
|
2020-06-24 16:35:18 +02:00
|
|
|
if p.tok.kind == .rcbr {
|
|
|
|
break
|
|
|
|
}
|
2020-06-23 18:01:56 +02:00
|
|
|
}
|
|
|
|
if p.tok.kind == .rcbr {
|
2020-12-20 10:42:46 +01:00
|
|
|
end_comments = comments.clone()
|
2020-06-24 16:35:18 +02:00
|
|
|
break
|
2020-04-17 18:01:02 +02:00
|
|
|
}
|
|
|
|
if p.tok.kind == .key_pub {
|
2020-05-07 06:51:36 +02:00
|
|
|
p.next()
|
2020-04-17 18:01:02 +02:00
|
|
|
if p.tok.kind == .key_mut {
|
2020-04-29 13:32:39 +02:00
|
|
|
if pub_mut_pos != -1 {
|
|
|
|
p.error('redefinition of `pub mut` section')
|
2020-12-04 19:34:05 +01:00
|
|
|
return ast.StructDecl{}
|
2020-04-29 13:32:39 +02:00
|
|
|
}
|
2020-05-07 06:51:36 +02:00
|
|
|
p.next()
|
2021-02-16 12:39:50 +01:00
|
|
|
pub_mut_pos = ast_fields.len
|
2020-04-27 22:53:26 +02:00
|
|
|
is_field_pub = true
|
|
|
|
is_field_mut = true
|
|
|
|
is_field_global = false
|
2020-04-17 18:01:02 +02:00
|
|
|
} else {
|
2020-04-29 13:32:39 +02:00
|
|
|
if pub_pos != -1 {
|
|
|
|
p.error('redefinition of `pub` section')
|
2020-12-04 19:34:05 +01:00
|
|
|
return ast.StructDecl{}
|
2020-04-29 13:32:39 +02:00
|
|
|
}
|
2021-02-16 12:39:50 +01:00
|
|
|
pub_pos = ast_fields.len
|
2020-04-27 22:53:26 +02:00
|
|
|
is_field_pub = true
|
|
|
|
is_field_mut = false
|
|
|
|
is_field_global = false
|
2020-04-17 18:01:02 +02:00
|
|
|
}
|
|
|
|
p.check(.colon)
|
|
|
|
} else if p.tok.kind == .key_mut {
|
2020-04-29 13:32:39 +02:00
|
|
|
if mut_pos != -1 {
|
|
|
|
p.error('redefinition of `mut` section')
|
2020-12-04 19:34:05 +01:00
|
|
|
return ast.StructDecl{}
|
2020-04-29 13:32:39 +02:00
|
|
|
}
|
2020-05-07 06:51:36 +02:00
|
|
|
p.next()
|
2020-04-17 18:01:02 +02:00
|
|
|
p.check(.colon)
|
2021-02-16 12:39:50 +01:00
|
|
|
mut_pos = ast_fields.len
|
2020-04-27 22:53:26 +02:00
|
|
|
is_field_pub = false
|
|
|
|
is_field_mut = true
|
|
|
|
is_field_global = false
|
2020-04-17 18:01:02 +02:00
|
|
|
} else if p.tok.kind == .key_global {
|
2020-04-29 13:32:39 +02:00
|
|
|
if global_pos != -1 {
|
|
|
|
p.error('redefinition of `global` section')
|
2020-12-04 19:34:05 +01:00
|
|
|
return ast.StructDecl{}
|
2020-04-29 13:32:39 +02:00
|
|
|
}
|
2020-05-07 06:51:36 +02:00
|
|
|
p.next()
|
2020-04-17 18:01:02 +02:00
|
|
|
p.check(.colon)
|
2021-02-16 12:39:50 +01:00
|
|
|
global_pos = ast_fields.len
|
2020-04-27 22:53:26 +02:00
|
|
|
is_field_pub = true
|
|
|
|
is_field_mut = true
|
|
|
|
is_field_global = true
|
2021-01-17 05:39:44 +01:00
|
|
|
} else if p.tok.kind == .key_module {
|
|
|
|
if module_pos != -1 {
|
|
|
|
p.error('redefinition of `module` section')
|
2021-07-20 10:17:08 +02:00
|
|
|
return ast.StructDecl{}
|
2021-01-17 05:39:44 +01:00
|
|
|
}
|
|
|
|
p.next()
|
|
|
|
p.check(.colon)
|
2021-02-16 12:39:50 +01:00
|
|
|
module_pos = ast_fields.len
|
2021-01-17 05:39:44 +01:00
|
|
|
is_field_pub = false
|
|
|
|
is_field_mut = false
|
|
|
|
is_field_global = false
|
2020-04-17 18:01:02 +02:00
|
|
|
}
|
2020-06-23 18:01:56 +02:00
|
|
|
for p.tok.kind == .comment {
|
|
|
|
comments << p.comment()
|
2020-06-24 16:35:18 +02:00
|
|
|
if p.tok.kind == .rcbr {
|
|
|
|
break
|
|
|
|
}
|
2020-06-23 18:01:56 +02:00
|
|
|
}
|
2022-01-26 11:36:28 +01:00
|
|
|
field_start_pos := p.tok.pos()
|
2021-11-04 08:31:40 +01:00
|
|
|
mut is_field_volatile := false
|
|
|
|
if p.tok.kind == .key_volatile {
|
|
|
|
p.next()
|
|
|
|
is_field_volatile = true
|
|
|
|
}
|
2022-04-10 09:24:36 +02:00
|
|
|
is_embed := ((p.tok.lit.len > 1 && p.tok.lit[0].is_capital()
|
2022-04-29 13:57:14 +02:00
|
|
|
&& (p.peek_tok.line_nr != p.tok.line_nr || p.peek_tok.kind !in [.name, .amp])
|
2022-04-10 09:24:36 +02:00
|
|
|
&& (p.peek_tok.kind != .lsbr || p.peek_token(2).kind != .rsbr))
|
2021-02-12 09:12:22 +01:00
|
|
|
|| p.peek_tok.kind == .dot) && language == .v && p.peek_tok.kind != .key_fn
|
2021-04-19 14:38:48 +02:00
|
|
|
is_on_top := ast_fields.len == 0 && !(is_field_mut || is_field_global)
|
2020-10-30 07:09:26 +01:00
|
|
|
mut field_name := ''
|
2021-04-02 00:57:09 +02:00
|
|
|
mut typ := ast.Type(0)
|
2022-01-26 11:36:28 +01:00
|
|
|
mut type_pos := token.Pos{}
|
|
|
|
mut field_pos := token.Pos{}
|
2020-10-30 07:09:26 +01:00
|
|
|
if is_embed {
|
|
|
|
// struct embedding
|
2022-01-26 11:36:28 +01:00
|
|
|
type_pos = p.tok.pos()
|
2020-10-30 07:09:26 +01:00
|
|
|
typ = p.parse_type()
|
2021-09-04 10:02:04 +02:00
|
|
|
comments << p.eat_comments()
|
2022-01-26 11:36:28 +01:00
|
|
|
type_pos = type_pos.extend(p.prev_tok.pos())
|
2021-01-06 15:46:36 +01:00
|
|
|
if !is_on_top {
|
|
|
|
p.error_with_pos('struct embedding must be declared at the beginning of the struct body',
|
|
|
|
type_pos)
|
|
|
|
return ast.StructDecl{}
|
|
|
|
}
|
2021-12-19 17:25:18 +01:00
|
|
|
sym := p.table.sym(typ)
|
2020-12-23 19:12:49 +01:00
|
|
|
if typ in embed_types {
|
|
|
|
p.error_with_pos('cannot embed `$sym.name` more than once', type_pos)
|
2020-12-04 19:34:05 +01:00
|
|
|
return ast.StructDecl{}
|
2020-10-30 07:09:26 +01:00
|
|
|
}
|
2020-12-23 19:12:49 +01:00
|
|
|
field_name = sym.embed_name()
|
|
|
|
if field_name in embed_field_names {
|
|
|
|
p.error_with_pos('duplicate field `$field_name`', type_pos)
|
|
|
|
return ast.StructDecl{}
|
|
|
|
}
|
|
|
|
embed_field_names << field_name
|
|
|
|
embed_types << typ
|
|
|
|
embeds << ast.Embed{
|
|
|
|
typ: typ
|
|
|
|
pos: type_pos
|
2021-09-04 10:02:04 +02:00
|
|
|
comments: comments
|
2020-12-23 19:12:49 +01:00
|
|
|
}
|
2020-10-30 07:09:26 +01:00
|
|
|
} else {
|
|
|
|
// struct field
|
|
|
|
field_name = p.check_name()
|
|
|
|
for p.tok.kind == .comment {
|
|
|
|
comments << p.comment()
|
|
|
|
if p.tok.kind == .rcbr {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
2022-03-28 17:13:38 +02:00
|
|
|
p.inside_struct_field_decl = true
|
2020-10-30 07:09:26 +01:00
|
|
|
typ = p.parse_type()
|
2022-03-28 17:13:38 +02:00
|
|
|
p.inside_struct_field_decl = false
|
2020-12-11 06:55:39 +01:00
|
|
|
if typ.idx() == 0 {
|
|
|
|
// error is set in parse_type
|
|
|
|
return ast.StructDecl{}
|
|
|
|
}
|
2022-01-26 11:36:28 +01:00
|
|
|
type_pos = p.prev_tok.pos()
|
2020-10-30 07:09:26 +01:00
|
|
|
field_pos = field_start_pos.extend(type_pos)
|
2020-06-23 18:01:56 +02:00
|
|
|
}
|
|
|
|
// Comments after type (same line)
|
2021-07-20 10:17:08 +02:00
|
|
|
comments << p.eat_comments()
|
2020-05-29 11:44:49 +02:00
|
|
|
if p.tok.kind == .lsbr {
|
2020-08-04 20:10:22 +02:00
|
|
|
// attrs are stored in `p.attrs`
|
|
|
|
p.attributes()
|
2020-05-29 11:44:49 +02:00
|
|
|
}
|
2021-03-31 10:13:15 +02:00
|
|
|
mut default_expr := ast.empty_expr()
|
2020-04-22 20:20:49 +02:00
|
|
|
mut has_default_expr := false
|
2020-10-30 07:09:26 +01:00
|
|
|
if !is_embed {
|
|
|
|
if p.tok.kind == .assign {
|
|
|
|
// Default value
|
|
|
|
p.next()
|
|
|
|
default_expr = p.expr(0)
|
2020-11-25 12:09:40 +01:00
|
|
|
match mut default_expr {
|
2020-10-30 07:09:26 +01:00
|
|
|
ast.EnumVal { default_expr.typ = typ }
|
|
|
|
// TODO: implement all types??
|
|
|
|
else {}
|
|
|
|
}
|
|
|
|
has_default_expr = true
|
2021-07-20 10:17:08 +02:00
|
|
|
comments << p.eat_comments()
|
2020-04-17 18:01:02 +02:00
|
|
|
}
|
2020-12-23 19:12:49 +01:00
|
|
|
ast_fields << ast.StructField{
|
|
|
|
name: field_name
|
2021-04-02 00:57:09 +02:00
|
|
|
typ: typ
|
2020-12-23 19:12:49 +01:00
|
|
|
pos: field_pos
|
|
|
|
type_pos: type_pos
|
|
|
|
comments: comments
|
|
|
|
default_expr: default_expr
|
|
|
|
has_default_expr: has_default_expr
|
|
|
|
attrs: p.attrs
|
2021-04-02 00:57:09 +02:00
|
|
|
is_pub: is_embed || is_field_pub
|
|
|
|
is_mut: is_embed || is_field_mut
|
|
|
|
is_global: is_field_global
|
2021-11-04 08:31:40 +01:00
|
|
|
is_volatile: is_field_volatile
|
2020-12-23 19:12:49 +01:00
|
|
|
}
|
2020-04-17 18:01:02 +02:00
|
|
|
}
|
2020-12-23 19:12:49 +01:00
|
|
|
// save embeds as table fields too, it will be used in generation phase
|
2021-04-02 00:57:09 +02:00
|
|
|
fields << ast.StructField{
|
2020-04-17 18:01:02 +02:00
|
|
|
name: field_name
|
|
|
|
typ: typ
|
2021-04-02 00:57:09 +02:00
|
|
|
pos: field_pos
|
|
|
|
type_pos: type_pos
|
|
|
|
comments: comments
|
|
|
|
default_expr: default_expr
|
2020-04-17 18:01:02 +02:00
|
|
|
has_default_expr: has_default_expr
|
2020-08-04 20:10:22 +02:00
|
|
|
attrs: p.attrs
|
2021-04-02 00:57:09 +02:00
|
|
|
is_pub: is_embed || is_field_pub
|
|
|
|
is_mut: is_embed || is_field_mut
|
|
|
|
is_global: is_field_global
|
2021-11-04 08:31:40 +01:00
|
|
|
is_volatile: is_field_volatile
|
2020-04-17 18:01:02 +02:00
|
|
|
}
|
2020-08-04 20:10:22 +02:00
|
|
|
p.attrs = []
|
2020-04-17 18:01:02 +02:00
|
|
|
}
|
2020-06-06 17:47:16 +02:00
|
|
|
p.top_level_statement_end()
|
2020-12-22 14:45:12 +01:00
|
|
|
last_line = p.tok.line_nr
|
2020-04-17 18:01:02 +02:00
|
|
|
p.check(.rcbr)
|
|
|
|
}
|
2021-04-02 00:57:09 +02:00
|
|
|
t := ast.TypeSymbol{
|
2020-04-17 18:01:02 +02:00
|
|
|
kind: .struct_
|
2020-11-03 08:35:35 +01:00
|
|
|
language: language
|
2020-12-06 04:55:08 +01:00
|
|
|
name: name
|
2020-11-29 14:10:45 +01:00
|
|
|
cname: util.no_dots(name)
|
2020-10-08 07:02:04 +02:00
|
|
|
mod: p.mod
|
2021-04-02 00:57:09 +02:00
|
|
|
info: ast.Struct{
|
2020-12-23 19:12:49 +01:00
|
|
|
embeds: embed_types
|
2020-04-17 18:01:02 +02:00
|
|
|
fields: fields
|
2020-08-04 20:10:22 +02:00
|
|
|
is_typedef: attrs.contains('typedef')
|
2020-04-17 18:01:02 +02:00
|
|
|
is_union: is_union
|
2021-02-13 15:52:01 +01:00
|
|
|
is_heap: attrs.contains('heap')
|
2021-04-23 14:17:57 +02:00
|
|
|
is_generic: generic_types.len > 0
|
2020-06-29 20:09:09 +02:00
|
|
|
generic_types: generic_types
|
2021-01-08 04:49:13 +01:00
|
|
|
attrs: attrs
|
2020-04-17 18:01:02 +02:00
|
|
|
}
|
2022-03-10 21:18:57 +01:00
|
|
|
is_pub: is_pub
|
2020-04-17 18:01:02 +02:00
|
|
|
}
|
2021-01-09 01:33:36 +01:00
|
|
|
if p.table.has_deep_child_no_ref(&t, name) {
|
|
|
|
p.error_with_pos('invalid recursive struct `$orig_name`', name_pos)
|
|
|
|
return ast.StructDecl{}
|
|
|
|
}
|
2020-04-22 20:20:49 +02:00
|
|
|
mut ret := 0
|
2020-12-11 07:39:51 +01:00
|
|
|
// println('reg type symbol $name mod=$p.mod')
|
2022-01-19 19:16:23 +01:00
|
|
|
ret = p.table.register_sym(t)
|
2020-12-11 07:39:51 +01:00
|
|
|
// allow duplicate c struct declarations
|
|
|
|
if ret == -1 && language != .c {
|
2020-07-14 18:52:51 +02:00
|
|
|
p.error_with_pos('cannot register struct `$name`, another type with this name exists',
|
|
|
|
name_pos)
|
2020-12-04 19:34:05 +01:00
|
|
|
return ast.StructDecl{}
|
2020-04-17 18:01:02 +02:00
|
|
|
}
|
|
|
|
p.expr_mod = ''
|
|
|
|
return ast.StructDecl{
|
|
|
|
name: name
|
|
|
|
is_pub: is_pub
|
|
|
|
fields: ast_fields
|
2020-12-22 14:45:12 +01:00
|
|
|
pos: start_pos.extend_with_last_line(name_pos, last_line)
|
2021-02-16 12:39:50 +01:00
|
|
|
mut_pos: mut_pos
|
|
|
|
pub_pos: pub_pos
|
|
|
|
pub_mut_pos: pub_mut_pos
|
|
|
|
global_pos: global_pos
|
|
|
|
module_pos: module_pos
|
2020-05-19 17:12:47 +02:00
|
|
|
language: language
|
2020-04-17 18:01:02 +02:00
|
|
|
is_union: is_union
|
2020-08-04 20:10:22 +02:00
|
|
|
attrs: attrs
|
2020-06-23 18:01:56 +02:00
|
|
|
end_comments: end_comments
|
2021-04-22 17:21:01 +02:00
|
|
|
generic_types: generic_types
|
2020-12-23 19:12:49 +01:00
|
|
|
embeds: embeds
|
2020-04-17 18:01:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-13 21:25:25 +01:00
|
|
|
fn (mut p Parser) struct_init(typ_str string, short_syntax bool) ast.StructInit {
|
2022-01-26 11:36:28 +01:00
|
|
|
first_pos := (if short_syntax && p.prev_tok.kind == .lcbr { p.prev_tok } else { p.tok }).pos()
|
2022-02-04 13:24:38 +01:00
|
|
|
p.struct_init_generic_types = []ast.Type{}
|
2021-04-02 00:57:09 +02:00
|
|
|
typ := if short_syntax { ast.void_type } else { p.parse_type() }
|
2020-04-17 18:01:02 +02:00
|
|
|
p.expr_mod = ''
|
|
|
|
if !short_syntax {
|
|
|
|
p.check(.lcbr)
|
|
|
|
}
|
2021-07-20 10:17:08 +02:00
|
|
|
pre_comments := p.eat_comments()
|
2020-04-26 09:17:13 +02:00
|
|
|
mut fields := []ast.StructInitField{}
|
2020-04-22 20:20:49 +02:00
|
|
|
mut i := 0
|
2021-01-04 19:19:03 +01:00
|
|
|
no_keys := p.peek_tok.kind != .colon && p.tok.kind != .rcbr && p.tok.kind != .ellipsis // `Vec{a,b,c}
|
2020-05-30 15:42:12 +02:00
|
|
|
saved_is_amp := p.is_amp
|
|
|
|
p.is_amp = false
|
2021-03-31 10:13:15 +02:00
|
|
|
mut update_expr := ast.empty_expr()
|
2021-01-04 20:01:35 +01:00
|
|
|
mut update_expr_comments := []ast.Comment{}
|
2021-01-04 19:19:03 +01:00
|
|
|
mut has_update_expr := false
|
2020-12-10 18:32:15 +01:00
|
|
|
for p.tok.kind !in [.rcbr, .rpar, .eof] {
|
2020-04-22 20:20:49 +02:00
|
|
|
mut field_name := ''
|
2021-03-31 10:13:15 +02:00
|
|
|
mut expr := ast.empty_expr()
|
2022-01-26 11:36:28 +01:00
|
|
|
mut field_pos := token.Pos{}
|
|
|
|
mut first_field_pos := token.Pos{}
|
2020-10-15 22:12:59 +02:00
|
|
|
mut comments := []ast.Comment{}
|
2020-12-09 10:11:22 +01:00
|
|
|
mut nline_comments := []ast.Comment{}
|
2021-01-04 19:19:03 +01:00
|
|
|
is_update_expr := fields.len == 0 && p.tok.kind == .ellipsis
|
2020-05-05 02:12:40 +02:00
|
|
|
if no_keys {
|
2020-04-22 20:20:49 +02:00
|
|
|
// name will be set later in checker
|
2020-10-15 22:12:59 +02:00
|
|
|
expr = p.expr(0)
|
2022-01-26 11:36:28 +01:00
|
|
|
field_pos = expr.pos()
|
2021-03-30 09:43:17 +02:00
|
|
|
first_field_pos = field_pos
|
2021-02-08 17:16:02 +01:00
|
|
|
comments = p.eat_comments(same_line: true)
|
2021-01-04 19:19:03 +01:00
|
|
|
} else if is_update_expr {
|
|
|
|
// struct updating syntax; f2 := Foo{ ...f, name: 'f2' }
|
|
|
|
p.check(.ellipsis)
|
|
|
|
update_expr = p.expr(0)
|
2021-02-08 17:16:02 +01:00
|
|
|
update_expr_comments << p.eat_comments(same_line: true)
|
2021-01-04 19:19:03 +01:00
|
|
|
has_update_expr = true
|
2020-04-17 18:01:02 +02:00
|
|
|
} else {
|
2022-01-26 11:36:28 +01:00
|
|
|
first_field_pos = p.tok.pos()
|
2020-04-17 18:01:02 +02:00
|
|
|
field_name = p.check_name()
|
|
|
|
p.check(.colon)
|
2020-10-15 22:12:59 +02:00
|
|
|
expr = p.expr(0)
|
2021-02-08 17:16:02 +01:00
|
|
|
comments = p.eat_comments(same_line: true)
|
2022-01-26 11:36:28 +01:00
|
|
|
last_field_pos := expr.pos()
|
2021-01-23 09:33:22 +01:00
|
|
|
field_len := if last_field_pos.len > 0 {
|
|
|
|
last_field_pos.pos - first_field_pos.pos + last_field_pos.len
|
|
|
|
} else {
|
|
|
|
first_field_pos.len + 1
|
|
|
|
}
|
2022-01-26 11:36:28 +01:00
|
|
|
field_pos = token.Pos{
|
2020-04-17 18:01:02 +02:00
|
|
|
line_nr: first_field_pos.line_nr
|
|
|
|
pos: first_field_pos.pos
|
2020-12-28 11:39:02 +01:00
|
|
|
len: field_len
|
2021-03-23 06:23:46 +01:00
|
|
|
col: first_field_pos.col
|
2020-04-17 18:01:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
i++
|
|
|
|
if p.tok.kind == .comma {
|
2020-05-07 06:51:36 +02:00
|
|
|
p.next()
|
2020-04-17 18:01:02 +02:00
|
|
|
}
|
2021-02-08 17:16:02 +01:00
|
|
|
comments << p.eat_comments(same_line: true)
|
2021-07-20 10:17:08 +02:00
|
|
|
nline_comments << p.eat_comments()
|
2021-01-04 19:19:03 +01:00
|
|
|
if !is_update_expr {
|
|
|
|
fields << ast.StructInitField{
|
|
|
|
name: field_name
|
|
|
|
expr: expr
|
|
|
|
pos: field_pos
|
2021-03-30 09:43:17 +02:00
|
|
|
name_pos: first_field_pos
|
2021-01-04 19:19:03 +01:00
|
|
|
comments: comments
|
|
|
|
next_comments: nline_comments
|
2021-04-02 16:26:37 +02:00
|
|
|
parent_type: typ
|
2021-01-04 19:19:03 +01:00
|
|
|
}
|
2020-10-15 22:12:59 +02:00
|
|
|
}
|
2020-04-17 18:01:02 +02:00
|
|
|
}
|
|
|
|
if !short_syntax {
|
|
|
|
p.check(.rcbr)
|
|
|
|
}
|
2020-05-30 15:42:12 +02:00
|
|
|
p.is_amp = saved_is_amp
|
2021-02-02 14:42:00 +01:00
|
|
|
return ast.StructInit{
|
|
|
|
unresolved: typ.has_flag(.generic)
|
2022-01-13 21:25:25 +01:00
|
|
|
typ_str: typ_str
|
2020-04-17 18:01:02 +02:00
|
|
|
typ: typ
|
|
|
|
fields: fields
|
2021-01-04 19:19:03 +01:00
|
|
|
update_expr: update_expr
|
2021-01-04 20:01:35 +01:00
|
|
|
update_expr_comments: update_expr_comments
|
2021-01-04 19:19:03 +01:00
|
|
|
has_update_expr: has_update_expr
|
2021-03-30 09:43:17 +02:00
|
|
|
name_pos: first_pos
|
2022-01-26 11:36:28 +01:00
|
|
|
pos: first_pos.extend(if short_syntax { p.tok.pos() } else { p.prev_tok.pos() })
|
2020-05-05 02:12:40 +02:00
|
|
|
is_short: no_keys
|
2022-02-09 13:06:45 +01:00
|
|
|
is_short_syntax: short_syntax
|
2020-11-05 17:49:52 +01:00
|
|
|
pre_comments: pre_comments
|
2022-02-04 13:24:38 +01:00
|
|
|
generic_types: p.struct_init_generic_types
|
2020-04-17 18:01:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-22 20:20:49 +02:00
|
|
|
fn (mut p Parser) interface_decl() ast.InterfaceDecl {
|
2020-06-06 17:47:16 +02:00
|
|
|
p.top_level_statement_start()
|
2022-01-26 11:36:28 +01:00
|
|
|
mut pos := p.tok.pos()
|
2021-11-17 10:41:33 +01:00
|
|
|
attrs := p.attrs
|
2020-04-17 18:01:02 +02:00
|
|
|
is_pub := p.tok.kind == .key_pub
|
|
|
|
if is_pub {
|
|
|
|
p.next()
|
|
|
|
}
|
2020-04-22 20:20:49 +02:00
|
|
|
p.next() // `interface`
|
2021-04-26 08:58:05 +02:00
|
|
|
language := if p.tok.lit == 'C' && p.peek_tok.kind == .dot {
|
|
|
|
ast.Language.c
|
|
|
|
} else if p.tok.lit == 'JS' && p.peek_tok.kind == .dot {
|
|
|
|
ast.Language.js
|
|
|
|
} else {
|
|
|
|
ast.Language.v
|
|
|
|
}
|
|
|
|
if language != .v {
|
|
|
|
p.next() // C || JS
|
|
|
|
p.next() // .
|
|
|
|
}
|
2022-01-26 11:36:28 +01:00
|
|
|
name_pos := p.tok.pos()
|
2021-04-26 08:58:05 +02:00
|
|
|
p.check_for_impure_v(language, name_pos)
|
2021-06-28 09:26:09 +02:00
|
|
|
modless_name := p.check_name()
|
2022-02-26 08:52:40 +01:00
|
|
|
if modless_name == 'IError' && p.mod != 'builtin' {
|
|
|
|
p.error_with_pos('cannot register interface `IError`, it is builtin interface type',
|
|
|
|
name_pos)
|
|
|
|
}
|
2021-11-11 13:36:32 +01:00
|
|
|
mut interface_name := ''
|
|
|
|
if language == .js {
|
|
|
|
interface_name = 'JS.' + modless_name
|
|
|
|
} else {
|
|
|
|
interface_name = p.prepend_mod(modless_name)
|
|
|
|
}
|
2021-11-09 08:25:57 +01:00
|
|
|
generic_types, _ := p.parse_generic_types()
|
2020-04-25 08:00:28 +02:00
|
|
|
// println('interface decl $interface_name')
|
2020-04-17 18:01:02 +02:00
|
|
|
p.check(.lcbr)
|
2021-07-20 10:17:08 +02:00
|
|
|
pre_comments := p.eat_comments()
|
2021-06-28 09:26:09 +02:00
|
|
|
if modless_name in p.imported_symbols {
|
|
|
|
p.error_with_pos('cannot register interface `$interface_name`, this type was already imported',
|
|
|
|
name_pos)
|
|
|
|
return ast.InterfaceDecl{}
|
|
|
|
}
|
2020-04-22 20:20:49 +02:00
|
|
|
// Declare the type
|
2022-01-19 19:16:23 +01:00
|
|
|
reg_idx := p.table.register_sym(
|
2022-03-10 21:18:57 +01:00
|
|
|
is_pub: is_pub
|
2020-04-22 20:20:49 +02:00
|
|
|
kind: .interface_
|
|
|
|
name: interface_name
|
2020-11-29 14:10:45 +01:00
|
|
|
cname: util.no_dots(interface_name)
|
2020-05-11 08:59:55 +02:00
|
|
|
mod: p.mod
|
2021-04-02 00:57:09 +02:00
|
|
|
info: ast.Interface{
|
2020-05-04 00:14:59 +02:00
|
|
|
types: []
|
2021-07-15 07:29:13 +02:00
|
|
|
is_generic: generic_types.len > 0
|
|
|
|
generic_types: generic_types
|
2020-04-22 20:20:49 +02:00
|
|
|
}
|
2021-11-11 13:36:32 +01:00
|
|
|
language: language
|
2020-12-04 10:22:26 +01:00
|
|
|
)
|
2020-07-14 18:52:51 +02:00
|
|
|
if reg_idx == -1 {
|
|
|
|
p.error_with_pos('cannot register interface `$interface_name`, another type with this name exists',
|
|
|
|
name_pos)
|
2020-12-04 19:34:05 +01:00
|
|
|
return ast.InterfaceDecl{}
|
2020-04-22 20:20:49 +02:00
|
|
|
}
|
2021-04-02 00:57:09 +02:00
|
|
|
typ := ast.new_type(reg_idx)
|
2021-12-19 17:25:18 +01:00
|
|
|
mut ts := p.table.sym(typ)
|
2021-04-02 00:57:09 +02:00
|
|
|
mut info := ts.info as ast.Interface
|
2020-07-15 10:23:21 +02:00
|
|
|
// if methods were declared before, it's an error, ignore them
|
2021-04-02 00:57:09 +02:00
|
|
|
ts.methods = []ast.Fn{cap: 20}
|
2021-01-23 07:57:17 +01:00
|
|
|
// Parse fields or methods
|
|
|
|
mut fields := []ast.StructField{cap: 20}
|
2020-11-05 18:55:20 +01:00
|
|
|
mut methods := []ast.FnDecl{cap: 20}
|
2021-01-22 09:02:28 +01:00
|
|
|
mut is_mut := false
|
2021-03-04 14:30:30 +01:00
|
|
|
mut mut_pos := -1
|
2021-05-02 02:00:47 +02:00
|
|
|
mut ifaces := []ast.InterfaceEmbedding{}
|
2020-04-17 18:01:02 +02:00
|
|
|
for p.tok.kind != .rcbr && p.tok.kind != .eof {
|
2022-04-29 14:48:03 +02:00
|
|
|
if p.tok.kind == .name && p.tok.lit.len > 0 && p.tok.lit[0].is_capital()
|
2022-04-30 04:29:33 +02:00
|
|
|
&& (p.peek_tok.line_nr != p.tok.line_nr
|
|
|
|
|| p.peek_tok.kind !in [.name, .amp, .lsbr, .lpar]) {
|
2022-01-26 11:36:28 +01:00
|
|
|
iface_pos := p.tok.pos()
|
2021-11-11 13:36:32 +01:00
|
|
|
mut iface_name := p.tok.lit
|
2021-05-02 02:00:47 +02:00
|
|
|
iface_type := p.parse_type()
|
2021-11-11 13:36:32 +01:00
|
|
|
if iface_name == 'JS' {
|
2021-12-19 17:25:18 +01:00
|
|
|
iface_name = p.table.sym(iface_type).name
|
2021-11-11 13:36:32 +01:00
|
|
|
}
|
2021-07-20 10:17:08 +02:00
|
|
|
comments := p.eat_comments()
|
2021-05-02 02:00:47 +02:00
|
|
|
ifaces << ast.InterfaceEmbedding{
|
|
|
|
name: iface_name
|
|
|
|
typ: iface_type
|
|
|
|
pos: iface_pos
|
|
|
|
comments: comments
|
|
|
|
}
|
|
|
|
if p.tok.kind == .rcbr {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
continue
|
|
|
|
}
|
2022-02-06 23:20:34 +01:00
|
|
|
|
|
|
|
// Check embedded interface from external module
|
|
|
|
if p.tok.kind == .name && p.peek_tok.kind == .dot {
|
|
|
|
if p.tok.lit !in p.imports {
|
|
|
|
p.error_with_pos('mod `$p.tok.lit` not imported', p.tok.pos())
|
|
|
|
break
|
|
|
|
}
|
|
|
|
mod_name := p.tok.lit
|
|
|
|
from_mod_typ := p.parse_type()
|
|
|
|
from_mod_name := '${mod_name}.$p.prev_tok.lit'
|
|
|
|
if from_mod_name.is_lower() {
|
|
|
|
p.error_with_pos('The interface name need to have the pascal case', p.prev_tok.pos())
|
|
|
|
break
|
|
|
|
}
|
|
|
|
comments := p.eat_comments()
|
|
|
|
ifaces << ast.InterfaceEmbedding{
|
|
|
|
name: from_mod_name
|
|
|
|
typ: from_mod_typ
|
|
|
|
pos: p.prev_tok.pos()
|
|
|
|
comments: comments
|
|
|
|
}
|
|
|
|
if p.tok.kind == .rcbr {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-24 22:11:17 +01:00
|
|
|
if p.tok.kind == .key_mut {
|
|
|
|
if is_mut {
|
2022-01-26 11:36:28 +01:00
|
|
|
p.error_with_pos('redefinition of `mut` section', p.tok.pos())
|
2021-07-20 10:17:08 +02:00
|
|
|
return ast.InterfaceDecl{}
|
2021-01-24 22:11:17 +01:00
|
|
|
}
|
|
|
|
p.next()
|
|
|
|
p.check(.colon)
|
|
|
|
is_mut = true
|
2021-03-04 14:30:30 +01:00
|
|
|
mut_pos = fields.len
|
2021-01-24 22:11:17 +01:00
|
|
|
}
|
2021-01-23 07:57:17 +01:00
|
|
|
if p.peek_tok.kind == .lpar {
|
2022-01-26 11:36:28 +01:00
|
|
|
method_start_pos := p.tok.pos()
|
2021-01-23 07:57:17 +01:00
|
|
|
line_nr := p.tok.line_nr
|
|
|
|
name := p.check_name()
|
2021-05-02 02:00:47 +02:00
|
|
|
|
2021-08-14 16:22:25 +02:00
|
|
|
if name in ['type_name', 'type_idx'] {
|
|
|
|
p.error_with_pos('cannot override built-in method `$name`', method_start_pos)
|
2021-02-15 14:29:44 +01:00
|
|
|
return ast.InterfaceDecl{}
|
|
|
|
}
|
2021-01-23 07:57:17 +01:00
|
|
|
if ts.has_method(name) {
|
|
|
|
p.error_with_pos('duplicate method `$name`', method_start_pos)
|
|
|
|
return ast.InterfaceDecl{}
|
|
|
|
}
|
|
|
|
// field_names << name
|
2021-04-02 00:57:09 +02:00
|
|
|
args2, _, is_variadic := p.fn_args() // TODO merge ast.Param and ast.Arg to avoid this
|
2021-09-21 15:20:09 +02:00
|
|
|
mut args := [
|
|
|
|
ast.Param{
|
|
|
|
name: 'x'
|
|
|
|
is_mut: is_mut
|
|
|
|
typ: typ
|
|
|
|
is_hidden: true
|
|
|
|
},
|
|
|
|
]
|
2021-01-23 07:57:17 +01:00
|
|
|
args << args2
|
|
|
|
mut method := ast.FnDecl{
|
|
|
|
name: name
|
2022-02-10 11:26:30 +01:00
|
|
|
short_name: name
|
2021-01-23 07:57:17 +01:00
|
|
|
mod: p.mod
|
|
|
|
params: args
|
|
|
|
file: p.file_name
|
2021-04-02 00:57:09 +02:00
|
|
|
return_type: ast.void_type
|
2021-01-23 07:57:17 +01:00
|
|
|
is_variadic: is_variadic
|
|
|
|
is_pub: true
|
2022-01-26 11:36:28 +01:00
|
|
|
pos: method_start_pos.extend(p.prev_tok.pos())
|
2021-01-23 07:57:17 +01:00
|
|
|
scope: p.scope
|
|
|
|
}
|
|
|
|
if p.tok.kind.is_start_of_type() && p.tok.line_nr == line_nr {
|
2022-01-26 11:36:28 +01:00
|
|
|
method.return_type_pos = p.tok.pos()
|
2021-01-23 07:57:17 +01:00
|
|
|
method.return_type = p.parse_type()
|
2022-01-26 11:36:28 +01:00
|
|
|
method.return_type_pos = method.return_type_pos.extend(p.tok.pos())
|
2021-04-05 17:14:21 +02:00
|
|
|
method.pos = method.pos.extend(method.return_type_pos)
|
2021-01-23 07:57:17 +01:00
|
|
|
}
|
2021-02-08 17:16:02 +01:00
|
|
|
mcomments := p.eat_comments(same_line: true)
|
2021-07-20 10:17:08 +02:00
|
|
|
mnext_comments := p.eat_comments()
|
2021-01-23 07:57:17 +01:00
|
|
|
method.comments = mcomments
|
|
|
|
method.next_comments = mnext_comments
|
|
|
|
methods << method
|
|
|
|
// println('register method $name')
|
2021-04-02 00:57:09 +02:00
|
|
|
tmethod := ast.Fn{
|
2021-01-23 07:57:17 +01:00
|
|
|
name: name
|
|
|
|
params: args
|
2021-05-02 02:00:47 +02:00
|
|
|
pos: method.pos
|
2021-01-23 07:57:17 +01:00
|
|
|
return_type: method.return_type
|
|
|
|
is_variadic: is_variadic
|
|
|
|
is_pub: true
|
2021-12-28 18:42:31 +01:00
|
|
|
is_method: true
|
|
|
|
receiver_type: typ
|
2021-01-26 11:56:17 +01:00
|
|
|
}
|
|
|
|
ts.register_method(tmethod)
|
|
|
|
info.methods << tmethod
|
2021-01-23 07:57:17 +01:00
|
|
|
} else {
|
|
|
|
// interface fields
|
2022-01-26 11:36:28 +01:00
|
|
|
field_pos := p.tok.pos()
|
2021-01-23 07:57:17 +01:00
|
|
|
field_name := p.check_name()
|
2022-01-26 11:36:28 +01:00
|
|
|
mut type_pos := p.tok.pos()
|
2021-01-23 07:57:17 +01:00
|
|
|
field_typ := p.parse_type()
|
2022-01-26 11:36:28 +01:00
|
|
|
type_pos = type_pos.extend(p.prev_tok.pos())
|
2021-01-23 07:57:17 +01:00
|
|
|
mut comments := []ast.Comment{}
|
|
|
|
for p.tok.kind == .comment {
|
|
|
|
comments << p.comment()
|
|
|
|
if p.tok.kind == .rcbr {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fields << ast.StructField{
|
|
|
|
name: field_name
|
|
|
|
pos: field_pos
|
|
|
|
type_pos: type_pos
|
|
|
|
typ: field_typ
|
|
|
|
comments: comments
|
2021-04-02 00:57:09 +02:00
|
|
|
is_pub: true
|
2021-01-23 07:57:17 +01:00
|
|
|
}
|
2021-04-02 00:57:09 +02:00
|
|
|
info.fields << ast.StructField{
|
2021-01-23 07:57:17 +01:00
|
|
|
name: field_name
|
|
|
|
typ: field_typ
|
2021-01-24 22:11:17 +01:00
|
|
|
is_pub: true
|
|
|
|
is_mut: is_mut
|
2021-01-23 07:57:17 +01:00
|
|
|
}
|
2020-04-17 18:01:02 +02:00
|
|
|
}
|
|
|
|
}
|
2022-02-15 10:17:39 +01:00
|
|
|
info.embeds = ifaces.map(it.typ)
|
2021-01-26 11:56:17 +01:00
|
|
|
ts.info = info
|
2020-06-06 17:47:16 +02:00
|
|
|
p.top_level_statement_end()
|
2020-04-17 18:01:02 +02:00
|
|
|
p.check(.rcbr)
|
2022-01-26 11:36:28 +01:00
|
|
|
pos = pos.extend_with_last_line(p.prev_tok.pos(), p.prev_tok.line_nr)
|
2021-05-02 02:00:47 +02:00
|
|
|
res := ast.InterfaceDecl{
|
2020-04-17 18:01:02 +02:00
|
|
|
name: interface_name
|
2021-04-26 08:58:05 +02:00
|
|
|
language: language
|
2021-05-02 02:00:47 +02:00
|
|
|
typ: typ
|
2021-01-23 07:57:17 +01:00
|
|
|
fields: fields
|
2020-04-22 20:20:49 +02:00
|
|
|
methods: methods
|
2022-02-15 10:17:39 +01:00
|
|
|
embeds: ifaces
|
2020-07-14 18:52:28 +02:00
|
|
|
is_pub: is_pub
|
2021-11-17 10:41:33 +01:00
|
|
|
attrs: attrs
|
2021-01-19 14:49:40 +01:00
|
|
|
pos: pos
|
2020-10-14 21:48:49 +02:00
|
|
|
pre_comments: pre_comments
|
2021-07-15 07:29:13 +02:00
|
|
|
generic_types: generic_types
|
2021-03-04 14:30:30 +01:00
|
|
|
mut_pos: mut_pos
|
2021-04-05 17:14:21 +02:00
|
|
|
name_pos: name_pos
|
2020-04-17 18:01:02 +02:00
|
|
|
}
|
2021-05-02 02:00:47 +02:00
|
|
|
p.table.register_interface(res)
|
|
|
|
return res
|
2020-04-17 18:01:02 +02:00
|
|
|
}
|