Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
clean-compiler-and-rts
compiler
Commits
2a4cca74
Commit
2a4cca74
authored
Jan 17, 2002
by
Martijn Vervoort
Browse files
added a constructor and a destructor function for type string which contains
a type name and a module name.
parent
b6a0c985
Changes
2
Hide whitespace changes
Inline
Side-by-side
frontend/type_io_common.dcl
View file @
2a4cca74
...
...
@@ -8,6 +8,8 @@ import StdEnv
import
syntax
import
StdOverloaded
APPEND_DEFINING_TYPE_MODULE_NAMES_TO_TYPE_NAMES
yes
no
:==
yes
/*
// Priority
PrioCode :== toChar 0
...
...
@@ -66,3 +68,8 @@ UnderscoreSystemModule :== "_system" // implements the predefined module
instance
toString
GlobalTCType
instance
toString
BasicType
create_type_string
type_name
module_name
:==
type_name
+++
(
APPEND_DEFINING_TYPE_MODULE_NAMES_TO_TYPE_NAMES
(
"'"
+++
module_name
)
""
)
get_type_name_and_module_name_from_type_string
::
!
String
->
(!
String
,!
String
)
frontend/type_io_common.icl
View file @
2a4cca74
...
...
@@ -67,9 +67,10 @@ UnderscoreSystemModule :== "_system" // implements the predefined module
instance
toString
GlobalTCType
where
toString
(
GTT_Basic
basic_type
)
=
toString
basic_type
+++
(
APPEND_DEFINING_TYPE_MODULE_NAMES_TO_TYPE_NAMES
(
"'"
+++
PredefinedModuleName
)
""
)
toString
(
GTT_Basic
basic_type
)
=
create_type_string
(
toString
basic_type
)
PredefinedModuleName
toString
GTT_Function
=
" -> "
toString
(
GTT_Constructor
type_symb_indent
mod_name
)
=
type_symb_indent
.
type_name
.
id_name
+++
(
APPEND_DEFINING_TYPE_MODULE_NAMES_TO_TYPE_NAMES
(
"'"
+++
mod_name
)
""
)
toString
(
GTT_Constructor
type_symb_indent
mod_name
)
=
create_type_string
type_symb_indent
.
type_name
.
id_name
mod_name
// +++ (APPEND_DEFINING_TYPE_MODULE_NAMES_TO_TYPE_NAMES ("'" +++ mod_name) "")
instance
toString
BasicType
where
...
...
@@ -81,3 +82,29 @@ where
toString
BT_File
=
"File"
toString
BT_World
=
"World"
toString
(
BT_String
_)
=
"String"
create_type_string
type_name
module_name
:==
type_name
+++
(
APPEND_DEFINING_TYPE_MODULE_NAMES_TO_TYPE_NAMES
(
"'"
+++
module_name
)
""
)
get_type_name_and_module_name_from_type_string
::
!
String
->
(!
String
,!
String
)
get_type_name_and_module_name_from_type_string
type_string
#!
(
found_sep
,
sep_pos
)
=
CharIndex
type_string
0
'\''
|
found_sep
#!
type_name
=
type_string
%
(
0
,
dec
sep_pos
)
#!
module_name
=
type_string
%
(
inc
sep_pos
,
dec
(
size
type_string
))
=
(
type_name
,
module_name
)
where
CharIndex
::
!
String
!
Int
!
Char
->
(!
Bool
,!
Int
)
CharIndex
s
i
char
|
i
==
(
size
s
)
=
(
False
,
size
s
)
|
i
<
(
size
s
)
|
s
.[
i
]
==
char
=
(
True
,
i
)
=
CharIndex
s
(
inc
i
)
char
;
=
abort
"CharIndex: index out of range"
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment