Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dusk-lang
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Peter Matta
dusk-lang
Commits
84b8efb2
Commit
84b8efb2
authored
6 years ago
by
Peter Matta
Browse files
Options
Downloads
Patches
Plain Diff
[CLI][Feature] Updated CLI interfaces for duckc and dusk-format
parent
d825109c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tools/dusk-format/main.cpp
+28
-2
28 additions, 2 deletions
tools/dusk-format/main.cpp
tools/duskc/main.cpp
+32
-4
32 additions, 4 deletions
tools/duskc/main.cpp
with
60 additions
and
6 deletions
tools/dusk-format/main.cpp
+
28
−
2
View file @
84b8efb2
//===--- main.cpp - Dusk source compiler ------------------------*- C++ -*-===//
//
// dusk-lang
// This source file is part of a dusk-lang project, which is a semestral
// assignement for BI-PJP course at Czech Technical University in Prague.
// The software is provided "AS IS", WITHOUT WARRANTY OF ANY KIND.
//
//===----------------------------------------------------------------------===//
#include
"dusk/Basic/LLVM.h"
#include
"dusk/Frontend/CompilerInvocation.h"
#include
"dusk/Frontend/CompilerInstance.h"
#include
"llvm/ADT/StringRef.h"
#include
"llvm/Support/CommandLine.h"
#include
<string>
#include
<iostream>
#include
"dusk/AST/ASTContext.h"
#include
"dusk/AST/Type.h"
...
...
@@ -15,14 +25,23 @@ cl::opt<std::string> InFile(cl::Positional, cl::Required,
cl
::
desc
(
"<input file>"
),
cl
::
init
(
"-"
));
cl
::
opt
<
std
::
string
>
OutFile
(
"o"
,
cl
::
desc
(
"Specify output filename"
),
cl
::
value_desc
(
"<filename>"
));
cl
::
value_desc
(
"<filename>"
)
,
cl
::
init
(
"a.out"
)
);
cl
::
opt
<
bool
>
IsQuiet
(
"quiet"
,
cl
::
desc
(
"Suppress diagnostics"
));
cl
::
alias
IsQuiet2
(
"q"
,
cl
::
desc
(
"Suppress diagnostics"
),
cl
::
aliasopt
(
IsQuiet
));
cl
::
opt
<
bool
>
OnlyCompile
(
"c"
,
cl
::
desc
(
"Run parser, type checker as well as LLVM "
"IR generation and create an object file."
"Does not perform linkage of binary"
));
cl
::
opt
<
bool
>
PrintIR
(
"S"
,
cl
::
desc
(
"Print outputed IR of compilation"
));
void
initCompilerInstance
(
CompilerInstance
&
C
)
{
CompilerInvocation
Inv
;
Inv
.
setArgs
(
C
.
getSourceManager
(),
C
.
getDiags
(),
InFile
,
OutFile
,
IsQuiet
);
Inv
.
setArgs
(
C
.
getSourceManager
(),
C
.
getDiags
(),
InFile
,
OutFile
,
IsQuiet
,
PrintIR
);
C
.
reset
(
std
::
move
(
Inv
));
}
...
...
@@ -33,5 +52,12 @@ int main(int argc, const char *argv[]) {
Compiler
.
performCompilation
();
if
(
!
OnlyCompile
&&
!
Compiler
.
getContext
().
isError
())
{
auto
Cmd
=
"clang++ "
+
Compiler
.
getInputFile
()
->
file
()
+
".o "
+
"-L$DUSK_STDLIB_PATH -lstddusk -o"
+
OutFile
;
system
(
Cmd
.
c_str
());
}
return
0
;
}
This diff is collapsed.
Click to expand it.
tools/duskc/main.cpp
+
32
−
4
View file @
84b8efb2
//===--- main.cpp - Dusk source formatter -----------------------*- C++ -*-===//
//
// dusk-lang
// This source file is part of a dusk-lang project, which is a semestral
// assignement for BI-PJP course at Czech Technical University in Prague.
// The software is provided "AS IS", WITHOUT WARRANTY OF ANY KIND.
//
//===----------------------------------------------------------------------===//
#include
"dusk/Basic/LLVM.h"
#include
"dusk/Frontend/CompilerInvocation.h"
#include
"dusk/Frontend/CompilerInstance.h"
#include
"dusk/AST/ASTPrinter.h"
#include
"dusk/Frontend/Formatter.h"
#include
"llvm/ADT/StringRef.h"
#include
"llvm/Support/CommandLine.h"
#include
"llvm/Support/raw_os_ostream.h"
#include
<iostream>
#include
<string>
...
...
@@ -15,15 +26,29 @@ using namespace llvm;
cl
::
opt
<
std
::
string
>
InFile
(
cl
::
Positional
,
cl
::
Required
,
cl
::
desc
(
"<input file>"
),
cl
::
init
(
"-"
));
cl
::
opt
<
std
::
string
>
OutFile
(
"o"
,
cl
::
desc
(
"Specify output filename"
),
cl
::
value_desc
(
"<filename>"
));
cl
::
opt
<
unsigned
>
SpaceLen
(
"indent-size"
,
cl
::
desc
(
"Indenetation size. Aplicable only when "
"idending with spaces. Default indentation"
"is 4 spaces."
),
cl
::
init
(
4
));
cl
::
opt
<
IndKind
>
IndentationType
(
"indent-type"
,
cl
::
desc
(
"Indentation type. Choose wheather to ident with "
"spaces or tabs. By default formatter indent with"
"spaces."
),
cl
::
values
(
clEnumVal
(
IndKind
::
Space
,
"Indent with spaces."
),
clEnumVal
(
IndKind
::
Tab
,
"Indent with tabs."
)),
cl
::
init
(
IndKind
::
Space
));
cl
::
opt
<
bool
>
IsQuiet
(
"quiet"
,
cl
::
desc
(
"Suppress diagnostics"
));
cl
::
alias
IsQuiet2
(
"q"
,
cl
::
desc
(
"Suppress diagnostics"
),
cl
::
aliasopt
(
IsQuiet
));
void
initCompilerInstance
(
CompilerInstance
&
C
)
{
CompilerInvocation
Inv
;
Inv
.
setArgs
(
C
.
getSourceManager
(),
C
.
getDiags
(),
InFile
,
OutFile
,
IsQuiet
);
Inv
.
setArgs
(
C
.
getSourceManager
(),
C
.
getDiags
(),
InFile
,
""
,
IsQuiet
,
false
);
C
.
reset
(
std
::
move
(
Inv
));
}
...
...
@@ -34,7 +59,10 @@ int main(int argc, const char *argv[]) {
Compiler
.
performParseOnly
();
if
(
Compiler
.
hasASTContext
()
&&
!
Compiler
.
getContext
().
isError
())
{
Formatter
F
(
Compiler
.
getContext
(),
llvm
::
errs
());
llvm
::
raw_os_ostream
OS
(
std
::
cout
);
Formatter
F
(
Compiler
.
getContext
(),
OS
);
F
.
setIndentSize
(
SpaceLen
);
F
.
setIndentType
(
IndentationType
);
F
.
format
();
return
0
;
}
else
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment