mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-07-07 17:04:59 +00:00
Support no_std
(#332)
* Support `no_std` Signed-off-by: koushiro <koushiro.cqx@gmail.com> * Fix typo Signed-off-by: koushiro <koushiro.cqx@gmail.com>
This commit is contained in:
parent
293133f910
commit
5bc109a7ad
13 changed files with 71 additions and 14 deletions
10
.github/workflows/rust.yml
vendored
10
.github/workflows/rust.yml
vendored
|
@ -35,6 +35,16 @@ jobs:
|
|||
- uses: actions/checkout@master
|
||||
- run: cargo check --all-targets --all-features
|
||||
|
||||
compile-no-std:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Set up Rust
|
||||
uses: hecrj/setup-rust-action@v1
|
||||
with:
|
||||
targets: 'thumbv6m-none-eabi'
|
||||
- uses: actions/checkout@master
|
||||
- run: cargo check --no-default-features --target thumbv6m-none-eabi
|
||||
|
||||
test:
|
||||
strategy:
|
||||
matrix:
|
||||
|
|
|
@ -13,12 +13,15 @@ include = [
|
|||
"Cargo.toml",
|
||||
]
|
||||
edition = "2018"
|
||||
resolver = "2"
|
||||
|
||||
[lib]
|
||||
name = "sqlparser"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = []
|
||||
# Enable JSON output in the `cli` example:
|
||||
json_example = ["serde_json", "serde"]
|
||||
|
||||
|
|
|
@ -10,7 +10,9 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use std::fmt;
|
||||
#[cfg(not(feature = "std"))]
|
||||
use alloc::boxed::Box;
|
||||
use core::fmt;
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
|
|
@ -13,7 +13,9 @@
|
|||
//! AST types specific to CREATE/ALTER variants of [Statement]
|
||||
//! (commonly referred to as Data Definition Language, or DDL)
|
||||
|
||||
use std::fmt;
|
||||
#[cfg(not(feature = "std"))]
|
||||
use alloc::{boxed::Box, string::ToString, vec::Vec};
|
||||
use core::fmt;
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
|
|
@ -18,7 +18,13 @@ mod operator;
|
|||
mod query;
|
||||
mod value;
|
||||
|
||||
use std::fmt;
|
||||
#[cfg(not(feature = "std"))]
|
||||
use alloc::{
|
||||
boxed::Box,
|
||||
string::{String, ToString},
|
||||
vec::Vec,
|
||||
};
|
||||
use core::fmt;
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use std::fmt;
|
||||
use core::fmt;
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
use alloc::{boxed::Box, vec::Vec};
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
|
|
@ -10,7 +10,9 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use std::fmt;
|
||||
#[cfg(not(feature = "std"))]
|
||||
use alloc::string::String;
|
||||
use core::fmt;
|
||||
|
||||
#[cfg(feature = "bigdecimal")]
|
||||
use bigdecimal::BigDecimal;
|
||||
|
|
|
@ -20,8 +20,8 @@ mod postgresql;
|
|||
mod snowflake;
|
||||
mod sqlite;
|
||||
|
||||
use std::any::{Any, TypeId};
|
||||
use std::fmt::Debug;
|
||||
use core::any::{Any, TypeId};
|
||||
use core::fmt::Debug;
|
||||
|
||||
pub use self::ansi::AnsiDialect;
|
||||
pub use self::generic::GenericDialect;
|
||||
|
|
|
@ -32,8 +32,13 @@
|
|||
//!
|
||||
//! println!("AST: {:?}", ast);
|
||||
//! ```
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
#![allow(clippy::upper_case_acronyms)]
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
extern crate alloc;
|
||||
|
||||
pub mod ast;
|
||||
#[macro_use]
|
||||
pub mod dialect;
|
||||
|
|
|
@ -12,8 +12,15 @@
|
|||
|
||||
//! SQL Parser
|
||||
|
||||
use std::error::Error;
|
||||
use std::fmt;
|
||||
#[cfg(not(feature = "std"))]
|
||||
use alloc::{
|
||||
boxed::Box,
|
||||
format,
|
||||
string::{String, ToString},
|
||||
vec,
|
||||
vec::Vec,
|
||||
};
|
||||
use core::fmt;
|
||||
|
||||
use log::debug;
|
||||
|
||||
|
@ -81,7 +88,8 @@ impl fmt::Display for ParserError {
|
|||
}
|
||||
}
|
||||
|
||||
impl Error for ParserError {}
|
||||
#[cfg(feature = "std")]
|
||||
impl std::error::Error for ParserError {}
|
||||
|
||||
pub struct Parser<'a> {
|
||||
tokens: Vec<Token>,
|
||||
|
|
|
@ -16,7 +16,15 @@
|
|||
//
|
||||
// Integration tests (i.e. everything under `tests/`) import this
|
||||
// via `tests/test_utils/mod.rs`.
|
||||
use std::fmt::Debug;
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
use alloc::{
|
||||
boxed::Box,
|
||||
string::{String, ToString},
|
||||
vec,
|
||||
vec::Vec,
|
||||
};
|
||||
use core::fmt::Debug;
|
||||
|
||||
use crate::ast::*;
|
||||
use crate::dialect::*;
|
||||
|
|
|
@ -16,9 +16,17 @@
|
|||
//!
|
||||
//! The tokens then form the input for the parser, which outputs an Abstract Syntax Tree (AST).
|
||||
|
||||
use std::fmt;
|
||||
use std::iter::Peekable;
|
||||
use std::str::Chars;
|
||||
#[cfg(not(feature = "std"))]
|
||||
use alloc::{
|
||||
borrow::ToOwned,
|
||||
format,
|
||||
string::{String, ToString},
|
||||
vec,
|
||||
vec::Vec,
|
||||
};
|
||||
use core::fmt;
|
||||
use core::iter::Peekable;
|
||||
use core::str::Chars;
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue