Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
erode
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Per Lindgren
erode
Commits
dc365160
Commit
dc365160
authored
4 years ago
by
Per Lindgren
Browse files
Options
Downloads
Patches
Plain Diff
move to new syntax, wip7 broken
parent
2bb6b324
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/wip.rs
+3
-2
3 additions, 2 deletions
examples/wip.rs
src/ast.rs
+31
-2
31 additions, 2 deletions
src/ast.rs
with
34 additions
and
4 deletions
examples/wip.rs
+
3
−
2
View file @
dc365160
fn
main
()
{
fn
main
()
{
//
{}
{}
let
mut
a
=
5
;
let
mut
a
=
5
;
a
=
5
;
a
=
5
;
// a = { 7 }
a
=
{
7
};
a
=
if
true
{
7
}
else
{
5
}
}
}
fn
b
(
x
:
i32
)
->
i32
{
fn
b
(
x
:
i32
)
->
i32
{
...
...
This diff is collapsed.
Click to expand it.
src/ast.rs
+
31
−
2
View file @
dc365160
...
@@ -218,10 +218,18 @@ impl Stmts {
...
@@ -218,10 +218,18 @@ impl Stmts {
// set tab
// set tab
write!
(
fmt
,
"
\n
{}"
,
" "
.repeat
(
indent
+
4
))
?
;
write!
(
fmt
,
"
\n
{}"
,
" "
.repeat
(
indent
+
4
))
?
;
s
.ifmt
(
fmt
,
indent
+
4
)
?
;
s
.ifmt
(
fmt
,
indent
+
4
)
?
;
if
i
<
len
-
1
||
self
.ret
{
if
i
<
len
-
1
{
match
s
{
Stmt
::
Block
(
_
)
|
Stmt
::
If
(
_
,
_
,
_
)
=>
(),
_
=>
write!
(
fmt
,
";"
)
?
,
}
}
else
{
if
self
.ret
{
write!
(
fmt
,
";"
)
?
;
write!
(
fmt
,
";"
)
?
;
}
}
}
}
}
write!
(
fmt
,
"
\n
{}}}"
,
" "
.repeat
(
indent
))
write!
(
fmt
,
"
\n
{}}}"
,
" "
.repeat
(
indent
))
}
}
}
}
...
@@ -305,6 +313,7 @@ impl Display for Type {
...
@@ -305,6 +313,7 @@ impl Display for Type {
}
}
}
}
}
}
impl
Display
for
Expr
{
impl
Display
for
Expr
{
fn
fmt
(
&
self
,
fmt
:
&
mut
Formatter
)
->
Result
<
(),
Error
>
{
fn
fmt
(
&
self
,
fmt
:
&
mut
Formatter
)
->
Result
<
(),
Error
>
{
use
self
::
Expr
::
*
;
use
self
::
Expr
::
*
;
...
@@ -325,6 +334,26 @@ impl Display for Expr {
...
@@ -325,6 +334,26 @@ impl Display for Expr {
}
}
}
}
impl
Expr
{
fn
ifmt
(
&
self
,
fmt
:
&
mut
Formatter
,
indent
:
i32
)
->
Result
<
(),
Error
>
{
use
self
::
Expr
::
*
;
match
*
self
{
Num
(
n
)
=>
write!
(
fmt
,
"{}"
,
n
),
Bool
(
b
)
=>
write!
(
fmt
,
"{}"
,
b
),
Id
(
ref
s
)
=>
write!
(
fmt
,
"{}"
,
s
),
As
(
ref
e
,
ref
t
)
=>
write!
(
fmt
,
"{} as {}"
,
e
,
t
),
Infix
(
ref
l
,
ref
op
,
ref
r
)
=>
write!
(
fmt
,
"({} {} {})"
,
l
,
op
,
r
),
Prefix
(
ref
op
,
ref
r
)
=>
write!
(
fmt
,
"({} {})"
,
op
,
r
),
Ref
(
ref
e
)
=>
write!
(
fmt
,
"&{}"
,
e
),
RefMut
(
ref
e
)
=>
write!
(
fmt
,
"&mut {}"
,
e
),
DeRef
(
ref
e
)
=>
write!
(
fmt
,
"*{}"
,
e
),
Call
(
ref
s
,
ref
exprs
)
=>
write!
(
fmt
,
"{}{}"
,
s
,
exprs
),
Block
(
ref
s
)
=>
write!
(
fmt
,
"{}"
,
s
),
Stmt
(
ref
s
)
=>
write!
(
fmt
,
"{}"
,
s
),
}
}
}
impl
Display
for
Op
{
impl
Display
for
Op
{
fn
fmt
(
&
self
,
fmt
:
&
mut
Formatter
)
->
Result
<
(),
Error
>
{
fn
fmt
(
&
self
,
fmt
:
&
mut
Formatter
)
->
Result
<
(),
Error
>
{
use
self
::
Op
::
*
;
use
self
::
Op
::
*
;
...
...
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