The Draconian compiler can now read a file.
A file can be read and placed into a Reader buffer for lexicographical analysis. This buffer can be consumed on a character by character basis.
This commit is contained in:
45
examples/compile.rs
Normal file
45
examples/compile.rs
Normal file
@ -0,0 +1,45 @@
|
||||
extern crate draconic;
|
||||
|
||||
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use draconic::Compiler;
|
||||
|
||||
|
||||
|
||||
///
|
||||
pub const RESOURCE_DIR: &'static str = "resources";
|
||||
|
||||
///
|
||||
pub const EXAMPLES_DIR: &'static str = "examples";
|
||||
|
||||
///
|
||||
pub const TEST_INPUT_FILENAME: &'static str = "test.drs";
|
||||
|
||||
///
|
||||
pub const TEST_OUTPUT_FILENAME: &'static str = "test.rs";
|
||||
|
||||
|
||||
|
||||
///
|
||||
pub fn main()
|
||||
{
|
||||
let mut input: PathBuf;
|
||||
let mut output: PathBuf;
|
||||
|
||||
// Get the input file to test with. It is in the
|
||||
// resources directory.
|
||||
input = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
input.push(RESOURCE_DIR);
|
||||
input.push(TEST_INPUT_FILENAME);
|
||||
|
||||
// The output file created from compiling. It will be
|
||||
// placed in the examples directory.
|
||||
output = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
output.push(EXAMPLES_DIR);
|
||||
output.push(TEST_OUTPUT_FILENAME);
|
||||
|
||||
println!("Compiling {:?} to {:?}", input, output);
|
||||
Compiler::compile(input, output);
|
||||
}
|
Reference in New Issue
Block a user