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
db2259b1
Commit
db2259b1
authored
Nov 17, 2022
by
MarvelousAnything
Browse files
Options
Downloads
Patches
Plain Diff
Did some work on the parser, ast, and lexer.
parent
0049eab5
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
.idea/sonarlint/issuestore/index.pb
+10
-0
10 additions, 0 deletions
.idea/sonarlint/issuestore/index.pb
src/ast/mod.rs
+29
-21
29 additions, 21 deletions
src/ast/mod.rs
src/lex/lexer.rs
+6
-0
6 additions, 0 deletions
src/lex/lexer.rs
src/parser/mod.rs
+25
-1
25 additions, 1 deletion
src/parser/mod.rs
with
70 additions
and
22 deletions
.idea/sonarlint/issuestore/index.pb
+
10
−
0
View file @
db2259b1
H
desolation-vm/src/lib.rs,d/2/d223e57cb8e5a300f8967d2aa903ba0ce9bb7fc0
A
src/lex/consts.rs,d/6/d6ac01c8a58d9dff09212d8593829096a491440e
:
Cargo.toml,1/b/1b290eb385892bfd4870c08a785598e98c8691b7
@
src/lex/token.rs,e/f/ef992bfb55ea19c324d0baced9107bb35e7403e4
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/ast/mod.rs
+
29
−
21
View file @
db2259b1
// mod node;
mod
node
;
//
// pub enum Program {
pub
enum
Program
{
// VarList(Vec<Var>),
VarList
(
Vec
<
Var
>
),
// FunList(Vec<Fun>),
FunList
(
Vec
<
Fun
>
),
// }
}
//
// pub struct ID {
pub
struct
ID
{
// pub name: String,
pub
name
:
String
,
// }
}
//
// pub struct Var {
pub
struct
Var
{
// pub name: String,
pub
name
:
String
,
// pub value: Option<Expr>,
pub
value
:
Option
<
Expr
>
,
// }
}
//
// pub struct Fun {
pub
struct
Expr
{
// pub name: String,
// pub params: Vec<ID>,
}
// pub body: Vec<Stmt>,
// }
pub
struct
Fun
{
pub
name
:
String
,
pub
params
:
Vec
<
ID
>
,
pub
body
:
Vec
<
Stmt
>
,
}
pub
struct
Stmt
{
}
This diff is collapsed.
Click to expand it.
src/lex/lexer.rs
+
6
−
0
View file @
db2259b1
...
@@ -93,6 +93,12 @@ impl TokenStream {
...
@@ -93,6 +93,12 @@ impl TokenStream {
.cloned
()
.cloned
()
.collect
::
<
TokenStream
>
()
.collect
::
<
TokenStream
>
()
}
}
pub
fn
reverse
(
&
self
)
->
Self
{
let
mut
tokens
=
self
.tokens
.clone
();
tokens
.reverse
();
TokenStream
{
tokens
}
}
}
}
impl
FromIterator
<
Token
>
for
TokenStream
{
impl
FromIterator
<
Token
>
for
TokenStream
{
...
...
This diff is collapsed.
Click to expand it.
src/parser/mod.rs
+
25
−
1
View file @
db2259b1
use
thiserror
::
Error
;
use
anyhow
::{
bail
,
ensure
,
Result
};
use
crate
::
ast
;
use
crate
::
ast
::
Program
;
use
crate
::
lex
::
lexer
::
TokenStream
;
use
crate
::
lex
::
lexer
::
TokenStream
;
use
crate
::
lex
::
token
::
Token
;
#[derive(Debug,
Error)]
enum
ParseError
{
#[error(
"Unexpected token"
)]
UnexpectedToken
,
#[error(
"Unexpected end of file"
)]
UnexpectedEOF
,
}
pub
struct
Parser
{
pub
struct
Parser
{
tokens
:
TokenStream
,
tokens
:
TokenStream
,
stack
:
Vec
<
Token
>
}
pub
enum
ParserActions
{
Shift
,
Reduce
(
usize
),
Accept
,
}
}
impl
Parser
{
impl
Parser
{
pub
fn
new
(
tokens
:
TokenStream
)
->
Self
{
Self
{
tokens
,
stack
:
vec!
[]
}
}
// This should parse a token stream into an AST.
// This should parse a token stream into an AST.
pub
fn
parse
(
_tokens
:
TokenStre
am
)
{
pub
fn
parse
(
&
mut
self
)
->
Result
<
Progr
am
>
{
todo!
(
"Implement parser"
);
todo!
(
"Implement parser"
);
}
}
}
}
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
sign in
to comment