Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Cloogle
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Cloogle
Cloogle
Commits
9556351d
Commit
9556351d
authored
Aug 17, 2016
by
Camil Staps
🚀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Macro infix priority in typedb
parent
2b7ab8d9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
9 deletions
+41
-9
TypeDB.icl
TypeDB.icl
+3
-1
builddb.icl
builddb.icl
+23
-8
listmacros.py
listmacros.py
+15
-0
No files found.
TypeDB.icl
View file @
9556351d
...
...
@@ -81,7 +81,9 @@ instance print (FunctionName, ExtendedType)
where
print
_
(
f
,
(
ET
t
e
=:{
te_generic_vars
=
Just
_}))
=
"generic "
--
f
--
" "
--
e
--
" :: "
--
t
print
_
(
f
,
(
ET
t
e
))
print
_
(
f
,
(
ET
t
e
=:{
te_priority
=
Just
_}))
=
"("
--
f
--
") "
--
e
--
" :: "
--
t
print
_
(
f
,
(
ET
t
e
=:{
te_priority
=
Nothing
}))
=
f
--
" "
--
e
--
" :: "
--
t
getFunction
::
FunctionLocation
TypeDB
->
Maybe
ExtendedType
...
...
builddb.icl
View file @
9556351d
...
...
@@ -9,6 +9,7 @@ import StdFile, StdList, StdMisc, StdArray, StdBool, StdString, StdTuple
// CleanPlatform
import
Data
.
Maybe
,
Data
.
Either
,
Data
.
Error
,
Data
.
Func
,
Data
.
Tuple
,
Data
.
Functor
import
Control
.
Applicative
,
Control
.
Monad
from
Text
import
class
Text
(
concat
),
instance
Text
String
import
System
.
Directory
,
System
.
CommandLine
...
...
@@ -184,10 +185,24 @@ where
pd_macros
::
String
String
[
ParsedDefinition
]
->
[('
DB
'.
MacroLocation
,
'
DB
'.
Macro
)]
pd_macros
lib
mod
pds
=
[(
'
DB
'.
ML
lib
mod
id
.
id_name
,
{
macro_as_string
=
cpp
pd
,
macro_extras
=
zero
,
{
macro_as_string
=
priostring
id
+++
cpp
pd
,
macro_extras
=
{
zero
&
te_priority
=
findPrio
id
>>=
toPrio
}
}
)
\\
pd
=:(
PD_Function
_
id
isinfix
args
rhs
FK_Macro
)
<-
pds
]
where
priostring
::
Ident
->
String
priostring
id
=
case
findTypeSpec
id
pds
of
Nothing
=
""
(
Just
pri
)
=
cpp
pri
+++
"
\n
"
findPrio
::
Ident
->
Maybe
Priority
findPrio
id
=
(\(
PD_TypeSpec
_
_
p
_
_)
->
p
)
<$>
findTypeSpec
id
pds
findTypeSpec
::
Ident
[
ParsedDefinition
]
->
Maybe
ParsedDefinition
findTypeSpec
_
[]
=
Nothing
findTypeSpec
id
[
pd
=:(
PD_TypeSpec
_
id`
prio
_
_):
pds
]
|
id`
.
id_name
==
id
.
id_name
=
Just
pd
findTypeSpec
id
[_:
pds
]
=
findTypeSpec
id
pds
pd_derivations
::
[
ParsedDefinition
]
->
[('
DB
'.
GenericName
,
['
DB
'.
Type
])]
pd_derivations
pds
...
...
@@ -207,12 +222,6 @@ where
=
[(
'
DB
'.
FL
lib
mod
id_name
,
'
DB
'.
ET
(
'T'
.
toType
t
)
{
zero
&
te_priority
=
toPrio
p
}
)
\\
PD_TypeSpec
pos
id
=:{
id_name
}
p
(
Yes
t
)
funspecs
<-
pds
]
where
toPrio
::
Priority
->
Maybe
'
DB
'.
TE_Priority
toPrio
(
Prio
LeftAssoc
i
)
=
Just
$
'
DB
'.
LeftAssoc
i
toPrio
(
Prio
RightAssoc
i
)
=
Just
$
'
DB
'.
RightAssoc
i
toPrio
(
Prio
NoAssoc
i
)
=
Just
$
'
DB
'.
NoAssoc
i
toPrio
_
=
Nothing
pd_instances
::
[
ParsedDefinition
]
->
[('
DB
'.
Class
,
['
DB
'.
Type
])]
pd_instances
pds
...
...
@@ -242,6 +251,12 @@ where
=
[('
DB
'.
FL
lib
mod
c
,
'
DB
'.
ET
f
{
zero
&
te_isconstructor
=
True
})
\\
(
c
,
f
)
<-
'T'
.
constructorsToFunctions
td
]
toPrio
::
Priority
->
Maybe
'
DB
'.
TE_Priority
toPrio
(
Prio
LeftAssoc
i
)
=
Just
$
'
DB
'.
LeftAssoc
i
toPrio
(
Prio
RightAssoc
i
)
=
Just
$
'
DB
'.
RightAssoc
i
toPrio
(
Prio
NoAssoc
i
)
=
Just
$
'
DB
'.
NoAssoc
i
toPrio
_
=
Nothing
wantModule`
::
!*
File
!{#
Char
}
!
Bool
!
Ident
!
Position
!
Bool
!*
HashTable
!*
File
!*
Files
->
((!
Bool
,!
Bool
,!
ParsedModule
,
!*
HashTable
,
!*
File
),
!*
Files
)
wantModule`
f
s
b1
i
p
b2
ht
io
fs
...
...
listmacros.py
0 → 100755
View file @
9556351d
#!/usr/bin/env python3
import
json
db
=
{}
with
open
(
'types.json'
,
'r'
)
as
f
:
db
=
json
.
load
(
f
)
def
listmacros
(
db
):
if
db
[
0
]
==
'Tip'
:
return
listmacros
(
db
[
4
])
print
(
db
[
2
])
listmacros
(
db
[
5
])
listmacros
(
db
[
'macromap'
])
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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