Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
desolation
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
Container 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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Owen Hayes
desolation
Commits
a9eea125
Commit
a9eea125
authored
2 years ago
by
MarvelousAnything
Browse files
Options
Downloads
Patches
Plain Diff
Worked on ast.
parent
24a472be
No related branches found
No related tags found
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
examples/lex.rs
+3
-0
3 additions, 0 deletions
examples/lex.rs
src/ast/mod.rs
+21
-1
21 additions, 1 deletion
src/ast/mod.rs
src/ast/node.rs
+0
-12
0 additions, 12 deletions
src/ast/node.rs
src/lib.rs
+1
-0
1 addition, 0 deletions
src/lib.rs
src/parser/mod.rs
+12
-0
12 additions, 0 deletions
src/parser/mod.rs
with
37 additions
and
13 deletions
examples/lex.rs
+
3
−
0
View file @
a9eea125
...
...
@@ -11,6 +11,9 @@ fn main() {
let
tokens
=
lexer
.lex
(
source
);
match
tokens
{
Ok
(
tokens
)
=>
{
for
token
in
&
tokens
.tokens
{
info!
(
"{:?}"
,
token
);
}
println!
(
"Keywords:
\n
{}"
,
tokens
.get_keywords
());
println!
(
"Identifiers:
\n
{}"
,
tokens
.get_identifiers
());
println!
(
"Integers:
\n
{}"
,
tokens
.get_integer_literals
());
...
...
This diff is collapsed.
Click to expand it.
src/ast/mod.rs
+
21
−
1
View file @
a9eea125
mod
node
;
// mod node;
//
// pub enum Program {
// VarList(Vec<Var>),
// FunList(Vec<Fun>),
// }
//
// pub struct ID {
// pub name: String,
// }
//
// pub struct Var {
// pub name: String,
// pub value: Option<Expr>,
// }
//
// pub struct Fun {
// pub name: String,
// pub params: Vec<ID>,
// pub body: Vec<Stmt>,
// }
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/ast/node.rs
+
0
−
12
View file @
a9eea125
pub
struct
Node
<
'a
>
{
pub
op
:
i32
,
pub
val
:
String
,
pub
sym
:
IdList
,
pub
fnum
:
i32
,
pub
line_no
:
i32
,
pub
left
:
&
'a
Node
<
'a
>
,
pub
right
:
&
'a
Node
<
'a
>
,
pub
next
:
&
'a
Node
<
'a
>
,
}
pub
struct
IdList
{}
This diff is collapsed.
Click to expand it.
src/lib.rs
+
1
−
0
View file @
a9eea125
mod
ast
;
pub
mod
lex
;
mod
parser
;
extern
crate
pretty_env_logger
;
#[macro_use]
extern
crate
log
;
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/parser/mod.rs
0 → 100644
+
12
−
0
View file @
a9eea125
use
crate
::
lex
::
lexer
::
TokenStream
;
pub
struct
Parser
{
tokens
:
TokenStream
,
}
impl
Parser
{
// This should parse a token stream into an AST.
pub
fn
parse
(
tokens
:
TokenStream
)
{
todo!
(
"Implement parser"
);
}
}
\ No newline at end of file
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