ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
begin_type.c
Go to the documentation of this file.
1/*****************************************************************************
2 * ugBASIC - an isomorphic BASIC language compiler for retrocomputers *
3 *****************************************************************************
4 * Copyright 2021-2026 Marco Spedaletti (asimov@mclink.it)
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *----------------------------------------------------------------------------
18 * Concesso in licenza secondo i termini della Licenza Apache, versione 2.0
19 * (la "Licenza"); è proibito usare questo file se non in conformità alla
20 * Licenza. Una copia della Licenza è disponibile all'indirizzo:
21 *
22 * http://www.apache.org/licenses/LICENSE-2.0
23 *
24 * Se non richiesto dalla legislazione vigente o concordato per iscritto,
25 * il software distribuito nei termini della Licenza è distribuito
26 * "COSÌ COM'È", SENZA GARANZIE O CONDIZIONI DI ALCUN TIPO, esplicite o
27 * implicite. Consultare la Licenza per il testo specifico che regola le
28 * autorizzazioni e le limitazioni previste dalla medesima.
29 ****************************************************************************/
30
31/****************************************************************************
32 * INCLUDE SECTION
33 ****************************************************************************/
34
35#include "../../ugbc.h"
36
37/****************************************************************************
38 * CODE SECTION
39 ****************************************************************************/
40
47/* <usermanual>
48@keyword BEGIN TYPE...END TYPE
49
50@english
51
52The ''BEGIN TYPE..END TYPE'' command lets you define custom data types,
53also known as "records" or "structures." These data types let you group
54variables of different types under a single name, making it easier to
55manage complex data.
56
57The ''TYPE'' command lets you create data models that can contain
58variables of different types. It lets you organize data in a logical
59and structured way, improving the readability and maintainability of
60your code. Once you've defined a data type with ''TYPE'', you can access
61the individual members (variables) of the structure using the variable
62name and the member name separated by a period.
63
64The ''TYPE'' command is especially useful when you work with large
65amounts of data or when you want to create complex data structures.
66It allows you to group related information and manage it efficiently.
67
68@italian
69Il comando ''BEGIN TYPE..END TYPE'' consente di definire tipi di dati personalizzati,
70noti anche come "record" o "strutture". Questi tipi di dati consentono di raggruppare
71variabili di tipi diversi sotto un unico nome, semplificando
72la gestione di dati complessi.
73
74Il comando ''TYPE'' consente di creare modelli di dati che possono contenere
75variabili di tipi diversi. Consente di organizzare i dati in modo logico
76e strutturato, migliorando la leggibilità e la manutenibilità del
77codice. Dopo aver definito un tipo di dati con ''TYPE'', è possibile accedere
78ai singoli membri (variabili) della struttura utilizzando il nome della variabile e il nome del membro separati da un punto.
79
80Il comando ''TYPE'' è particolarmente utile quando si lavora con grandi
81quantità di dati o quando si desidera creare strutture di dati complesse.
82Consente di raggruppare informazioni correlate e gestirle in modo efficiente.
83
84@syntax BEGIN TYPE name
85@syntax variable AS datatype
86@syntax END TYPE
87
88@example BEGIN TYPE person
89@example age AS INT
90@example height AS BYTE
91@example END TYPE
92
93@alias TYPE...ENDTYPE
94@alias BEGIN TYPE...ENDTYPE
95
96</usermanual> */
97/* <usermanual>
98@keyword TYPE...END TYPE
99
100@english
101
102@italian
103
104@syntax TYPE name
105@syntax variable AS datatype
106@syntax END TYPE
107
108@example TYPE person
109@example age AS INT
110@example height AS BYTE
111@example END TYPE
112
113@alias BEGIN TYPE...END TYPE
114
115</usermanual> */
116
117void begin_type( Environment * _environment, char * _name ) {
118
119 if ( _environment->currentType ) {
121 }
122
123 if ( type_find( _environment->types, _name ) ) {
125 }
126
127 Type * type = malloc( sizeof( Type ) );
128 memset( type, 0, sizeof ( Type ) );
129 type->name = strdup( _name );
130
131 _environment->currentType = type;
132
133}
Type * type_find(Type *_first, char *_name)
void begin_type(Environment *_environment, char *_name)
Emit code for STORAGE ... ENDSTORAGE.
Definition begin_type.c:117
Type * types
Definition ugbc.h:2538
Type * currentType
Definition ugbc.h:2540
char * name
Definition ugbc.h:1243
void * malloc(YYSIZE_T)
struct _Type Type
struct _Environment Environment
Structure of compilation environment.
#define CRITICAL_TYPE_ALREADY_DEFINED(n)
Definition ugbc.h:3827
#define CRITICAL_TYPE_NESTED_UNSUPPORTED(n)
Definition ugbc.h:3826