Fix #12 and bump version

This commit is contained in:
Jethro Beekman
2019-01-15 22:43:56 +05:30
parent 1de17f5710
commit 008b808e6b
4 changed files with 19 additions and 4 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
[package]
name = "cexpr"
version = "0.3.3"
version = "0.3.4"
authors = ["Jethro Beekman <jethro@jbeekman.nl>"]
license = "Apache-2.0/MIT"
description = "A C expression parser and evaluator"
@@ -12,4 +12,4 @@ keywords = ["C","expression","parser"]
nom = {version = "^4", features = ["verbose-errors"] }
[dev-dependencies]
clang-sys = ">= 0.13.0, < 0.27.0"
clang-sys = ">= 0.13.0, < 0.28.0"
+1 -1
View File
@@ -195,7 +195,7 @@ named!(c_string<Vec<u8> >,
delimited!(
alt!( preceded!(c_width_prefix,char!('"')) | char!('"') ),
fold_many0!(
alt!(map!(escaped_char, |c:CChar| c.into()) | map!(complete!(is_not!("\"")), |c: &[u8]| c.into())),
alt!(map!(escaped_char, |c:CChar| c.into()) | map!(is_not!([b'\\', b'"']), |c: &[u8]| c.into())),
Vec::new(),
|mut v: Vec<u8>, res:Vec<u8>| { v.extend_from_slice(&res); v }
),
+11 -1
View File
@@ -9,6 +9,7 @@ extern crate cexpr;
extern crate clang_sys;
use std::{ptr,mem,ffi,slice,char};
use std::io::Write;
use std::str::{self,FromStr};
use std::collections::HashMap;
@@ -50,7 +51,16 @@ fn test_definition(ident: Vec<u8>, tokens: &[Token], idents: &mut HashMap<Vec<u8
}
if expected==b"Str" {
Some(Str(value.to_owned()))
let mut splits=value.split(|c|*c==b'U');
let mut s=Vec::with_capacity(value.len());
s.extend_from_slice(splits.next().unwrap());
for split in splits {
let (chr,rest) = split.split_at(6);
let chr=u32::from_str_radix(str::from_utf8(chr).unwrap(),16).unwrap();
write!(s,"{}",char::from_u32(chr).unwrap()).unwrap();
s.extend_from_slice(rest);
}
Some(Str(s))
} else if expected==b"Int" {
bytes_to_int(value)
} else if expected==b"Float" {
+5
View File
@@ -5,6 +5,11 @@
#define Str_concat u"con" L"cat"
#define Str_concat_parens ("concat" U"_parens")
#define Str_concat_identifier (Str_concat L"_identifier")
#define Str_hex_escape_all "\x68\x65\x78\x5f\x65\x73\x63\x61\x70\x65\x5f\x61\x6c\x6c"
#define Str_hex_escape_hex "h\x65x_\x65s\x63\x61p\x65_h\x65x"
#define Str_quote_U000022_escape "quote_\"_escape"
#define Str_Fly_away_in_my_space_U01F680_You_no_need_put_U01F4B5_in_my_pocket \
u8"Fly_away_in_my_space_🚀_You_no_need_put_💵_in_my_pocket"
#define Fn_Str_no_args() "no_args"
#define Fn_Str_no_args_concat() "no_args_" Str_concat
#define Fn_Str_prepend_arg(arg) "prepend_" arg