forked from M-Labs/nac3
change the symbol resolver back and add some test case
This commit is contained in:
parent
512fc59281
commit
9603aa644a
@ -659,6 +659,9 @@ pub mod test {
|
|||||||
#[test_case("1 if True else False")]
|
#[test_case("1 if True else False")]
|
||||||
#[test_case("1 and 2")]
|
#[test_case("1 and 2")]
|
||||||
#[test_case("False or 1")]
|
#[test_case("False or 1")]
|
||||||
|
#[test_case("1 + False")]
|
||||||
|
#[test_case("1 < 2 > False")]
|
||||||
|
#[test_case("not 2")]
|
||||||
fn test_err_msg(prog: &'static str) {
|
fn test_err_msg(prog: &'static str) {
|
||||||
let mut inf = new_ctx();
|
let mut inf = new_ctx();
|
||||||
let ast = rustpython_parser::parser::parse_expression(prog).unwrap();
|
let ast = rustpython_parser::parser::parse_expression(prog).unwrap();
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
use super::typedef::Type;
|
use super::typedef::Type;
|
||||||
use super::location::Location;
|
use super::location::Location;
|
||||||
use rustpython_parser::ast::Expr;
|
|
||||||
|
pub enum SymbolType {
|
||||||
|
TypeName(Type),
|
||||||
|
Identifier(Type),
|
||||||
|
}
|
||||||
|
|
||||||
pub enum SymbolValue<'a> {
|
pub enum SymbolValue<'a> {
|
||||||
I32(i32),
|
I32(i32),
|
||||||
I64(i64),
|
I64(i64),
|
||||||
@ -9,10 +14,10 @@ pub enum SymbolValue<'a> {
|
|||||||
Tuple(&'a [SymbolValue<'a>]),
|
Tuple(&'a [SymbolValue<'a>]),
|
||||||
Bytes(&'a [u8]),
|
Bytes(&'a [u8]),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait SymbolResolver {
|
pub trait SymbolResolver {
|
||||||
fn get_symbol_type(&mut self, str: &str) -> Option<Type>;
|
fn get_symbol_type(&self, str: &str) -> Option<SymbolType>;
|
||||||
fn parse_type_name(&mut self, expr: &Expr<()>) -> Option<Type>;
|
fn get_symbol_value(&self, str: &str) -> Option<SymbolValue>;
|
||||||
fn get_symbol_value(&mut self, str: &str) -> Option<SymbolValue>;
|
fn get_symbol_location(&self, str: &str) -> Option<Location>;
|
||||||
fn get_symbol_location(&mut self, str: &str) -> Option<Location>;
|
|
||||||
// handle function call etc.
|
// handle function call etc.
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user