Skip to content

Commit

Permalink
parser (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
StunxFS committed Nov 25, 2024
1 parent 234a8cd commit eb539bd
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 82 deletions.
20 changes: 14 additions & 6 deletions src/compiler/context/mod.v
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@

module context

@[heap]
pub struct CContext {
pub mut:
options Options
report Report
}
import ast

const stack = []&CContext{}

Expand All @@ -34,3 +29,16 @@ pub fn pop() {
_ = stack.pop()
}
}

@[heap]
pub struct CContext {
pub mut:
options Options
report Report

source_files []&ast.SourceFile
}

pub fn (mut ctx CContext) load_input() {
ctx.source_files << ast.SourceFile.new(ctx.options.input)
}
13 changes: 3 additions & 10 deletions src/compiler/mod.v
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
module compiler

import compiler.context
import compiler.tokenizer
import compiler.parser

pub fn run(args []string) {
mut c_ctx := &context.CContext{}
Expand All @@ -15,13 +15,6 @@ pub fn run(args []string) {

c_ctx.options = context.parse_args(args)

mut t := tokenizer.new(c_ctx)
mut tok := t.next()
for {
println('${tok} - ${tok.pos}')
tok = t.next()
if tok.kind == .eof {
break
}
}
mut p := parser.new(c_ctx)
p.parse()
}
Loading

0 comments on commit eb539bd

Please sign in to comment.