mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-22 23:14:07 +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
|
- uses: actions/checkout@master
|
||||||
- run: cargo check --all-targets --all-features
|
- 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:
|
test:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
|
|
|
@ -13,12 +13,15 @@ include = [
|
||||||
"Cargo.toml",
|
"Cargo.toml",
|
||||||
]
|
]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
resolver = "2"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "sqlparser"
|
name = "sqlparser"
|
||||||
path = "src/lib.rs"
|
path = "src/lib.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
default = ["std"]
|
||||||
|
std = []
|
||||||
# Enable JSON output in the `cli` example:
|
# Enable JSON output in the `cli` example:
|
||||||
json_example = ["serde_json", "serde"]
|
json_example = ["serde_json", "serde"]
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,9 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
use std::fmt;
|
#[cfg(not(feature = "std"))]
|
||||||
|
use alloc::boxed::Box;
|
||||||
|
use core::fmt;
|
||||||
|
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
|
@ -13,7 +13,9 @@
|
||||||
//! AST types specific to CREATE/ALTER variants of [Statement]
|
//! AST types specific to CREATE/ALTER variants of [Statement]
|
||||||
//! (commonly referred to as Data Definition Language, or DDL)
|
//! (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")]
|
#[cfg(feature = "serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
|
@ -18,7 +18,13 @@ mod operator;
|
||||||
mod query;
|
mod query;
|
||||||
mod value;
|
mod value;
|
||||||
|
|
||||||
use std::fmt;
|
#[cfg(not(feature = "std"))]
|
||||||
|
use alloc::{
|
||||||
|
boxed::Box,
|
||||||
|
string::{String, ToString},
|
||||||
|
vec::Vec,
|
||||||
|
};
|
||||||
|
use core::fmt;
|
||||||
|
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
use std::fmt;
|
use core::fmt;
|
||||||
|
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
#[cfg(not(feature = "std"))]
|
||||||
|
use alloc::{boxed::Box, vec::Vec};
|
||||||
|
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,9 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
use std::fmt;
|
#[cfg(not(feature = "std"))]
|
||||||
|
use alloc::string::String;
|
||||||
|
use core::fmt;
|
||||||
|
|
||||||
#[cfg(feature = "bigdecimal")]
|
#[cfg(feature = "bigdecimal")]
|
||||||
use bigdecimal::BigDecimal;
|
use bigdecimal::BigDecimal;
|
||||||
|
|
|
@ -20,8 +20,8 @@ mod postgresql;
|
||||||
mod snowflake;
|
mod snowflake;
|
||||||
mod sqlite;
|
mod sqlite;
|
||||||
|
|
||||||
use std::any::{Any, TypeId};
|
use core::any::{Any, TypeId};
|
||||||
use std::fmt::Debug;
|
use core::fmt::Debug;
|
||||||
|
|
||||||
pub use self::ansi::AnsiDialect;
|
pub use self::ansi::AnsiDialect;
|
||||||
pub use self::generic::GenericDialect;
|
pub use self::generic::GenericDialect;
|
||||||
|
|
|
@ -32,8 +32,13 @@
|
||||||
//!
|
//!
|
||||||
//! println!("AST: {:?}", ast);
|
//! println!("AST: {:?}", ast);
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
#![allow(clippy::upper_case_acronyms)]
|
#![allow(clippy::upper_case_acronyms)]
|
||||||
|
|
||||||
|
#[cfg(not(feature = "std"))]
|
||||||
|
extern crate alloc;
|
||||||
|
|
||||||
pub mod ast;
|
pub mod ast;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub mod dialect;
|
pub mod dialect;
|
||||||
|
|
|
@ -12,8 +12,15 @@
|
||||||
|
|
||||||
//! SQL Parser
|
//! SQL Parser
|
||||||
|
|
||||||
use std::error::Error;
|
#[cfg(not(feature = "std"))]
|
||||||
use std::fmt;
|
use alloc::{
|
||||||
|
boxed::Box,
|
||||||
|
format,
|
||||||
|
string::{String, ToString},
|
||||||
|
vec,
|
||||||
|
vec::Vec,
|
||||||
|
};
|
||||||
|
use core::fmt;
|
||||||
|
|
||||||
use log::debug;
|
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> {
|
pub struct Parser<'a> {
|
||||||
tokens: Vec<Token>,
|
tokens: Vec<Token>,
|
||||||
|
|
|
@ -16,7 +16,15 @@
|
||||||
//
|
//
|
||||||
// Integration tests (i.e. everything under `tests/`) import this
|
// Integration tests (i.e. everything under `tests/`) import this
|
||||||
// via `tests/test_utils/mod.rs`.
|
// 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::ast::*;
|
||||||
use crate::dialect::*;
|
use crate::dialect::*;
|
||||||
|
|
|
@ -16,9 +16,17 @@
|
||||||
//!
|
//!
|
||||||
//! The tokens then form the input for the parser, which outputs an Abstract Syntax Tree (AST).
|
//! The tokens then form the input for the parser, which outputs an Abstract Syntax Tree (AST).
|
||||||
|
|
||||||
use std::fmt;
|
#[cfg(not(feature = "std"))]
|
||||||
use std::iter::Peekable;
|
use alloc::{
|
||||||
use std::str::Chars;
|
borrow::ToOwned,
|
||||||
|
format,
|
||||||
|
string::{String, ToString},
|
||||||
|
vec,
|
||||||
|
vec::Vec,
|
||||||
|
};
|
||||||
|
use core::fmt;
|
||||||
|
use core::iter::Peekable;
|
||||||
|
use core::str::Chars;
|
||||||
|
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue