Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
08c0a048
Commit
08c0a048
authored
Apr 20, 2013
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup: alias -> using
parent
6b61f9c4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
36 deletions
+36
-36
Compiler.hs
compiler/src/Compiler.hs
+12
-12
Grammar.hs
compiler/src/Grammar.hs
+3
-3
Parser.hs
compiler/src/Parser.hs
+3
-3
Semantics.hs
compiler/src/Semantics.hs
+18
-18
No files found.
compiler/src/Compiler.hs
View file @
08c0a048
...
@@ -115,7 +115,7 @@ descMember name (DescFile d) = lookupMember name (fileMemberMap d)
...
@@ -115,7 +115,7 @@ descMember name (DescFile d) = lookupMember name (fileMemberMap d)
descMember
name
(
DescEnum
d
)
=
lookupMember
name
(
enumMemberMap
d
)
descMember
name
(
DescEnum
d
)
=
lookupMember
name
(
enumMemberMap
d
)
descMember
name
(
DescStruct
d
)
=
lookupMember
name
(
structMemberMap
d
)
descMember
name
(
DescStruct
d
)
=
lookupMember
name
(
structMemberMap
d
)
descMember
name
(
DescInterface
d
)
=
lookupMember
name
(
interfaceMemberMap
d
)
descMember
name
(
DescInterface
d
)
=
lookupMember
name
(
interfaceMemberMap
d
)
descMember
name
(
Desc
Alias
d
)
=
descMember
name
(
alias
Target
d
)
descMember
name
(
Desc
Using
d
)
=
descMember
name
(
using
Target
d
)
descMember
_
_
=
Nothing
descMember
_
_
=
Nothing
-- | Lookup the given name in the scope of the given descriptor.
-- | Lookup the given name in the scope of the given descriptor.
...
@@ -255,7 +255,7 @@ compileValue pos (ListType _) _ = makeExpectError pos "list"
...
@@ -255,7 +255,7 @@ compileValue pos (ListType _) _ = makeExpectError pos "list"
makeFileMemberMap
::
FileDesc
->
Map
.
Map
String
Desc
makeFileMemberMap
::
FileDesc
->
Map
.
Map
String
Desc
makeFileMemberMap
desc
=
Map
.
fromList
allMembers
where
makeFileMemberMap
desc
=
Map
.
fromList
allMembers
where
allMembers
=
[
(
aliasName
m
,
DescAlias
m
)
|
m
<-
fileAliases
desc
]
allMembers
=
[
(
usingName
m
,
DescUsing
m
)
|
m
<-
fileUsings
desc
]
++
[
(
constantName
m
,
DescConstant
m
)
|
m
<-
fileConstants
desc
]
++
[
(
constantName
m
,
DescConstant
m
)
|
m
<-
fileConstants
desc
]
++
[
(
enumName
m
,
DescEnum
m
)
|
m
<-
fileEnums
desc
]
++
[
(
enumName
m
,
DescEnum
m
)
|
m
<-
fileEnums
desc
]
++
[
(
structName
m
,
DescStruct
m
)
|
m
<-
fileStructs
desc
]
++
[
(
structName
m
,
DescStruct
m
)
|
m
<-
fileStructs
desc
]
...
@@ -265,7 +265,7 @@ descAsType _ (DescEnum desc) = succeed (EnumType desc)
...
@@ -265,7 +265,7 @@ descAsType _ (DescEnum desc) = succeed (EnumType desc)
descAsType
_
(
DescStruct
desc
)
=
succeed
(
StructType
desc
)
descAsType
_
(
DescStruct
desc
)
=
succeed
(
StructType
desc
)
descAsType
_
(
DescInterface
desc
)
=
succeed
(
InterfaceType
desc
)
descAsType
_
(
DescInterface
desc
)
=
succeed
(
InterfaceType
desc
)
descAsType
_
(
DescBuiltinType
desc
)
=
succeed
(
BuiltinType
desc
)
descAsType
_
(
DescBuiltinType
desc
)
=
succeed
(
BuiltinType
desc
)
descAsType
name
(
Desc
Alias
desc
)
=
descAsType
name
(
alias
Target
desc
)
descAsType
name
(
Desc
Using
desc
)
=
descAsType
name
(
using
Target
desc
)
descAsType
name
DescBuiltinList
=
makeError
(
declNamePos
name
)
message
where
descAsType
name
DescBuiltinList
=
makeError
(
declNamePos
name
)
message
where
message
=
printf
"'List' requires exactly one type parameter."
(
declNameString
name
)
message
=
printf
"'List' requires exactly one type parameter."
(
declNameString
name
)
descAsType
name
_
=
makeError
(
declNamePos
name
)
message
where
descAsType
name
_
=
makeError
(
declNamePos
name
)
message
where
...
@@ -553,13 +553,13 @@ compileChildDecls desc decls = Active (members, memberMap) errors where
...
@@ -553,13 +553,13 @@ compileChildDecls desc decls = Active (members, memberMap) errors where
|
CompiledStatementStatus
name
status
<-
compiledDecls
]
|
CompiledStatementStatus
name
status
<-
compiledDecls
]
errors
=
concatMap
compiledErrors
compiledDecls
errors
=
concatMap
compiledErrors
compiledDecls
compileDecl
scope
(
Alias
Decl
(
Located
_
name
)
target
)
=
compileDecl
scope
(
Using
Decl
(
Located
_
name
)
target
)
=
CompiledStatementStatus
name
(
do
CompiledStatementStatus
name
(
do
targetDesc
<-
lookupDesc
scope
target
targetDesc
<-
lookupDesc
scope
target
return
(
Desc
Alias
Alias
Desc
return
(
Desc
Using
Using
Desc
{
alias
Name
=
name
{
using
Name
=
name
,
alias
Parent
=
scope
,
using
Parent
=
scope
,
alias
Target
=
targetDesc
,
using
Target
=
targetDesc
}))
}))
compileDecl
scope
(
ConstantDecl
(
Located
_
name
)
t
annotations
(
Located
valuePos
value
))
=
compileDecl
scope
(
ConstantDecl
(
Located
_
name
)
t
annotations
(
Located
valuePos
value
))
=
...
@@ -627,7 +627,7 @@ compileDecl scope (StructDecl (Located _ name) annotations decls) =
...
@@ -627,7 +627,7 @@ compileDecl scope (StructDecl (Located _ name) annotations decls) =
,
structPacking
=
packing
,
structPacking
=
packing
,
structFields
=
fields
,
structFields
=
fields
,
structUnions
=
unions
,
structUnions
=
unions
,
structNested
Aliases
=
[
d
|
DescAlias
d
<-
members
]
,
structNested
Usings
=
[
d
|
DescUsing
d
<-
members
]
,
structNestedConstants
=
[
d
|
DescConstant
d
<-
members
]
,
structNestedConstants
=
[
d
|
DescConstant
d
<-
members
]
,
structNestedEnums
=
[
d
|
DescEnum
d
<-
members
]
,
structNestedEnums
=
[
d
|
DescEnum
d
<-
members
]
,
structNestedStructs
=
[
d
|
DescStruct
d
<-
members
]
,
structNestedStructs
=
[
d
|
DescStruct
d
<-
members
]
...
@@ -708,7 +708,7 @@ compileDecl scope (InterfaceDecl (Located _ name) annotations decls) =
...
@@ -708,7 +708,7 @@ compileDecl scope (InterfaceDecl (Located _ name) annotations decls) =
,
interfaceId
=
theId
,
interfaceId
=
theId
,
interfaceParent
=
scope
,
interfaceParent
=
scope
,
interfaceMethods
=
[
d
|
DescMethod
d
<-
members
]
,
interfaceMethods
=
[
d
|
DescMethod
d
<-
members
]
,
interfaceNested
Aliases
=
[
d
|
DescAlias
d
<-
members
]
,
interfaceNested
Usings
=
[
d
|
DescUsing
d
<-
members
]
,
interfaceNestedConstants
=
[
d
|
DescConstant
d
<-
members
]
,
interfaceNestedConstants
=
[
d
|
DescConstant
d
<-
members
]
,
interfaceNestedEnums
=
[
d
|
DescEnum
d
<-
members
]
,
interfaceNestedEnums
=
[
d
|
DescEnum
d
<-
members
]
,
interfaceNestedStructs
=
[
d
|
DescStruct
d
<-
members
]
,
interfaceNestedStructs
=
[
d
|
DescStruct
d
<-
members
]
...
@@ -777,7 +777,7 @@ compileFile name decls annotations importMap =
...
@@ -777,7 +777,7 @@ compileFile name decls annotations importMap =
{
fileName
=
name
{
fileName
=
name
,
fileId
=
theId
,
fileId
=
theId
,
fileImports
=
Map
.
elems
importMap
,
fileImports
=
Map
.
elems
importMap
,
file
Aliases
=
[
d
|
DescAlias
d
<-
members
]
,
file
Usings
=
[
d
|
DescUsing
d
<-
members
]
,
fileConstants
=
[
d
|
DescConstant
d
<-
members
]
,
fileConstants
=
[
d
|
DescConstant
d
<-
members
]
,
fileEnums
=
[
d
|
DescEnum
d
<-
members
]
,
fileEnums
=
[
d
|
DescEnum
d
<-
members
]
,
fileStructs
=
[
d
|
DescStruct
d
<-
members
]
,
fileStructs
=
[
d
|
DescStruct
d
<-
members
]
...
@@ -795,7 +795,7 @@ emptyFileDesc filename = FileDesc
...
@@ -795,7 +795,7 @@ emptyFileDesc filename = FileDesc
{
fileName
=
filename
{
fileName
=
filename
,
fileId
=
Nothing
,
fileId
=
Nothing
,
fileImports
=
[]
,
fileImports
=
[]
,
file
Aliase
s
=
[]
,
file
Using
s
=
[]
,
fileConstants
=
[]
,
fileConstants
=
[]
,
fileEnums
=
[]
,
fileEnums
=
[]
,
fileStructs
=
[]
,
fileStructs
=
[]
...
...
compiler/src/Grammar.hs
View file @
08c0a048
...
@@ -91,7 +91,7 @@ instance Show AnnotationTarget where
...
@@ -91,7 +91,7 @@ instance Show AnnotationTarget where
show
ParamAnnotation
=
"param"
show
ParamAnnotation
=
"param"
show
AnnotationAnnotation
=
"annotation"
show
AnnotationAnnotation
=
"annotation"
data
Declaration
=
Alias
Decl
(
Located
String
)
DeclName
data
Declaration
=
Using
Decl
(
Located
String
)
DeclName
|
ConstantDecl
(
Located
String
)
TypeExpression
[
Annotation
]
(
Located
FieldValue
)
|
ConstantDecl
(
Located
String
)
TypeExpression
[
Annotation
]
(
Located
FieldValue
)
|
EnumDecl
(
Located
String
)
[
Annotation
]
[
Declaration
]
|
EnumDecl
(
Located
String
)
[
Annotation
]
[
Declaration
]
|
EnumerantDecl
(
Located
String
)
(
Located
Integer
)
[
Annotation
]
|
EnumerantDecl
(
Located
String
)
(
Located
Integer
)
[
Annotation
]
...
@@ -106,7 +106,7 @@ data Declaration = AliasDecl (Located String) DeclName
...
@@ -106,7 +106,7 @@ data Declaration = AliasDecl (Located String) DeclName
deriving
(
Show
)
deriving
(
Show
)
declarationName
::
Declaration
->
Maybe
(
Located
String
)
declarationName
::
Declaration
->
Maybe
(
Located
String
)
declarationName
(
Alias
Decl
n
_
)
=
Just
n
declarationName
(
Using
Decl
n
_
)
=
Just
n
declarationName
(
ConstantDecl
n
_
_
_
)
=
Just
n
declarationName
(
ConstantDecl
n
_
_
_
)
=
Just
n
declarationName
(
EnumDecl
n
_
_
)
=
Just
n
declarationName
(
EnumDecl
n
_
_
)
=
Just
n
declarationName
(
EnumerantDecl
n
_
_
)
=
Just
n
declarationName
(
EnumerantDecl
n
_
_
)
=
Just
n
...
@@ -118,7 +118,7 @@ declarationName (MethodDecl n _ _ _ _) = Just n
...
@@ -118,7 +118,7 @@ declarationName (MethodDecl n _ _ _ _) = Just n
declarationName
(
AnnotationDecl
n
_
_
_
)
=
Just
n
declarationName
(
AnnotationDecl
n
_
_
_
)
=
Just
n
declImports
::
Declaration
->
[
Located
String
]
declImports
::
Declaration
->
[
Located
String
]
declImports
(
Alias
Decl
_
name
)
=
maybeToList
(
declNameImport
name
)
declImports
(
Using
Decl
_
name
)
=
maybeToList
(
declNameImport
name
)
declImports
(
ConstantDecl
_
t
ann
_
)
=
typeImports
t
++
concatMap
annotationImports
ann
declImports
(
ConstantDecl
_
t
ann
_
)
=
typeImports
t
++
concatMap
annotationImports
ann
declImports
(
EnumDecl
_
ann
decls
)
=
concatMap
annotationImports
ann
++
concatMap
declImports
decls
declImports
(
EnumDecl
_
ann
decls
)
=
concatMap
annotationImports
ann
++
concatMap
declImports
decls
declImports
(
EnumerantDecl
_
_
ann
)
=
concatMap
annotationImports
ann
declImports
(
EnumerantDecl
_
_
ann
)
=
concatMap
annotationImports
ann
...
...
compiler/src/Parser.hs
View file @
08c0a048
...
@@ -167,16 +167,16 @@ annotation = do
...
@@ -167,16 +167,16 @@ annotation = do
return
(
Annotation
name
value
)
return
(
Annotation
name
value
)
topLine
::
Maybe
[
Located
Statement
]
->
TokenParser
(
Either
Declaration
Annotation
)
topLine
::
Maybe
[
Located
Statement
]
->
TokenParser
(
Either
Declaration
Annotation
)
topLine
Nothing
=
liftM
Left
(
alias
Decl
<|>
constantDecl
<|>
annotationDecl
)
topLine
Nothing
=
liftM
Left
(
using
Decl
<|>
constantDecl
<|>
annotationDecl
)
<|>
liftM
Right
annotation
<|>
liftM
Right
annotation
topLine
(
Just
statements
)
=
liftM
Left
$
typeDecl
statements
topLine
(
Just
statements
)
=
liftM
Left
$
typeDecl
statements
alias
Decl
=
do
using
Decl
=
do
usingKeyword
usingKeyword
name
<-
located
typeIdentifier
name
<-
located
typeIdentifier
equalsSign
equalsSign
target
<-
declName
target
<-
declName
return
(
Alias
Decl
name
target
)
return
(
Using
Decl
name
target
)
constantDecl
=
do
constantDecl
=
do
constKeyword
constKeyword
...
...
compiler/src/Semantics.hs
View file @
08c0a048
...
@@ -42,7 +42,7 @@ maxOrdinal = 65534 :: Integer
...
@@ -42,7 +42,7 @@ maxOrdinal = 65534 :: Integer
type
ByteString
=
[
Word8
]
type
ByteString
=
[
Word8
]
data
Desc
=
DescFile
FileDesc
data
Desc
=
DescFile
FileDesc
|
Desc
Alias
Alias
Desc
|
Desc
Using
Using
Desc
|
DescConstant
ConstantDesc
|
DescConstant
ConstantDesc
|
DescEnum
EnumDesc
|
DescEnum
EnumDesc
|
DescEnumerant
EnumerantDesc
|
DescEnumerant
EnumerantDesc
...
@@ -58,7 +58,7 @@ data Desc = DescFile FileDesc
...
@@ -58,7 +58,7 @@ data Desc = DescFile FileDesc
|
DescBuiltinId
|
DescBuiltinId
descName
(
DescFile
_
)
=
"(top-level)"
descName
(
DescFile
_
)
=
"(top-level)"
descName
(
Desc
Alias
d
)
=
alias
Name
d
descName
(
Desc
Using
d
)
=
using
Name
d
descName
(
DescConstant
d
)
=
constantName
d
descName
(
DescConstant
d
)
=
constantName
d
descName
(
DescEnum
d
)
=
enumName
d
descName
(
DescEnum
d
)
=
enumName
d
descName
(
DescEnumerant
d
)
=
enumerantName
d
descName
(
DescEnumerant
d
)
=
enumerantName
d
...
@@ -74,7 +74,7 @@ descName DescBuiltinList = "List"
...
@@ -74,7 +74,7 @@ descName DescBuiltinList = "List"
descName
DescBuiltinId
=
"id"
descName
DescBuiltinId
=
"id"
descId
(
DescFile
d
)
=
fileId
d
descId
(
DescFile
d
)
=
fileId
d
descId
(
Desc
Alias
_
)
=
Nothing
descId
(
Desc
Using
_
)
=
Nothing
descId
(
DescConstant
d
)
=
constantId
d
descId
(
DescConstant
d
)
=
constantId
d
descId
(
DescEnum
d
)
=
enumId
d
descId
(
DescEnum
d
)
=
enumId
d
descId
(
DescEnumerant
d
)
=
enumerantId
d
descId
(
DescEnumerant
d
)
=
enumerantId
d
...
@@ -98,7 +98,7 @@ descAutoId d = case descId d of
...
@@ -98,7 +98,7 @@ descAutoId d = case descId d of
_
->
fmap
(
++
'.'
:
descName
d
)
$
descAutoId
$
descParent
d
_
->
fmap
(
++
'.'
:
descName
d
)
$
descAutoId
$
descParent
d
descParent
(
DescFile
_
)
=
error
"File descriptor has no parent."
descParent
(
DescFile
_
)
=
error
"File descriptor has no parent."
descParent
(
Desc
Alias
d
)
=
alias
Parent
d
descParent
(
Desc
Using
d
)
=
using
Parent
d
descParent
(
DescConstant
d
)
=
constantParent
d
descParent
(
DescConstant
d
)
=
constantParent
d
descParent
(
DescEnum
d
)
=
enumParent
d
descParent
(
DescEnum
d
)
=
enumParent
d
descParent
(
DescEnumerant
d
)
=
DescEnum
(
enumerantParent
d
)
descParent
(
DescEnumerant
d
)
=
DescEnum
(
enumerantParent
d
)
...
@@ -114,7 +114,7 @@ descParent DescBuiltinList = error "Builtin type has no parent."
...
@@ -114,7 +114,7 @@ descParent DescBuiltinList = error "Builtin type has no parent."
descParent
DescBuiltinId
=
error
"Builtin annotation has no parent."
descParent
DescBuiltinId
=
error
"Builtin annotation has no parent."
descAnnotations
(
DescFile
d
)
=
fileAnnotations
d
descAnnotations
(
DescFile
d
)
=
fileAnnotations
d
descAnnotations
(
Desc
Alias
_
)
=
Map
.
empty
descAnnotations
(
Desc
Using
_
)
=
Map
.
empty
descAnnotations
(
DescConstant
d
)
=
constantAnnotations
d
descAnnotations
(
DescConstant
d
)
=
constantAnnotations
d
descAnnotations
(
DescEnum
d
)
=
enumAnnotations
d
descAnnotations
(
DescEnum
d
)
=
enumAnnotations
d
descAnnotations
(
DescEnumerant
d
)
=
enumerantAnnotations
d
descAnnotations
(
DescEnumerant
d
)
=
enumerantAnnotations
d
...
@@ -291,9 +291,9 @@ typeName scope (ListType t) = "List(" ++ typeName scope t ++ ")"
...
@@ -291,9 +291,9 @@ typeName scope (ListType t) = "List(" ++ typeName scope t ++ ")"
-- This could be made fancier in a couple ways:
-- This could be made fancier in a couple ways:
-- 1) Drop the common prefix between scope and desc to form a minimal relative name. Note that
-- 1) Drop the common prefix between scope and desc to form a minimal relative name. Note that
-- we'll need to check for shadowing.
-- we'll need to check for shadowing.
-- 2) Examine
aliase
s visible in the current scope to see if they refer to a prefix of the target
-- 2) Examine
`using`
s visible in the current scope to see if they refer to a prefix of the target
-- symbol, and use them if so. A particularly important case of this is imports -- typically
-- symbol, and use them if so. A particularly important case of this is imports -- typically
-- the import will have a
n alias
in the file scope.
-- the import will have a
`using`
in the file scope.
descQualifiedName
::
Desc
->
Desc
->
String
descQualifiedName
::
Desc
->
Desc
->
String
descQualifiedName
(
DescFile
scope
)
(
DescFile
desc
)
=
descQualifiedName
(
DescFile
scope
)
(
DescFile
desc
)
=
if
fileName
scope
==
fileName
desc
if
fileName
scope
==
fileName
desc
...
@@ -307,7 +307,7 @@ data FileDesc = FileDesc
...
@@ -307,7 +307,7 @@ data FileDesc = FileDesc
{
fileName
::
String
{
fileName
::
String
,
fileId
::
Maybe
String
,
fileId
::
Maybe
String
,
fileImports
::
[
FileDesc
]
,
fileImports
::
[
FileDesc
]
,
file
Aliases
::
[
Alias
Desc
]
,
file
Usings
::
[
Using
Desc
]
,
fileConstants
::
[
ConstantDesc
]
,
fileConstants
::
[
ConstantDesc
]
,
fileEnums
::
[
EnumDesc
]
,
fileEnums
::
[
EnumDesc
]
,
fileStructs
::
[
StructDesc
]
,
fileStructs
::
[
StructDesc
]
...
@@ -318,10 +318,10 @@ data FileDesc = FileDesc
...
@@ -318,10 +318,10 @@ data FileDesc = FileDesc
,
fileStatements
::
[
Desc
]
,
fileStatements
::
[
Desc
]
}
}
data
AliasDesc
=
Alias
Desc
data
UsingDesc
=
Using
Desc
{
alias
Name
::
String
{
using
Name
::
String
,
alias
Parent
::
Desc
,
using
Parent
::
Desc
,
alias
Target
::
Desc
,
using
Target
::
Desc
}
}
data
ConstantDesc
=
ConstantDesc
data
ConstantDesc
=
ConstantDesc
...
@@ -358,7 +358,7 @@ data StructDesc = StructDesc
...
@@ -358,7 +358,7 @@ data StructDesc = StructDesc
,
structPacking
::
PackingState
,
structPacking
::
PackingState
,
structFields
::
[
FieldDesc
]
,
structFields
::
[
FieldDesc
]
,
structUnions
::
[
UnionDesc
]
,
structUnions
::
[
UnionDesc
]
,
structNested
Aliases
::
[
Alias
Desc
]
,
structNested
Usings
::
[
Using
Desc
]
,
structNestedConstants
::
[
ConstantDesc
]
,
structNestedConstants
::
[
ConstantDesc
]
,
structNestedEnums
::
[
EnumDesc
]
,
structNestedEnums
::
[
EnumDesc
]
,
structNestedStructs
::
[
StructDesc
]
,
structNestedStructs
::
[
StructDesc
]
...
@@ -407,7 +407,7 @@ data InterfaceDesc = InterfaceDesc
...
@@ -407,7 +407,7 @@ data InterfaceDesc = InterfaceDesc
,
interfaceId
::
Maybe
String
,
interfaceId
::
Maybe
String
,
interfaceParent
::
Desc
,
interfaceParent
::
Desc
,
interfaceMethods
::
[
MethodDesc
]
,
interfaceMethods
::
[
MethodDesc
]
,
interfaceNested
Aliases
::
[
Alias
Desc
]
,
interfaceNested
Usings
::
[
Using
Desc
]
,
interfaceNestedConstants
::
[
ConstantDesc
]
,
interfaceNestedConstants
::
[
ConstantDesc
]
,
interfaceNestedEnums
::
[
EnumDesc
]
,
interfaceNestedEnums
::
[
EnumDesc
]
,
interfaceNestedStructs
::
[
StructDesc
]
,
interfaceNestedStructs
::
[
StructDesc
]
...
@@ -456,9 +456,9 @@ descToCode indent self@(DescFile desc) = printf "# %s\n%s%s%s"
...
@@ -456,9 +456,9 @@ descToCode indent self@(DescFile desc) = printf "# %s\n%s%s%s"
Nothing
->
""
)
Nothing
->
""
)
(
concatMap
((
++
";
\n
"
)
.
annotationCode
self
)
$
Map
.
toList
$
fileAnnotations
desc
)
(
concatMap
((
++
";
\n
"
)
.
annotationCode
self
)
$
Map
.
toList
$
fileAnnotations
desc
)
(
concatMap
(
descToCode
indent
)
(
fileStatements
desc
))
(
concatMap
(
descToCode
indent
)
(
fileStatements
desc
))
descToCode
indent
(
Desc
Alias
desc
)
=
printf
"%susing %s = %s;
\n
"
indent
descToCode
indent
(
Desc
Using
desc
)
=
printf
"%susing %s = %s;
\n
"
indent
(
alias
Name
desc
)
(
using
Name
desc
)
(
descQualifiedName
(
aliasParent
desc
)
(
alias
Target
desc
))
(
descQualifiedName
(
usingParent
desc
)
(
using
Target
desc
))
descToCode
indent
self
@
(
DescConstant
desc
)
=
printf
"%sconst %s: %s = %s%s;
\n
"
indent
descToCode
indent
self
@
(
DescConstant
desc
)
=
printf
"%sconst %s: %s = %s%s;
\n
"
indent
(
constantName
desc
)
(
constantName
desc
)
(
typeName
(
descParent
self
)
(
constantType
desc
))
(
typeName
(
descParent
self
)
(
constantType
desc
))
...
@@ -543,7 +543,7 @@ annotationsCode desc = let
...
@@ -543,7 +543,7 @@ annotationsCode desc = let
Nothing
->
nonIds
Nothing
->
nonIds
instance
Show
FileDesc
where
{
show
desc
=
descToCode
""
(
DescFile
desc
)
}
instance
Show
FileDesc
where
{
show
desc
=
descToCode
""
(
DescFile
desc
)
}
instance
Show
AliasDesc
where
{
show
desc
=
descToCode
""
(
DescAlias
desc
)
}
instance
Show
UsingDesc
where
{
show
desc
=
descToCode
""
(
DescUsing
desc
)
}
instance
Show
ConstantDesc
where
{
show
desc
=
descToCode
""
(
DescConstant
desc
)
}
instance
Show
ConstantDesc
where
{
show
desc
=
descToCode
""
(
DescConstant
desc
)
}
instance
Show
EnumDesc
where
{
show
desc
=
descToCode
""
(
DescEnum
desc
)
}
instance
Show
EnumDesc
where
{
show
desc
=
descToCode
""
(
DescEnum
desc
)
}
instance
Show
EnumerantDesc
where
{
show
desc
=
descToCode
""
(
DescEnumerant
desc
)
}
instance
Show
EnumerantDesc
where
{
show
desc
=
descToCode
""
(
DescEnumerant
desc
)
}
...
...
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