|
|
|
@ -19,9 +19,17 @@ pub fn parse(file_path: &str) {
|
|
|
|
|
for token in line.into_inner() {
|
|
|
|
|
match token.as_rule() {
|
|
|
|
|
Rule::token => {
|
|
|
|
|
let token = token.into_inner().next().unwrap();
|
|
|
|
|
let token = token.into_inner().next().unwrap();
|
|
|
|
|
match token.as_rule() {
|
|
|
|
|
Rule::string => println!("string: {}", token.as_str()),
|
|
|
|
|
Rule::string => {
|
|
|
|
|
let string_data = token.into_inner().next().unwrap();
|
|
|
|
|
let str = string_data.as_str();
|
|
|
|
|
println!("string: {}", match string_data.as_rule() {
|
|
|
|
|
Rule::single_quote_string_data => str.replace("\\'", "'"),
|
|
|
|
|
Rule::double_quote_string_data => str.replace("\\\"", "\""),
|
|
|
|
|
_ => unreachable!(),
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
Rule::keyword => println!("keyword: {}", token.as_str()),
|
|
|
|
|
_ => unreachable!(),
|
|
|
|
|
};
|
|
|
|
|