diff --git a/Cargo.toml b/Cargo.toml index 75c1d61..aaa903e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,20 +1,20 @@ [package] name = "ratisui" -version = "0.1.2" +version = "0.1.7" edition = "2021" authors = ["honhimw "] rust-version = "1.81.0" build = "build.rs" [workspace] -members = ["ratisui-deadpool-redis", "ratisui-jaded", "ratisui-tree-sitter-ron"] +members = ["ratisui-deadpool-redis"] [workspace.dependencies] log = "0.4" redis = "0.27" serde = "1" tokio = "1" -tree-sitter = "0.23" +tree-sitter = "0.24" [dependencies] anyhow = "1" @@ -59,14 +59,16 @@ unicode-width = "0.2.0" once_cell = "1" futures = "0.3" -jaded = { path = "ratisui-jaded", features = ["serde"] } +jaded = { version = "0.5.0", features = ["serde"] } protobuf = { version = "3.7.1" } tree-sitter = { workspace = true} -tree-sitter-highlight = "0.23" -tree-sitter-json = "0.23" -tree-sitter-html = "0.23" -tree-sitter-ron = { path = "ratisui-tree-sitter-ron" } +tree-sitter-highlight = "0.24" +tree-sitter-json = "0.24" +tree-sitter-html = { git = "https://github.com/honhimW/tree-sitter-html" } +tree-sitter-ron = { git = "https://github.com/honhimW/tree-sitter-ron" } +#tree-sitter-html = "0.23" +#tree-sitter-ron = { path = "ratisui-tree-sitter-ron" } russh = { version = "0.46", default-features = false } async-trait = "0.1.83" # git crates diff --git a/examples/ssh_tunnel.rs b/examples/ssh_tunnel.rs index 27dd709..31a3c27 100644 --- a/examples/ssh_tunnel.rs +++ b/examples/ssh_tunnel.rs @@ -10,6 +10,7 @@ use redis::cmd; use russh::client::Handler; use russh::keys::key; use std::ops::Deref; +use std::string::ToString; const SSH_HOST: &str = "10.37.1.133"; const SSH_PORT: u16 = 22; @@ -18,8 +19,8 @@ const SSH_PASSWORD: &str = "123"; const REDIS_HOST: &str = "redis-16430.c1.asia-northeast1-1.gce.redns.redis-cloud.com"; const REDIS_PORT: u16 = 16430; -const REDIS_USER: Some(String) = Some(String::from("default")); -const REDIS_PASSWORD: Some(String) = Some(String::from("9JRCAjglNSTc4pXWOggLT7BKljwuoSSy")); +const REDIS_USER: &str = "default"; +const REDIS_PASSWORD: &str = "9JRCAjglNSTc4pXWOggLT7BKljwuoSSy"; const LOCAL_HOST: &str = "127.0.0.1"; @@ -50,8 +51,8 @@ async fn main() -> Result<()> { let pool = build_pool(common::client::Config { host: addr.ip().to_string(), port: addr.port(), - username: REDIS_USER.deref().clone(), - password: REDIS_PASSWORD.deref().clone(), + username: Some(REDIS_USER.to_string()), + password: Some(REDIS_PASSWORD.to_string()), ..Default::default() })?; let mut connection = pool.get().await?; diff --git a/ratisui-deadpool-redis/src/lib.rs b/ratisui-deadpool-redis/src/lib.rs index 3f60bfe..913000b 100644 --- a/ratisui-deadpool-redis/src/lib.rs +++ b/ratisui-deadpool-redis/src/lib.rs @@ -175,7 +175,7 @@ impl managed::Manager for Manager { } /// Pretty format human readable redis command. -pub fn format_cmd(cmd: &Cmd) -> String { +fn format_cmd(cmd: &Cmd) -> String { let mut s = String::new(); for x in cmd.args_iter() { match x { diff --git a/ratisui-deadpool-redis/src/sentinel/mod.rs b/ratisui-deadpool-redis/src/sentinel/mod.rs index b388ff9..159f28f 100644 --- a/ratisui-deadpool-redis/src/sentinel/mod.rs +++ b/ratisui-deadpool-redis/src/sentinel/mod.rs @@ -10,12 +10,12 @@ use redis::sentinel::{SentinelClient, SentinelNodeConnectionInfo}; use redis::{aio::ConnectionLike, IntoConnectionInfo, RedisError, RedisResult}; use tokio::sync::Mutex; +pub use self::config::{Config, ConfigError}; +use crate::log_cmd; pub use crate::sentinel::config::SentinelServerType; use deadpool::managed; pub use deadpool::managed::reexports::*; -pub use self::config::{Config, ConfigError}; - mod config; deadpool::managed_reexports!( diff --git a/ratisui-jaded/Cargo.toml b/ratisui-jaded/Cargo.toml deleted file mode 100644 index 1ae129e..0000000 --- a/ratisui-jaded/Cargo.toml +++ /dev/null @@ -1,48 +0,0 @@ -# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO -# -# When uploading crates to the registry Cargo will automatically -# "normalize" Cargo.toml files for maximal compatibility -# with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies. -# -# If you are reading this file be aware that the original Cargo.toml -# will likely look very different (and much more reasonable). -# See Cargo.toml.orig for the original contents. - -[package] -edition = "2018" -name = "jaded" -version = "0.4.0" -authors = ["Peter Holloway "] -description = "Java deserialization for Rust" -homepage = "https://gitlab.com/woollyGibbon/jaded" -readme = "README.md" -keywords = [ - "Java", - "Deserialization", -] -categories = [ - "parser-implementations", - "encoding", -] -license = "MIT" -repository = "https://gitlab.com/woollyGibbon/jaded" - -[dependencies.serde] -workspace = true -features = ["derive"] -optional = true - -[dependencies.jaded-derive] -version = "0.2" -optional = true - -[dependencies.thiserror] -version = "1.0.23" - -[features] -derive = ["jaded-derive"] -renaming = ["jaded-derive/renaming"] -serde = [ - "dep:serde", -] \ No newline at end of file diff --git a/ratisui-jaded/src/annotations.rs b/ratisui-jaded/src/annotations.rs deleted file mode 100644 index b1e7bab..0000000 --- a/ratisui-jaded/src/annotations.rs +++ /dev/null @@ -1,283 +0,0 @@ -use super::{Content, ConversionError, ConversionResult, FromJava, Value}; -use std::convert::TryInto; - -enum AnnotationReadState<'a> { - Complete, - Value(&'a Value), - Block(&'a [u8]), -} - -impl<'a> AnnotationReadState<'a> { - fn switch(&mut self, next: &'a Content) { - *self = match next { - Content::Block(d) => Self::Block(&d[..]), - Content::Object(v) => Self::Value(v), - } - } -} - -/// Utility for reading things from annotations -/// -/// This is intended to offer a similar interface to the ObjectInputStream used -/// by Java classes that implement custom readObject methods. -pub struct AnnotationIter<'a> { - values: Vec<&'a Content>, - state: AnnotationReadState<'a>, -} - -impl<'a> AnnotationIter<'a> { - pub(crate) fn new(values: &'a [Content]) -> Self { - use AnnotationReadState::*; - let state = match values.first() { - Some(Content::Block(d)) => Block(&d[..]), - Some(Content::Object(v)) => Value(v), - None => Complete, - }; - AnnotationIter { - values: values.iter().skip(1).collect::>(), - state, - } - } - - fn advance(&mut self) { - use AnnotationReadState::*; - match (self.values.len(), &self.state) { - (0, Complete) => (), // End of iteration - nothing to do - (0, Block(d)) if d.is_empty() => self.state = Complete, - (0, Value(_)) => self.state = Complete, - (_, Block(d)) if d.is_empty() => self.state.switch(self.values.remove(0)), - (_, Value(_)) => self.state.switch(self.values.remove(0)), - (_, Block(_)) => (), // mid block - nothing to do - (_, Complete) => panic!("Annotations complete while contents remain"), - } - } - - fn read_bytes(&mut self, count: usize) -> ConversionResult - where - T: std::convert::TryFrom<&'a [u8]>, - { - self.advance(); - use AnnotationReadState::*; - match self.state { - Block(d) if d.len() >= count => { - let (l, r) = d.split_at(count); - self.state = Block(r); - Ok(l.try_into() - .map_err(|_| ConversionError::InvalidType("integer data"))?) - } - Block(_) => Err(ConversionError::InvalidType("Not enough data")), - Value(_) => Err(ConversionError::InvalidType("Expected block data")), - Complete => Err(ConversionError::InvalidType("End of Annotations")), - } - } - - /// Read byte from annotation - /// # Errors - /// [ConversionError::InvalidType] - /// * if there is not enough data - /// * if the next item in the annotation is an - /// object instead of binary data. - /// # See - /// [ObjectInputStream#readByte()](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/ObjectInputStream.html#readByte()) - pub fn read_u8(&mut self) -> ConversionResult { - Ok(self.read_bytes::<&[u8]>(1)?[0]) - } - - /// Read boolean from annotation - /// # Errors - /// [ConversionError::InvalidType] - /// * if there is not enough data - /// * if the next item in the annotation is an object instead of binary data. - /// # See - /// [ObjectInputStream#readBoolean()](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/ObjectInputStream.html#readBoolean()) - pub fn read_boolean(&mut self) -> ConversionResult { - Ok(self.read_u8()? == 1) - } - - /// Read short (i16) from annotation - /// # Errors - /// [ConversionError::InvalidType] - /// * if there is not enough data - /// * if the next item in the annotation is an object instead of binary data. - /// # See - /// [ObjectInputStream#readShort()](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/ObjectInputStream.html#readShort()) - pub fn read_i16(&mut self) -> ConversionResult { - Ok(i16::from_be_bytes(self.read_bytes(2)?)) - } - - /// Read int (i32) from annotation - /// # Errors - /// [ConversionError::InvalidType] - /// * if there is not enough data - /// * if the next item in the annotation is an object instead of binary data. - /// # See - /// [ObjectInputStream#readInt()](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/ObjectInputStream.html#readInt()) - pub fn read_i32(&mut self) -> ConversionResult { - Ok(i32::from_be_bytes(self.read_bytes(4)?)) - } - - /// Read long (i64) from annotation - /// # Errors - /// [ConversionError::InvalidType] - /// * if there is not enough data - /// * if the next item in the annotation is an object instead of binary data. - /// # See - /// [ObjectInputStream#readLong()](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/ObjectInputStream.html#readLong()) - pub fn read_i64(&mut self) -> ConversionResult { - Ok(i64::from_be_bytes(self.read_bytes(8)?)) - } - - /// Read float (f32) from annotation - /// # Errors - /// [ConversionError::InvalidType] - /// * if there is not enough data - /// * if the next item in the annotation is an object instead of binary data. - /// # See - /// [ObjectInputStream#readFloat()](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/ObjectInputStream.html#readFloat()) - pub fn read_f32(&mut self) -> ConversionResult { - Ok(f32::from_be_bytes(self.read_bytes(4)?)) - } - - /// Read double (f64) from annotation - /// # Errors - /// [ConversionError::InvalidType] - /// * if there is not enough data - /// * if the next item in the annotation is an object instead of binary data. - /// # See - /// [ObjectInputStream#readDouble()](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/ObjectInputStream.html#readDouble()) - pub fn read_f64(&mut self) -> ConversionResult { - Ok(f64::from_be_bytes(self.read_bytes(8)?)) - } - - /// Read char from annotation - /// # Errors - /// [ConversionError::InvalidType] - /// * if there is not enough data - /// * if the next item in the annotation is an object instead of binary data. - /// * if the bytes are not a valid UTF-8 character - /// # See - /// [ObjectInputStream#readChar()](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/ObjectInputStream.html#readChar()) - pub fn read_char(&mut self) -> ConversionResult { - let c = self.read_i16()? as u32; - std::char::from_u32(c).ok_or(ConversionError::InvalidType("valid character")) - } - - /// Read an object from annotation - /// # Errors - /// [ConversionError::UnexpectedBlockData] - /// if the next item in annotation is binary data. - /// [ConversionError::MissingAnnotations] - /// if there are no more objects in this annotation - /// # See - /// [ObjectInputStream#readObject()](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/ObjectInputStream.html#readObject()) - pub fn read_object(&mut self) -> ConversionResult<&'a Value> { - self.advance(); - use AnnotationReadState::*; - match self.state { - Value(v) => Ok(v), - Block(d) => Err(ConversionError::UnexpectedBlockData(d.to_vec())), - Complete => Err(ConversionError::NullPointerException), - } - } - - /// Read an object and convert it to a rust type - /// # Errors - /// This method is the equivalent of T::from_value(read_object()?) - /// so any errors raised by either method will be returned. - pub fn read_object_as(&mut self) -> ConversionResult { - T::from_value(self.read_object()?) - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn read_boolean() { - let data = vec![Content::Block(vec![1, 0])]; - let mut a = AnnotationIter::new(&data); - assert!(a.read_boolean().unwrap()); - assert!(!a.read_boolean().unwrap()); - } - #[test] - fn read_bytes() { - let data = vec![Content::Block(vec![1, 2, 3, 4, 5])]; - let mut a = AnnotationIter::new(&data); - assert_eq!(1, a.read_u8().unwrap()); - assert_eq!(2, a.read_u8().unwrap()); - assert_eq!(3, a.read_u8().unwrap()); - assert_eq!(4, a.read_u8().unwrap()); - assert_eq!(5, a.read_u8().unwrap()); - } - - #[test] - fn read_u16() { - let data = vec![Content::Block(vec![1, 2, 3, 4, 255, 5])]; - let mut a = AnnotationIter::new(&data); - assert_eq!(258, a.read_i16().unwrap()); - assert_eq!(772, a.read_i16().unwrap()); - assert_eq!(-251, a.read_i16().unwrap()); - } - - #[test] - fn read_i32() { - let data = vec![Content::Block(vec![1, 2, 3, 4, 255, 255, 3, 4])]; - let mut a = AnnotationIter::new(&data); - assert_eq!(16_909_060, a.read_i32().unwrap()); - assert_eq!(-64764, a.read_i32().unwrap()); - } - - #[test] - fn read_i64() { - let data = vec![Content::Block(vec![ - 1, 2, 3, 4, 5, 6, 7, 8, 255, 255, 255, 255, 1, 2, 3, 4, - ])]; - let mut a = AnnotationIter::new(&data); - assert_eq!(72_623_859_790_382_856, a.read_i64().unwrap()); - assert_eq!(-4278058236, a.read_i64().unwrap()); - } - - #[test] - fn read_float() { - let data = vec![Content::Block(vec![ - 0x42, 0x28, 0x00, 0x00, 0xc2, 0x28, 0x00, 0x00, - ])]; - let mut a = AnnotationIter::new(&data); - assert_eq!(42_f32, a.read_f32().unwrap()); - assert_eq!(-42_f32, a.read_f32().unwrap()); - } - - #[test] - fn read_double() { - let data = vec![Content::Block(vec![ - 0x40, 0x45, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ])]; - let mut a = AnnotationIter::new(&data); - assert_eq!(42_f64, a.read_f64().unwrap()); - } - - #[test] - fn read_char() { - let data = vec![Content::Block(vec![ - 0, 102, 0, 111, 0, 111, 0, 98, 0, 97, 0, 114, - ])]; - let mut a = AnnotationIter::new(&data); - assert_eq!('f', a.read_char().unwrap()); - assert_eq!('o', a.read_char().unwrap()); - assert_eq!('o', a.read_char().unwrap()); - assert_eq!('b', a.read_char().unwrap()); - assert_eq!('a', a.read_char().unwrap()); - assert_eq!('r', a.read_char().unwrap()); - } - - #[test] - fn empty_annotation() { - let mut a = AnnotationIter::new(&[]); - match a.read_u8() { - Ok(_) => panic!("Read byte from empty iterator"), - Err(ConversionError::InvalidType(_)) => (), - Err(_) => panic!("Incorrect error from reading byte"), - } - } -} diff --git a/ratisui-jaded/src/convert.rs b/ratisui-jaded/src/convert.rs deleted file mode 100644 index 99b6429..0000000 --- a/ratisui-jaded/src/convert.rs +++ /dev/null @@ -1,94 +0,0 @@ -//! Traits and methods used to convert deserialized Java objects into useful -//! structures. -use crate::{ConversionError, ConversionResult, PrimitiveType, Value}; - -/// Trait for structs that can be converted from a deserialized Java Value -pub trait FromJava: Sized { - /// Convert content read from a java stream into Self - fn from_value(value: &Value) -> ConversionResult; -} - -impl FromJava for Option { - fn from_value(value: &Value) -> ConversionResult { - match value { - Value::Null => Ok(None), - _ => Ok(Some(T::from_value(value)?)), - } - } -} - -impl FromJava for String { - fn from_value(value: &Value) -> ConversionResult { - match value { - Value::JavaString(s) => Ok(s.to_string()), - Value::Null => Err(ConversionError::NullPointerException), - _ => Err(ConversionError::InvalidType("string")), - } - } -} - -/// Implement FromJava for a primitive type. In Java a primitive can be a -/// 'real' primitive (int, double etc), or a boxed Object version -/// (java.lang.Integer, java.lang.Double) etc. This lets both variants be -/// converted to the equivalent rust types (i32, f64 etc). -macro_rules! from_value_for_primitive { - // Optionally take a string literal as boxed object names don't always match - // primitive name, eg int -> Integer - ($type:ty, $primitive:ident) => { - from_value_for_primitive! {$type, $primitive, stringify!($primitive)} - }; - // Convert either a primitive or boxed primitive into its rust equivalent - ($type:ty, $primitive:ident, $java_name:expr) => { - impl FromJava for $type { - fn from_value(value: &Value) -> ConversionResult { - match value { - Value::Object(data) => { - let java_class_name = concat!("java.lang.", $java_name); - if data.class_name() == java_class_name { - match data.get_field("value") { - Some(Value::Primitive(PrimitiveType::$primitive(v))) => Ok(*v), - Some(_) => Err(ConversionError::InvalidType(stringify!($type))), - None => Err(ConversionError::FieldNotFound("value".to_string())), - } - } else { - Err(ConversionError::InvalidType(java_class_name)) - } - } - Value::Primitive(PrimitiveType::$primitive(i)) => Ok(*i), - _ => Err(ConversionError::InvalidType($java_name)), - } - } - } - }; -} - -from_value_for_primitive!(u8, Byte); -from_value_for_primitive!(i16, Short); -from_value_for_primitive!(i32, Int, "Integer"); -from_value_for_primitive!(i64, Long); -from_value_for_primitive!(f32, Float); -from_value_for_primitive!(f64, Double); -from_value_for_primitive!(char, Char, "Character"); -from_value_for_primitive!(bool, Boolean); - -impl FromJava for Box { - fn from_value(value: &Value) -> ConversionResult { - Ok(Box::new(T::from_value(value)?)) - } -} - -impl FromJava for Vec { - fn from_value(value: &Value) -> ConversionResult { - match value { - Value::Array(items) => Ok(items - .iter() - .map(T::from_value) - .collect::>>()?), - Value::PrimitiveArray(items) => Ok(items - .iter() - .map(|p| T::from_value(&Value::Primitive(*p))) - .collect::>>()?), - _ => Err(ConversionError::InvalidType("array")), - } - } -} diff --git a/ratisui-jaded/src/error.rs b/ratisui-jaded/src/error.rs deleted file mode 100644 index 13225c5..0000000 --- a/ratisui-jaded/src/error.rs +++ /dev/null @@ -1,94 +0,0 @@ -use std::{borrow::Cow, string::FromUtf8Error}; -use thiserror::Error; - -/// Overall error type for everything that can go wrong with -/// Java deserialization -#[derive(Debug, Error)] -pub enum JavaError { - /// An error in the read/stream/deserialization process - #[error("Error read from stream")] - ReadError(#[from] StreamError), - /// An error arising from the conversion of read data to Rust struct - #[error("Error converting read object into something useful: {0}")] - ConvertError(#[from] ConversionError), -} - -/// Error for things that can go wrong with deserialization -#[derive(Debug, Error)] -pub enum StreamError { - /// If the stream ends while the parser is still expecting more data - #[error("Unexpected end of stream")] - EndOfStream(#[from] std::io::Error), - /// If the stream does not represent Serialized Java objects - #[error("This isn't a JavaObject - magic numbers: {0:X}")] - NonJavaObject(u16), - /// If the stream version is not one we can handle - #[error("Unknown serialization version: {0}")] - UnknownVersion(u16), - /// If the next stream marker is not a value recognised by the serialization - /// protocol - /// - /// The byte read from the stream will be included in the error. - #[error("Unknown mark: {0}")] - UnknownMark(u8), - /// If the type or a field is not one of the allowed characters - /// - /// The character being read as a type specification is included in the error - #[error("Unknown type marker: {0}")] - UnrecognisedType(char), - /// If a back reference is to an unregistered handle - /// - /// The unrecognised handle is included in the error - #[error("Unknown reference handle: {0}")] - UnknownReference(u32), - /// If the reference registered to a handle is not of the correct type - /// - /// The included string is the type that was expected, not the type found. - #[error("Invalid reference. Expected {0}")] - InvalidReference(&'static str), - /// The stream is not valid for some other reason - /// - /// The included string gives an error message of the problem found. - #[error("Invalid Stream: {0}")] - InvalidStream(&'static str), - /// This feature is not implemented yet - /// Some features are not possible without access to the Java source that - /// wrote the stream. - #[error("{0} isn't implemented yet")] - NotImplemented(&'static str), -} - -impl From for StreamError { - fn from(_: FromUtf8Error) -> Self { - StreamError::InvalidStream("String is not valid UTF-8") - } -} - -/// Things that can go wrong when converting deserialized java objects into -/// Rust entities -#[derive(Debug, Error)] -pub enum ConversionError { - /// Error signifying a required field does not exist in the deserialized - /// Java Object - #[error("Field '{0}' does not exist")] - FieldNotFound(String), - /// Everyone's favourite Java exception brought to rust. Returned if a - /// non-optional field has a null value. - #[error("No object found")] - NullPointerException, - /// The deserialized object was not the type required. - #[error("Expected '{0}'")] - InvalidType(&'static str), - /// Read block data instead of object - #[error("Unexpected block data")] - UnexpectedBlockData(Vec), - /// Annotation not available - #[error("Missing Annotation: {0}")] - MissingAnnotations(usize), - /// Incorrect class - #[error("Expected class '{0}', found '{1}'")] - IncorrectClass(Cow<'static, str>, Cow<'static, str>), - /// Unmatched class for enum - #[error("Class '{0}' was not expected")] - UnexpectedClass(String), -} diff --git a/ratisui-jaded/src/internal.rs b/ratisui-jaded/src/internal.rs deleted file mode 100644 index bda3ab6..0000000 --- a/ratisui-jaded/src/internal.rs +++ /dev/null @@ -1,231 +0,0 @@ -use crate::{ReadResult, StreamError}; -use std::convert::TryFrom; -use std::io::Read; - -const WRITE: u8 = 0x01; -const SERIALIZABLE: u8 = 0x02; -const EXTERNALIZABLE: u8 = 0x04; -const BLOCK: u8 = 0x08; -// const ENUM: u8 = 0x10; - -#[derive(Debug, Clone, PartialEq)] -pub(crate) enum Flag { - NoWrite, - Write, - ExtBlock, - Ext, -} - -impl TryFrom for Flag { - type Error = crate::StreamError; - fn try_from(byte: u8) -> ReadResult { - if byte.is(SERIALIZABLE) && !byte.is(WRITE) { - Ok(Self::NoWrite) - } else if byte.is(SERIALIZABLE) && byte.is(WRITE) { - Ok(Self::Write) - } else if byte.is(EXTERNALIZABLE) && !byte.is(BLOCK) { - Ok(Self::Ext) - } else if byte.is(EXTERNALIZABLE) && byte.is(BLOCK) { - Ok(Self::ExtBlock) - } else { - Err(StreamError::InvalidStream("Unexpected class flag")) - } - } -} - -trait BitField { - fn is(&self, mask: Self) -> bool; -} - -impl BitField for u8 { - fn is(&self, other: u8) -> bool { - self & other > 0 - } -} - -#[derive(Debug, PartialEq)] -pub(crate) enum Marker { - Null, // nullReference - Reference, // prevObject - ClassDesc, // newClassDesc - Object, // newObject - JavaString, // newString - Array, // newArray - Class, // newClass - BlockData, // blockdatashort - EndBlockData, // endblockdata - Reset, // reset - BlockDataLong, // blockdatalong - Exception, // exception - LongString, // newString - ProxyClassDesc, // proxyClassDesc - Enum, // newEnum -} - -impl Marker { - pub(crate) fn from(mark: u8) -> ReadResult { - Ok(match mark { - 0x70 => Self::Null, // nullReference - 0x71 => Self::Reference, // prevObject - 0x72 => Self::ClassDesc, // newClassDesc - 0x73 => Self::Object, // newObject - 0x74 => Self::JavaString, // newString - 0x75 => Self::Array, // newArray - 0x76 => Self::Class, // newClass - 0x77 => Self::BlockData, // blockdatashort - 0x78 => Self::EndBlockData, // endblockdata - 0x79 => Self::Reset, // reset - 0x7A => Self::BlockDataLong, // blockdatalong - 0x7B => Self::Exception, // exception - 0x7C => Self::LongString, // newString - 0x7D => Self::ProxyClassDesc, // proxyClassDesc - 0x7E => Self::Enum, // newEnum - unk => return Err(StreamError::UnknownMark(unk)), - }) - } -} - -pub(crate) trait JavaStream { - fn read_u8(&mut self) -> ReadResult; - fn read_u16(&mut self) -> ReadResult; - fn read_u32(&mut self) -> ReadResult; - fn read_u64(&mut self) -> ReadResult; - fn read_string(&mut self) -> ReadResult; - fn read_long_string(&mut self) -> ReadResult; - fn read_marker(&mut self) -> ReadResult; -} - -impl JavaStream for T { - fn read_u8(&mut self) -> ReadResult { - let mut buffer = [0]; - self.read_exact(&mut buffer)?; - Ok(u8::from_be_bytes(buffer)) - } - fn read_u16(&mut self) -> ReadResult { - let mut buffer = [0; 2]; - self.read_exact(&mut buffer)?; - Ok(u16::from_be_bytes(buffer)) - } - fn read_u32(&mut self) -> ReadResult { - let mut buffer = [0; 4]; - self.read_exact(&mut buffer)?; - Ok(u32::from_be_bytes(buffer)) - } - fn read_u64(&mut self) -> ReadResult { - let mut buffer = [0; 8]; - self.read_exact(&mut buffer)?; - Ok(u64::from_be_bytes(buffer)) - } - fn read_string(&mut self) -> ReadResult { - let len = self.read_u16()?.into(); - read_string(self, len) - } - fn read_long_string(&mut self) -> ReadResult { - let len = self.read_u64()? as usize; - read_string(self, len) - } - fn read_marker(&mut self) -> ReadResult { - Marker::from(self.read_u8()?) - } -} - -fn read_string(stream: &mut dyn Read, len: usize) -> ReadResult { - let mut buffer = Vec::with_capacity(len); - let read = stream.take(len as u64).read_to_end(&mut buffer)?; - if read != len { - return Err(StreamError::InvalidStream("Could not read full string")); - } - Ok(String::from_utf8(buffer)?) -} - -#[cfg(test)] -mod java_stream_test { - use super::*; - const DEMO_STREAM: &[u8] = &[ - 0x00, 0x0A, 0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x57, 0x6F, 0x72, 0x6C, 0x64, // string data - ]; - fn demo_stream() -> impl Read { - DEMO_STREAM - } - #[test] - fn read_u8() { - assert_eq!(demo_stream().read_u8().expect("Failed to read u8"), 0); - } - #[test] - fn read_u16() { - assert_eq!(demo_stream().read_u16().expect("Failed to read u16"), 10); - } - #[test] - fn read_u32() { - assert_eq!( - demo_stream().read_u32().expect("Failed to read u32"), - 682_085 - ); - } - #[test] - fn read_u64() { - assert_eq!( - demo_stream().read_u64().expect("Failed to read u64"), - 2_929_534_587_137_879 - ); - } - #[test] - fn read_string() { - assert_eq!( - demo_stream().read_string().expect("Failed to read string"), - "helloWorld" - ); - } - #[test] - fn read_markers() -> ReadResult<()> { - let mut data: &[u8] = &[0x74]; - assert_eq!(data.read_marker()?, Marker::JavaString); - Ok(()) - } - #[test] - fn read_incomplete_string() { - let mut data: &[u8] = &[ - 0x00, 0x10, 0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x57, // partial string data - ]; - let result = data.read_string(); - match result { - Ok(s) => panic!("Expected string read to fail but read '{}'", s), - Err(StreamError::InvalidStream(x)) => assert_eq!(x, "Could not read full string"), - Err(e) => panic!("Expected InvalidStream error but got '{}'", e), - } - } - #[test] - fn read_invalid_utf8() { - let mut data: &[u8] = &[ - 0x00, 0x0A, // 10 characters - 0xff, 0xfd, 0xff, 0xfd, 0xff, 0xfd, 0xff, 0xfd, 0xff, 0xfd, 0xff, - 0xfd, // invalid data - ]; - let result = data.read_string(); - match result { - Ok(s) => panic!("Expected invalid utf-8 error but read '{}'", s), - Err(StreamError::InvalidStream(e)) => assert_eq!(e, "String is not valid UTF-8"), - Err(e) => panic!("Expected invalid stream error but got '{}'", e), - } - } -} - -#[cfg(test)] -mod flag_test { - use super::*; - #[test] - fn converting_flags() -> ReadResult<()> { - assert_eq!(Flag::NoWrite, Flag::try_from(2)?); - assert_eq!(Flag::Write, Flag::try_from(3)?); - assert_eq!(Flag::Ext, Flag::try_from(4)?); - assert_eq!(Flag::ExtBlock, Flag::try_from(12)?); - - let result = Flag::try_from(8); - match result { - Ok(f) => panic!("Expected error but got {:?}", f), - Err(StreamError::InvalidStream(e)) => assert_eq!(e, "Unexpected class flag"), - Err(e) => panic!("Expected invalid stream error but got {}", e), - } - Ok(()) - } -} diff --git a/ratisui-jaded/src/lib.rs b/ratisui-jaded/src/lib.rs deleted file mode 100644 index b299aa2..0000000 --- a/ratisui-jaded/src/lib.rs +++ /dev/null @@ -1,1123 +0,0 @@ -//! # Java Deserializer for Rust -//! -//! Java has a much maligned but still widely used Serialization mechanism. -//! The serial stream produced follows the specification available from Oracle -//! [here](https://docs.oracle.com/en/java/javase/17/docs/specs/serialization/protocol.html) -//! (link is to Java 17 (latest LTS version at time of writing) but protocol -//! hasn't changed since 1.7). -//! -//! This library enables that serial stream to be read in Rust applications. -//! -//! ## Example -//! A simple bean type Java class can be serialized using the builtin tools -//! -//! ```java -//! import java.io.FileOutputStream; -//! import java.io.ObjectOutputStream; -//! import java.io.Serializable; -//! public class Demo implements Serializable { -//! private static final long serialVersionUID = 1L; -//! private String message; -//! private int i; -//! public Demo(String message, int count) { -//! this.message = message; -//! this.i = count; -//! } -//! public static void main(String[] args) throws Exception { -//! Demo d = new Demo("helloWorld", 42); -//! try (FileOutputStream fos = new FileOutputStream("demo.obj", false); -//! ObjectOutputStream oos = new ObjectOutputStream(fos);) { -//! oos.writeObject(d); -//! } -//! } -//! } -//! ``` -//! -//! We can read in the `demo.obj` file written as a rust struct -//! ```no_run -//! # use std::fs::File; -//! # use jaded::{Parser, Result, Value::{JavaString, Primitive}, PrimitiveType::Int}; -//! # fn main() -> Result<()> { -//! // Open the file written in Java -//! let sample = File::open("demo.obj").expect("File missing"); -//! // Create a new parser to wrap the file -//! let mut parser = Parser::new(sample)?; -//! // read an object from the stream -//! let content = parser.read()?; -//! // the content read was a value (instead of raw data) and the value -//! // was an instance of an object. These methods would panic if the content -//! // was of a different type (equivalent to Option#unwrap). -//! let demo = content.value().object_data(); -//! assert_eq!("Demo", demo.class_name()); -//! assert_eq!(Some(JavaString("helloWorld".to_string())).as_ref(), demo.get_field("message")); -//! assert_eq!(Some(Primitive(Int(42))).as_ref(), demo.get_field("i")); -//! # Ok(()) -//! # } -//! ``` -//! Reading into the raw data format is not often very user friendly so rust -//! types can be read directly from the stream if they implement [`FromJava`]. -//! -//! This is implemented for the primitive types and common types (boxed primitives, -//! arrays, String). Custom types can use these to implement `FromJava` -//! themselves. -//! -//! For example to read a string from an object stream -//! ```ignore -//! let mut parser = Parser::new(sample)?; -//! let string: String = parser.read_as()?; -//! ``` -//! Implemententing `FromJava` for custom types is very repetitive so a -//! [`derive`](jaded_derive) macro is provided with the `derive` feature to -//! automatically generate implementations. Using the same `Demo` class from -//! above this gives us -//! -//! ```ignore -//! #[derive(Debug, FromJava)] -//! struct Demo { -//! message: String, -//! i: i32, -//! } -//! -//! let mut parser = Parser::new(sample)?; -//! let demo: Demo = parser.read_as()?; -//! println!("{:#?}", demo); -//! -//! // Output -//! // Demo { -//! // message: "helloWorld", -//! // i: 42, -//! // } -//! ``` -//! - -#![warn(missing_docs)] -use std::collections::HashMap; -use std::convert::TryInto; -use std::fmt::{Display, Formatter}; -use std::io::Read; -use std::mem::replace; -mod annotations; -mod convert; -mod error; -mod internal; -pub use annotations::AnnotationIter; -pub use convert::FromJava; -pub use error::{ConversionError, JavaError, StreamError}; -use internal::{Flag, JavaStream, Marker}; - -#[cfg(feature = "derive")] -pub use jaded_derive::FromJava; - -#[cfg(feature = "serde")] -use serde::{Serialize, Deserialize}; - -/// Result type for all deserialization operations -pub type Result = std::result::Result; - -/// Result type for deserialization process -pub type ReadResult = std::result::Result; - -/// Result type for conversion process -pub type ConversionResult = std::result::Result; - -/// Handle are integers but make it explict what functions expect. -type Handle = u32; - -/// The first two bytes of any stream to mark it as Java Serialized Object data -const MAGIC: u16 = 0xAC_ED; -/// The serialization protocol expected -const VERSION: u16 = 0x00_05; - -/// The handle we assign to null values. -/// The Java protocol does not assign handles to null objects but it is useful -/// to treat all objects in the same way within the parsed data. -const NULL_HANDLE: Handle = 0; - -/// The handle given to the first object read. Subsequent objects take -/// successive handle values -const INITIAL_HANDLE: u32 = 0x7E_00_00; // Because why not start there - -/// The main parser class -/// ``` -/// # use std::fs::File; -/// # use jaded::Parser; -/// # fn main() -> jaded::Result<()> { -/// // Input can be anything that implements Read, eg file or tcp stream -/// let sample = File::open("sample").expect("Sample file missing"); -/// // Stream is checked at creation to ensure stream is java serialization -/// let mut parser = Parser::new(sample)?; -/// // Objects are read from stream in turn -/// let obj = parser.read()?; -/// println!("Read Object: {:?}", obj); -/// println!("Class name: {}", obj.value().object_data().class_name()); -/// # Ok(()) -/// # } -/// ``` -pub struct Parser { - /// The source stream - stream: Box, - /// Map of previous objects to support lookup of backreferences - references: HashMap, - /// The next handle to be assigned - handle: Handle, - /// The handles of all objects currently being resolved - handle_stack: Vec, - /// Stream protocol version. Currently always 5 - _version: u16, -} - -impl Parser { - /// Create a parser to read Java objects from a serial stream - pub fn new(mut source: T) -> Result { - let magic = source.read_u16()?; - let version = source.read_u16()?; - match (magic, version) { - (MAGIC, VERSION) => Ok(Self { - stream: Box::new(source), - _version: version, - handle_stack: vec![], - handle: INITIAL_HANDLE, - references: HashMap::new(), - }), - (MAGIC, v) => Err(JavaError::ReadError(StreamError::UnknownVersion(v))), - (m, _) => Err(JavaError::ReadError(StreamError::NonJavaObject(m))), - } - } - - /// Get the next handle (u32) to assign. Gets and increments the - /// internal counter and adds it to the stack of objects currently being - /// deserialized. For nested objects, this allows self referencing fields. - fn next_handle(&mut self) -> Handle { - let next = self.handle + 1; - self.handle_stack.push(self.handle); - replace(&mut self.handle, next) - } - - fn read_from_stream(&mut self) -> ReadResult { - use StreamRecord::*; - Ok(match self.stream.read_marker()? { - Marker::Null => Ref(NULL_HANDLE), - Marker::Reference => Ref(self.read_reference()?), - Marker::Object => Ref(self.read_object()?), - Marker::Array => Ref(self.read_array()?), - Marker::Enum => Ref(self.read_enum()?), - Marker::ClassDesc => Ref(self.read_class_desc()?), - Marker::ProxyClassDesc => Ref(self.read_proxy_class()?), - Marker::JavaString => Ref(self.read_java_string()?), - Marker::LongString => Ref(self.read_long_string()?), - Marker::Class => Ref(self.read_class()?), // This is a class that has been serialized, eg String.class - Marker::BlockData => BlockData(self.read_block_data()?), - Marker::BlockDataLong => BlockData(self.read_block_data_long()?), - Marker::EndBlockData => EndBlockData, - // This is an exception in the - // serialization process not an exception that has been serialized - Marker::Exception => Ref(self.read_exception()?), - Marker::Reset => { - self.reset(); - self.read_from_stream()? // potential for recursion problems for a stream of resets? - } - }) - } - - fn read_reference(&mut self) -> ReadResult { - self.stream.read_u32() - } - - fn read_class_desc(&mut self) -> ReadResult { - let class_name = self.stream.read_string()?; - let serial_uid = self.stream.read_u64()?; - let handle = self.next_handle(); - let flags = self.stream.read_u8()?.try_into()?; - let field_count = self.stream.read_u16()?; - let mut fields = Vec::with_capacity(field_count as usize); - for _ in 0..field_count { - let type_code = self.stream.read_u8()? as char; - let field_name = self.stream.read_string()?; - fields.push(if type_code == 'L' || type_code == '[' { - match self.read_from_stream()? { - StreamRecord::Ref(_) => FieldSpec { - name: field_name, - type_spec: type_code, - }, - _ => return Err(StreamError::InvalidReference("Expected reference handle")), - } - } else { - FieldSpec { - name: field_name, - type_spec: type_code, - } - }); - } - let annotations = self.read_annotations()?; - let super_class = match self.read_from_stream()? { - StreamRecord::Ref(NULL_HANDLE) => None, - StreamRecord::Ref(hnd) => Some(hnd), - _ => { - return Err(StreamError::InvalidStream( - "Super class is neither NewClassDesc nor null", - )) - } - }; - let class_outline = ClassOutline { - class_name, - fields, - _serial_uid: serial_uid, - _annotations: annotations, - super_class, - flags, - }; - self.register(&handle, Reference::Class(class_outline)); - Ok(handle) - } - - fn read_proxy_class(&mut self) -> ReadResult { - let handle = self.next_handle(); - let interface_count = self.stream.read_u32()? as i32; - let mut interfaces = vec![]; - for _ in 0..interface_count { - interfaces.push(self.stream.read_string()?); - } - let annotations = self.read_annotations()?; - let class_outline = *self.read_from_stream()?.handle()?; - let proxy = Reference::Proxy(ProxyOutline { - _interfaces: interfaces, - _annotations: annotations, - class_outline, - }); - self.register(&handle, proxy); - Ok(handle) - } - - fn read_annotations(&mut self) -> ReadResult> { - let mut annotations = vec![]; - use Annotation as A; - use StreamRecord::*; - loop { - match self.read_from_stream()? { - Ref(hnd) => annotations.push(A::Ref(hnd)), - BlockData(data) => annotations.push(A::Block(data)), - EndBlockData => break, - }; - } - Ok(annotations) - } - - fn read_object(&mut self) -> ReadResult { - let class_desc = self.read_from_stream()?; - let handle = self.next_handle(); - let order = self.build_read_list(class_desc.handle()?)?; - let mut fields = HashMap::new(); - let mut annotations = vec![]; - for read in order { - match read { - ReadOrder::Fields(spec) => { - for f in spec { - fields.insert(f.name, self.read_value(f.type_spec)?); - } - } - ReadOrder::Annotations => annotations.push(self.read_annotations()?), - } - } - let new_obj = Reference::Object(JavaObject { - class: *class_desc.handle()?, - fields, - annotations, - }); - self.register(&handle, new_obj); - Ok(handle) - } - - fn build_read_list(&mut self, hnd: &Handle) -> ReadResult> { - let class_desc = self.class_from(hnd)?; - // If any superclass in the hierarchy is externalizable, all subclasses - // are as well, and no default fields are written. Just read block data - if class_desc.flags == Flag::ExtBlock { - return Ok(vec![ReadOrder::Annotations]); - } - // otherwise, climb the class hierarchy and then add fields on the way down - let mut order = match class_desc.super_class { - Some(h) => self.build_read_list(&h)?, - None => vec![], - }; - order.push(ReadOrder::Fields(class_desc.fields)); - if class_desc.flags == Flag::Write { - order.push(ReadOrder::Annotations); - } - Ok(order) - } - - fn read_java_string(&mut self) -> ReadResult { - let handle = self.next_handle(); - let text = self.stream.read_string()?; - self.register(&handle, Reference::JavaString(text)); - Ok(handle) - } - - fn read_long_string(&mut self) -> ReadResult { - let handle = self.next_handle(); - let text = self.stream.read_long_string()?; - self.register(&handle, Reference::JavaString(text)); - Ok(handle) - } - - fn read_array(&mut self) -> ReadResult { - let class_handle = self.read_from_stream()?; - let handle = self.next_handle(); - let len = self.stream.read_u32()? as i32; - - let new_array = match self - .class_from(class_handle.handle()?)? - .class_name - .chars() - .nth(1) - { - Some('L') | Some('[') => { - // Arrays and Objects are stored as references - let mut data = vec![]; - for _ in 0..len { - data.push(*self.read_from_stream()?.handle()?); - } - Reference::Array(data) - } - Some(x) => { - // primitives are stored as values in PrimitiveType - let mut data = vec![]; - for _ in 0..len { - data.push(self.read_primitive(x)?); - } - Reference::PrimitiveArray(data) - } - None => return Err(StreamError::UnrecognisedType(' ')), - }; - self.register(&handle, new_array); - Ok(handle) - } - - fn read_value(&mut self, type_code: char) -> ReadResult { - use Field::*; - Ok(match type_code { - 'L' | '[' => match self.read_from_stream()? { - StreamRecord::Ref(obj_handle) => match self.get_from_handle(&obj_handle) { - Ok(_) => Field::Reference(obj_handle), - Err(_) => Field::Loop( - self.handle_stack - .iter() - .position(|i| i == &obj_handle) - .ok_or(StreamError::UnknownReference(obj_handle))? - as u32, - ), - }, - _ => return Err(StreamError::InvalidReference("Object")), - }, - c => Primitive(self.read_primitive(c)?), - }) - } - - fn read_primitive(&mut self, type_code: char) -> ReadResult { - use PrimitiveType::*; - Ok(match type_code { - 'C' => { - let c = self.stream.read_u16()? as u32; - Char( - std::char::from_u32(c) - .ok_or(StreamError::InvalidStream("invalid character"))?, - ) - } - 'B' => Byte(self.stream.read_u8()?), - 'S' => Short(self.stream.read_u16()? as i16), - 'I' => Int(self.stream.read_u32()? as i32), - 'J' => Long(self.stream.read_u64()? as i64), - 'F' => Float(f32::from_bits(self.stream.read_u32()?)), - 'D' => Double(f64::from_bits(self.stream.read_u64()?)), - 'Z' => Boolean(self.stream.read_u8()? == 1), - x => return Err(StreamError::UnrecognisedType(x)), - }) - } - - fn read_class(&mut self) -> ReadResult { - let desc = self.read_from_stream()?; - let handle = self.next_handle(); - let new_class = Reference::ClassObject(*desc.handle()?); - self.register(&handle, new_class); - Ok(handle) - } - - fn read_enum(&mut self) -> ReadResult { - let class_desc = self.read_from_stream()?; - let handle = self.next_handle(); - let constant_name = self.read_from_stream()?; - let new_enum = Reference::Enum(*class_desc.handle()?, *constant_name.handle()?); - self.register(&handle, new_enum); - Ok(handle) - } - - fn read_block_data(&mut self) -> ReadResult> { - let len = self.stream.read_u8()?; - let mut data = vec![]; - for _ in 0..len { - data.push(self.stream.read_u8()?); - } - Ok(data) - } - - fn reset(&mut self) { - self.handle = INITIAL_HANDLE; - self.references.clear(); - } - - fn read_block_data_long(&mut self) -> ReadResult> { - let len = self.stream.read_u32()?; - let mut data = vec![]; - for _ in 0..len { - data.push(self.stream.read_u8()?); - } - Ok(data) - } - - fn read_exception(&mut self) -> ReadResult { - self.reset(); - let exception = *self.read_from_stream()?.handle()?; - self.reset(); - Ok(exception) - } - - fn get_from_handle(&self, handle: &u32) -> ReadResult<&Reference> { - if handle == &NULL_HANDLE { - Ok(&Reference::Null) - } else { - match self.references.get(handle) { - Some(refn) => Ok(refn), - None => Err(StreamError::UnknownReference(*handle)), - } - } - } - - fn register(&mut self, handle: &u32, reference: Reference) { - if self.handle_stack.pop() != Some(*handle) { - panic!("object was registered before something it references"); - } - self.references.insert(*handle, reference); - } - - fn class_from(&self, hnd: &Handle) -> ReadResult { - let reference = self.get_from_handle(hnd)?; - match reference { - Reference::Proxy(proxy) => Ok(self.class_from(&proxy.class_outline)?), - Reference::Class(outline) => Ok(outline.clone()), - _ => Err(StreamError::InvalidReference("Class")), - } - } - - fn value_from_reference(&self, hnd: &Handle) -> ReadResult { - use Reference::*; - use Value as V; - Ok(match self.get_from_handle(hnd)? { - Null => V::Null, - PrimitiveArray(data) => V::PrimitiveArray(data.to_vec()), - Array(data) => V::Array( - data.iter() - .map(|h| self.value_from_reference(h)) - .collect::>()?, - ), - JavaString(s) => V::JavaString(s.to_string()), - Enum(class, cons) => { - let outline = self.get_from_handle(class)?.class_outline()?; - let constant = self.get_from_handle(cons)?.as_string()?; - V::Enum(outline.class_name.to_string(), constant.to_string()) - } - ClassObject(h) => V::Class( - self.get_from_handle(h)? - .class_outline()? - .class_name - .to_string(), - ), - Object(obj) => { - let class = self.class_from(&obj.class)?; - let mut field_data = HashMap::new(); - for (name, field) in &obj.fields { - field_data.insert( - name.to_string(), - match field { - Field::Loop(l) => Value::Loop(-(*l as i32)), - Field::Reference(h) => self.value_from_reference(h)?, - Field::Primitive(p) => Value::Primitive(*p), - }, - ); - } - let mut anno_data = vec![]; - for class_anno in &obj.annotations { - anno_data.push( - class_anno - .iter() - .map(|anno| { - Ok(match anno { - Annotation::Ref(h) => { - Content::Object(self.value_from_reference(h)?) - } - Annotation::Block(data) => Content::Block(data.to_vec()), - }) - }) - .collect::>>()?, - ); - } - V::Object(ObjectData { - class: class.class_name, - fields: field_data, - annotations: anno_data, - }) - } - _ => return Err(StreamError::NotImplemented("value from reference")), - }) - } - - /// Read the next item from the Java stream - pub fn read(&mut self) -> ReadResult { - use StreamRecord::*; - Ok(match self.read_from_stream()? { - Ref(hnd) => Content::Object(self.value_from_reference(&hnd)?), - EndBlockData => return Err(StreamError::InvalidStream("Unexpected EndBlockData mark")), - BlockData(data) => Content::Block(data), - }) - } - - /// Read the next item from the stream and convert it to required type - pub fn read_as(&mut self) -> Result { - match self.read()? { - Content::Object(value) => Ok(S::from_value(&value)?), - Content::Block(data) => Err(JavaError::ConvertError( - ConversionError::UnexpectedBlockData(data), - )), - } - } -} - -#[derive(Debug)] -enum StreamRecord { - /// End of raw byte stream - EndBlockData, - /// Stream of raw bytes in stream - BlockData(Vec), - /// Reference to previous data - Ref(u32), -} - -impl StreamRecord { - fn handle(&self) -> ReadResult<&Handle> { - match self { - StreamRecord::Ref(hnd) => Ok(hnd), - _ => Err(StreamError::InvalidReference("Ref")), - } - } -} - -#[derive(Debug)] -enum Reference { - Class(ClassOutline), - Proxy(ProxyOutline), - Null, - JavaString(String), - Array(Vec), - PrimitiveArray(Vec), - ClassObject(Handle), // eg from from serializing String.class handle -> Class(outline) - Object(JavaObject), - Enum(Handle, Handle), // classDesc, constantName -} - -impl Reference { - fn as_string(&self) -> ReadResult<&str> { - match self { - Self::JavaString(text) => Ok(text), - _ => Err(StreamError::InvalidReference("String")), - } - } - fn class_outline(&self) -> ReadResult<&ClassOutline> { - match self { - Self::Class(outline) => Ok(outline), - _ => Err(StreamError::InvalidReference("ClassOutline")), - } - } -} - -#[derive(Debug, Clone)] -struct ClassOutline { - class_name: String, - _serial_uid: u64, - super_class: Option, - fields: Vec, - _annotations: Vec, - flags: Flag, -} - -#[derive(Debug)] -struct ProxyOutline { - _interfaces: Vec, - _annotations: Vec, - class_outline: Handle, // -> Class(outline) -} - -#[derive(Debug, Clone)] -struct FieldSpec { - name: String, - type_spec: char, -} - -#[derive(Debug)] -enum ReadOrder { - Fields(Vec), - Annotations, -} - -/// Java's primitive value types in Rust form -/// -/// The boxed versions of primitives (`java.lang.Long` etc) are resolved as -/// objects and are not returned as primitives. -#[derive(Debug, Copy, Clone, PartialEq)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -pub enum PrimitiveType { - /// byte as u8 - Byte(u8), - /// char as char - /// - /// A Java char is always 2 bytes whereas a Rust char is four but for now - /// even with the increased memory usage, using a char presents a better - /// API than storing it as a u16. - Char(char), - /// double as f64 - Double(f64), - /// float as f32 - Float(f32), - /// int as i32 - Int(i32), - /// long as i64 - Long(i64), - /// short as i16 - Short(i16), - /// boolean as bool - Boolean(bool), -} - -impl Display for PrimitiveType { - fn fmt(&self, f: &mut Formatter) -> std::fmt::Result { - match self { - Self::Byte(b) => write!(f, "{b:X}")?, - Self::Char(c) => write!(f, "{c}")?, - Self::Double(d) => write!(f, "{d}")?, - Self::Float(fl) => write!(f, "{fl}")?, - Self::Int(i) => write!(f, "{i}")?, - Self::Short(s) => write!(f, "{s}")?, - Self::Long(l) => write!(f, "{l}")?, - Self::Boolean(b) => write!(f, "{b}")?, - } - Ok(()) - } -} - -#[derive(Debug)] -struct JavaObject { - class: Handle, - fields: HashMap, - annotations: Vec>, // vec of annotations for each class in hierarchy -} - -#[derive(Debug, Clone)] -enum Annotation { - Ref(Handle), - Block(Vec), -} - -#[derive(Debug)] -enum Field { - Primitive(PrimitiveType), - Reference(Handle), - Loop(Handle), -} - -/// Object data representing serialized Java object -/// -/// Gives access to field data and class as well as any raw data added via -/// a custom writeObject/writeExternal method. -#[derive(Debug, PartialEq)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -pub struct ObjectData { - class: String, - fields: HashMap, - annotations: Vec>, // list of annotations for each class in the hierarchy -} - -impl ObjectData { - /// Get the fully qualified class name of the type of this object - pub fn class_name(&self) -> &str { - &self.class - } - /// Get the value associated with a field if it exists - /// - /// `None` indicates that the field is not present. A `null` value will - /// be returned as `Some(Value::Null)`. - pub fn get_field(&self, name: &str) -> Option<&Value> { - self.fields.get(name) - } - - /// Get field and convert to Rust entity - pub fn get_field_as(&self, name: &str) -> ConversionResult { - match self.get_field(name) { - Some(v) => Ok(T::from_value(v)?), - None => Err(ConversionError::FieldNotFound(name.to_string())), - } - } - - /// Get the annotations written by a class in this object's class hierachy - /// - /// eg if `Child` extends `Parent`, then `get_annotation(0)` on an instance of `Child` will return - /// the annotations written by `Parent` and `get_annotation(1)` will return annotations written - /// by `Child`. - pub fn get_annotation(&self, ind: usize) -> Option { - self.annotations - .get(ind) - .map(|anno| annotations::AnnotationIter::new(anno)) - } - /// Get the total number of object annotations added to this object by any of the classes - /// in its class hierarchy. - pub fn annotation_count(&self) -> usize { - self.annotations.iter().filter(|a| !a.is_empty()).count() - } - /// Get the number of fields written for this object - pub fn field_count(&self) -> usize { - self.fields.len() - } -} - -/// The possible values written by Java's serialization -#[derive(Debug, PartialEq)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -pub enum Value { - /// A Java null reference - Null, - /// A 'normal' Java Object - Object(ObjectData), - /// A String. These are treated differently to normal objects. - JavaString(String), - /// An instance of an Enum. Only the class name and variant name are available - Enum(String, String), // class name, constant name - /// A Java primitive - int, long, double etc - Primitive(PrimitiveType), - /// An array of Java Objects - Array(Vec), - /// An array of Java Primitives - PrimitiveArray(Vec), - /// A class object eg java.lang.String. Only the name is recorded - Class(String), - /// A recursive reference to something containing this value - /// The contained value is the number of steps out to read the target - Loop(i32), -} - -impl Value { - /// Get the primitive value this Value represents - /// # Panics - /// If this value is not a primitive - pub fn primitive(&self) -> &PrimitiveType { - match self { - Value::Primitive(pt) => pt, - _ => panic!("Can't get primitive type from non primitive value"), - } - } - /// Get the array of values this Value represents - /// # Panics - /// If this value is not an array. Note, this method expects an array of - /// objects and a primitive array will also panic. See primitive_array() - pub fn array(&self) -> &[Value] { - match self { - Value::Array(values) => values, - _ => panic!("Can't get array values from non-array"), - } - } - /// Get the array of primitive this Value represents - /// # Panics - /// If this value is not an array of primitives - pub fn primitive_array(&self) -> &[PrimitiveType] { - match self { - Value::PrimitiveArray(values) => values, - _ => panic!("Can't get array values from non-array"), - } - } - /// Check if this value is a null reference - pub fn is_null(&self) -> bool { - matches!(self, Value::Null) - } - /// Get the string value the value represents. This is only used to get - /// the string from a deserialised Java String and will not convert other - /// types into strings. - /// # Panics - /// If this value is not a JavaString - pub fn string(&self) -> &str { - match self { - Value::JavaString(s) => s, - _ => panic!("Not a string value"), - } - } - /// Get the object data of the object this value represents. - /// # Panics - /// If this value is not an instance of an object - pub fn object_data(&self) -> &ObjectData { - match self { - Value::Object(obj) => obj, - _ => panic!("Not an object"), - } - } - /// Get the class name and variant name of the enum this value represents - /// # Panics - /// If this value is not an enum - pub fn enum_data(&self) -> (&str, &str) { - match self { - Value::Enum(cls, cons) => (cls, cons), - _ => panic!("Not an enum"), - } - } -} - -/// The content read from a stream. -/// -/// Either an object or raw primitive data. -/// Also used to represent class and object annotations for custom write methods -/// -/// This is the top level type that clients will interact with. When Java code -/// writes to a stream it can choose to write -/// * objects, which will each be read into an instance of Object (containing its data) -/// * primitives, which are written as bytes and returned as instances of -/// Block (containing the data). -/// -/// The individual java primitives are not distinguished in the stream -/// so that writing `(short)1` twice and writing `(int)65537` once result in -/// the same stream being wrtten. For this reason, decoding the bytes read is -/// left to the client code that hopefully knows what format to expect. -#[derive(Debug, PartialEq)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -pub enum Content { - /// A deserialized Java Object - Object(Value), - /// An array of raw data - Block(Vec), -} - -impl Content { - /// Get the value of the object represented by this instance - /// - /// panics if this Content is raw block data - pub fn value(&self) -> &Value { - match self { - Content::Object(val) => val, - _ => panic!("Can't unwrap block data to value"), - } - } - /// Get the raw block data represented by this instance - /// - /// panics is this Content is an object value - pub fn data(&self) -> &[u8] { - match self { - Content::Block(data) => data, - _ => panic!("Can't unwrap value as block data"), - } - } -} - -#[cfg(test)] -mod parser_tests { - use super::StreamRecord::*; - use super::*; - #[test] - fn invalid_stream() { - let dat: &[u8] = &[0xAC, 0xDE, 0x00, 0x05]; - let parser = Parser::new(dat); - match parser { - Ok(_) => panic!("Parser shouldn't be created with invalid magic marker"), - Err(JavaError::ReadError(StreamError::NonJavaObject(mm))) => assert_eq!( - mm, 0xACDE, - "NonJavaObject error has wrong magic marker data", - ), - Err(e) => panic!("Error should have been NonJavaObject but was '{}'", e), - } - } - #[test] - fn invalid_stream_version() { - let dat: &[u8] = &[0xAC, 0xED, 0x00, 0x06]; - let parser = Parser::new(dat); - match parser { - Ok(_) => panic!("Parser shouldn't be created with unknown version"), - Err(JavaError::ReadError(StreamError::UnknownVersion(version))) => { - assert_eq!(version, 6, "UnknownVersion error has wrong version",) - } - Err(e) => panic!("Error should have been UnknownVersion but was '{}'", e), - } - } - #[test] - fn correct_marker_and_version() { - let dat: &[u8] = &[0xAC, 0xED, 0x00, 0x05]; - let parser = Parser::new(dat); - let parser = parser.expect("Parser should be created with valid stream"); - assert_eq!(parser._version, 5, "Parser has incorrect version"); - assert_eq!( - parser.handle, INITIAL_HANDLE, - "Parser started with incorrect handle" - ); - } - #[test] - fn handles_are_incremented() { - let dat: &[u8] = &[0xAC, 0xED, 0x00, 0x05]; - let mut parser = Parser::new(dat).expect("Parser failed to initialise"); - assert_eq!(parser.next_handle(), INITIAL_HANDLE); - assert_eq!(parser.next_handle(), INITIAL_HANDLE + 1); - assert_eq!(parser.next_handle(), INITIAL_HANDLE + 2); - } - #[test] - fn handle_stack_holds_current_handles() { - let dat: &[u8] = &[0xAC, 0xED, 0x00, 0x05]; - let mut parser = Parser::new(dat).expect("Parser failed to initialise"); - let a = parser.next_handle(); - let b = parser.next_handle(); - assert_eq!(vec![a, b], parser.handle_stack); - parser.register(&b, Reference::Null); - assert_eq!(vec![a], parser.handle_stack); - } - #[test] - #[should_panic(expected = "object was registered before something it references")] - fn handles_must_be_registered_in_order() { - let dat: &[u8] = &[0xAC, 0xED, 0x00, 0x05]; - let mut parser = Parser::new(dat).expect("Parser failed to initialise"); - let a = parser.next_handle(); - let _b = parser.next_handle(); - parser.register(&a, Reference::Null); - } - #[test] - fn read_null_reference() -> Result<()> { - let dat: &[u8] = &[ - 0xAC, 0xED, 0x00, 0x05, // MAGIC, VERSION - 0x70, // Null marker - ]; - let mut parser = Parser::new(dat)?; - let result = parser.read_from_stream()?; - match result { - BlockData(_) => panic!("Expected null reference but read block data"), - EndBlockData => panic!("Expected null reference but read end block data"), - Ref(0) => (), - Ref(x) => panic!("Expected null reference but read Ref({}) instead", x), - } - assert_eq!( - parser.handle, INITIAL_HANDLE, - "Handle shouldn't be incremented for null" - ); - Ok(()) - } - #[test] - fn short_string() -> Result<()> { - let dat: &[u8] = &[ - 0xAC, 0xED, 0x00, 0x05, // MAGIC, VERSION - 0x74, // Short java string - 0x00, 0x0A, // Length of string (10) - 0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x57, 0x6F, 0x72, 0x6C, 0x64, // string data - ]; - let mut parser = Parser::new(dat)?; - let result = parser.read_from_stream()?; - match result { - BlockData(_) => panic!("Expected string but read block data"), - EndBlockData => panic!("Expected string but read end block data"), - Ref(x) => { - assert_eq!(x, INITIAL_HANDLE); - let read = parser.get_from_handle(&x)?; - match read { - Reference::JavaString(s) => assert_eq!(s, "helloWorld"), - x => panic!("Expected string but read {:?}", x), - } - } - } - Ok(()) - } - #[test] - fn repeated_string() -> Result<()> { - let dat: &[u8] = &[ - 0xAC, 0xED, 0x00, 0x05, // MAGIC, VERSION - 0x74, // Short string marker - 0x00, 0x0A, // Length of string (10) - 0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x57, 0x6F, 0x72, 0x6C, 0x64, // string data - 0x71, // back reference marker - 0x00, 0x7E, 0x00, 0x00, // initial handle given to first string - ]; - let mut parser = Parser::new(dat)?; - let _result = parser.read_from_stream()?; - let second = parser.read_from_stream()?; - match second { - BlockData(_) => panic!("Expected string but read block data"), - EndBlockData => panic!("Expected string but read end block data"), - Ref(x) => { - assert_eq!(x, INITIAL_HANDLE); - let read = parser.get_from_handle(&x)?; - match read { - Reference::JavaString(s) => assert_eq!(s, "helloWorld"), - x => panic!("Expected string but read {:?}", x), - } - } - } - Ok(()) - } - #[test] - /// This is reading a serialized class not the class description of a serialized object - fn read_class_object() -> Result<()> { - let dat: &[u8] = &[ - 0xAC, 0xED, 0x00, 0x05, // MAGIC, VERSION - 0x76, // Class marker - 0x72, // Class description marker - 0x00, 0x11, // length of class name (17) - 0x6A, 0x61, 0x76, 0x61, 0x2E, 0x6C, 0x61, 0x6E, 0x67, 0x2E, 0x49, 0x6E, 0x74, 0x65, - 0x67, 0x65, 0x72, // string data - 0x12, 0xE2, 0xA0, 0xA4, 0xF7, 0x81, 0x87, 0x38, // SerialVersionUID - 0x02, // class desc flags (0x02 -> serializable) - 0x00, 0x01, // field count (1) - 0x49, // primitive type code ('I' -> int) - 0x00, 0x05, // length of field name - 0x76, 0x61, 0x6C, 0x75, 0x65, // field name string data - 0x78, // end block data - no class annotations - 0x72, // Class description marker for superclass - 0x00, 0x10, // length of class name (16) - 0x6A, 0x61, 0x76, 0x61, 0x2E, 0x6C, 0x61, 0x6E, 0x67, 0x2E, 0x4E, 0x75, 0x6D, 0x62, - 0x65, 0x72, // string data - 0x86, 0xAC, 0x95, 0x1D, 0x0B, 0x94, 0xE0, 0x8B, // SerialVersionUID - 0x02, // class desc flags (0x02 -> serializable) - 0x00, 0x00, // field count (0) - 0x78, // end block data - no class annotations - 0x70, // null reference - no superclass - ]; - let mut parser = Parser::new(dat)?; - let result = parser.read_from_stream()?; - match result { - BlockData(_) => panic!("Expected Class handle but read block data"), - EndBlockData => panic!("Expected Class handle but read end block data"), - Ref(x) => { - assert_eq!(x, INITIAL_HANDLE + 2); // first handle given to string - let read = parser.get_from_handle(&x)?; - match read { - Reference::ClassObject(hnd) => { - let outline = parser.get_from_handle(hnd)?.class_outline()?; - assert_eq!(outline.class_name, "java.lang.Integer"); - assert!(outline._annotations.is_empty()); - assert_eq!(outline.flags, Flag::NoWrite); - let super_class = - parser.get_from_handle(&(outline.super_class.unwrap()))?; - assert_eq!(super_class.class_outline()?.class_name, "java.lang.Number"); - } - x => panic!("Expected class object but read {:?}", x), - } - } - } - Ok(()) - } - #[test] - fn read_invalid_primitive() -> Result<()> { - let data: &[u8] = &[0xAC, 0xED, 0x00, 0x05, 0x42]; - let mut parser = Parser::new(data)?; - match parser.read_primitive('X') { - Ok(p) => panic!("Expected invalid primitive, read '{}'", p), - Err(StreamError::UnrecognisedType(e)) => assert_eq!(e, 'X'), - Err(e) => panic!("Expect unrecognised primitive error, but got '{}'", e), - } - Ok(()) - } -} diff --git a/ratisui-tree-sitter-ron/.cargo-ok b/ratisui-tree-sitter-ron/.cargo-ok deleted file mode 100644 index 5f8b795..0000000 --- a/ratisui-tree-sitter-ron/.cargo-ok +++ /dev/null @@ -1 +0,0 @@ -{"v":1} \ No newline at end of file diff --git a/ratisui-tree-sitter-ron/.cargo_vcs_info.json b/ratisui-tree-sitter-ron/.cargo_vcs_info.json deleted file mode 100644 index 83b560b..0000000 --- a/ratisui-tree-sitter-ron/.cargo_vcs_info.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "git": { - "sha1": "439aa96dedad83457098cf9592702024adcfa458" - }, - "path_in_vcs": "" -} \ No newline at end of file diff --git a/ratisui-tree-sitter-ron/Cargo.toml b/ratisui-tree-sitter-ron/Cargo.toml deleted file mode 100644 index 368780a..0000000 --- a/ratisui-tree-sitter-ron/Cargo.toml +++ /dev/null @@ -1,49 +0,0 @@ -# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO -# -# When uploading crates to the registry Cargo will automatically -# "normalize" Cargo.toml files for maximal compatibility -# with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies. -# -# If you are reading this file be aware that the original Cargo.toml -# will likely look very different (and much more reasonable). -# See Cargo.toml.orig for the original contents. - -[package] -edition = "2021" -name = "tree-sitter-ron" -version = "0.2.0" -authors = [ - "Amaan Qureshi ", - "Marius Cobzarenco ", -] -build = "bindings/rust/build.rs" -include = [ - "bindings/rust/*", - "grammar.js", - "queries/*", - "src/*", -] -autoexamples = false -description = "Rusty Object Notation (RON) grammar for tree-sitter" -readme = "bindings/rust/README.md" -keywords = [ - "incremental", - "parsing", - "ron", -] -categories = [ - "parsing", - "text-editors", -] -license = "MIT" -repository = "https://github.com/amaanq/tree-sitter-ron" - -[lib] -path = "bindings/rust/lib.rs" - -[dependencies.tree-sitter] -workspace = true - -[build-dependencies.cc] -version = "1.0" diff --git a/ratisui-tree-sitter-ron/Cargo.toml.orig b/ratisui-tree-sitter-ron/Cargo.toml.orig deleted file mode 100644 index 6f09d47..0000000 --- a/ratisui-tree-sitter-ron/Cargo.toml.orig +++ /dev/null @@ -1,27 +0,0 @@ -[package] -name = "tree-sitter-ron" -description = "Rusty Object Notation (RON) grammar for tree-sitter" -version = "0.2.0" -authors = [ - "Amaan Qureshi ", - "Marius Cobzarenco ", -] -license = "MIT" -readme = "bindings/rust/README.md" -keywords = ["incremental", "parsing", "ron"] -categories = ["parsing", "text-editors"] -repository = "https://github.com/amaanq/tree-sitter-ron" -edition = "2021" -autoexamples = false - -build = "bindings/rust/build.rs" -include = ["bindings/rust/*", "grammar.js", "queries/*", "src/*"] - -[lib] -path = "bindings/rust/lib.rs" - -[dependencies] -tree-sitter = "~0.20.3" - -[build-dependencies] -cc = "1.0" diff --git a/ratisui-tree-sitter-ron/bindings/rust/README.md b/ratisui-tree-sitter-ron/bindings/rust/README.md deleted file mode 100644 index 4837040..0000000 --- a/ratisui-tree-sitter-ron/bindings/rust/README.md +++ /dev/null @@ -1,36 +0,0 @@ -# tree-sitter-ron - -this crate provides a Rusty Object Notation (RON) grammar for the [tree-sitter][] parsing library. to -use this crate, add it to the `[dependencies]` section of your `cargo.toml` -file. (note that you will probably also need to depend on the -[`tree-sitter`][tree-sitter crate] crate to use the parsed result in any useful -way.) - -```toml -[dependencies] -tree-sitter = "~0.20.3" -tree-sitter-ron = "0.2.0" -``` - -typically, you will use the [language][language func] function to add this -grammar to a tree-sitter [parser][], and then use the parser to parse some code: - -```rust -let code = r#" - fn double(x: i32) -> i32 { - x * 2 - } -"#; -let mut parser = parser::new(); -parser.set_language(tree_sitter_ron::language()).expect("error loading RON grammar"); -let parsed = parser.parse(code, none); -``` - -if you have any questions, please reach out to us in the [tree-sitter -discussions] page. - -[language func]: https://docs.rs/tree-sitter-ron/*/tree_sitter_ron/fn.language.html -[parser]: https://docs.rs/tree-sitter/*/tree_sitter/struct.parser.html -[tree-sitter]: https://tree-sitter.github.io/ -[tree-sitter crate]: https://crates.io/crates/tree-sitter -[tree-sitter discussions]: https://github.com/tree-sitter/tree-sitter/discussions diff --git a/ratisui-tree-sitter-ron/bindings/rust/build.rs b/ratisui-tree-sitter-ron/bindings/rust/build.rs deleted file mode 100644 index 8851fed..0000000 --- a/ratisui-tree-sitter-ron/bindings/rust/build.rs +++ /dev/null @@ -1,19 +0,0 @@ -fn main() { - let src_dir = std::path::Path::new("src"); - - let mut c_config = cc::Build::new(); - c_config.include(src_dir); - c_config - .flag_if_supported("-Wno-unused-parameter") - .flag_if_supported("-Wno-unused-but-set-variable") - .flag_if_supported("-Wno-trigraphs"); - let parser_path = src_dir.join("parser.c"); - c_config.file(&parser_path); - - let scanner_path = src_dir.join("scanner.c"); - c_config.file(&scanner_path); - println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap()); - - c_config.compile("parser"); - println!("cargo:rerun-if-changed={}", parser_path.to_str().unwrap()); -} diff --git a/ratisui-tree-sitter-ron/bindings/rust/lib.rs b/ratisui-tree-sitter-ron/bindings/rust/lib.rs deleted file mode 100644 index 7c0c9ec..0000000 --- a/ratisui-tree-sitter-ron/bindings/rust/lib.rs +++ /dev/null @@ -1,68 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright © 2023, Amaan Qureshi , Marius Cobzarenco -// See the LICENSE file in this repo for license details. -// ------------------------------------------------------------------------------------------------ - -//! This crate provides RON language support for the [tree-sitter][] parsing library. -//! -//! Typically, you will use the [language][language func] function to add this language to a -//! tree-sitter [Parser][], and then use the parser to parse some code: -//! -//! ``` -//! let code = ""; -//! let mut parser = tree_sitter::Parser::new(); -//! parser.set_language(&tree_sitter_ron::language()).expect("Error loading RON grammar"); -//! let tree = parser.parse(code, None).unwrap(); -//! ``` -//! -//! [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html -//! [language func]: fn.language.html -//! [Parser]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Parser.html -//! [tree-sitter]: https://tree-sitter.github.io/ - -use tree_sitter::Language; - -extern "C" { - fn tree_sitter_ron() -> Language; -} - -/// Get the tree-sitter [Language][] for this grammar. -/// -/// [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html -pub fn language() -> Language { - unsafe { tree_sitter_ron() } -} - -/// The source of the Rust tree-sitter grammar description. -pub const GRAMMAR: &str = include_str!("../../grammar.js"); - -/// The folds query for this language. -pub const FOLDS_QUERY: &str = include_str!("../../queries/folds.scm"); - -/// The syntax highlighting query for this language. -pub const HIGHLIGHTS_QUERY: &str = include_str!("../../queries/highlights.scm"); - -/// The indents query for this language. -pub const INDENTS_QUERY: &str = include_str!("../../queries/indents.scm"); - -/// The injection query for this language. -pub const INJECTIONS_QUERY: &str = include_str!("../../queries/injections.scm"); - -/// The symbol tagging query for this language. -pub const LOCALS_QUERY: &str = include_str!("../../queries/locals.scm"); - -/// The content of the [`node-types.json`][] file for this grammar. -/// -/// [`node-types.json`]: https://tree-sitter.github.io/tree-sitter/using-parsers#static-node-types -pub const NODE_TYPES: &str = include_str!("../../src/node-types.json"); - -#[cfg(test)] -mod tests { - #[test] - fn test_can_load_grammar() { - let mut parser = tree_sitter::Parser::new(); - parser - .set_language(&super::language()) - .expect("Error loading RON grammar"); - } -} diff --git a/ratisui-tree-sitter-ron/grammar.js b/ratisui-tree-sitter-ron/grammar.js deleted file mode 100644 index 6fefccd..0000000 --- a/ratisui-tree-sitter-ron/grammar.js +++ /dev/null @@ -1,205 +0,0 @@ -/** - * @file RON grammar for tree-sitter - * @author Marius Cobzarenco - * @author Amaan Qureshi - * @license MIT - * @see {@link https://github.com/ron-rs/ron/blob/master/docs/grammar.md|specification} - */ - -/* eslint-disable arrow-parens */ -/* eslint-disable camelcase */ -/* eslint-disable-next-line spaced-comment */ -/// -// @ts-check - -module.exports = grammar({ - name: 'ron', - - extras: $ => [ - /\s/, - $.line_comment, - $.block_comment, - ], - - externals: $ => [ - $._string_content, - $.raw_string, - $.float, - $.block_comment, - ], - - rules: { - source_file: $ => seq( - $._value, - ), - - _value: $ => choice( - $.array, - $.map, - $.struct, - $.tuple, - - $._literal, - - $.enum_variant, - ), - - enum_variant: $ => $.identifier, - - array: $ => seq( - '[', - sepBy(',', $._value), - optional(','), - ']', - ), - - map: $ => seq( - '{', - sepBy(',', $.map_entry), - optional(','), - '}', - ), - - struct: $ => choice( - $.unit_struct, - $._tuple_struct, - $._named_struct, - ), - - unit_struct: _ => choice( - '()', - ), - - struct_name: $ => $.identifier, - - _tuple_struct: $ => seq( - $.struct_name, - $.tuple, - ), - - _named_struct: $ => seq( - optional($.struct_name), - field('body', $._struct_body), - ), - - _struct_body: $ => seq( - '(', - sepBy(',', $.struct_entry), - optional(','), - ')', - ), - - tuple: $ => seq( - '(', - sepBy1(',', $._value), - optional(','), - ')', - ), - - map_entry: $ => seq( - $._value, - ':', - $._value, - ), - - struct_entry: $ => seq( - $.identifier, - ':', - $._value, - ), - - _literal: $ => choice( - $.string, - $.char, - $.boolean, - $.integer, - $.float, - $.negative, - ), - - integer: _ => token(seq( - choice( - /[0-9][0-9_]*/, - /0x[0-9a-fA-F_]+/, - /0b[01_]+/, - /0o[0-7_]+/, - ), - )), - - negative: $ => seq('-', choice($.integer, $.float)), - - string: $ => seq( - alias(/b?"/, '"'), - repeat(choice( - $._escape_sequence, - $._string_content, - )), - token.immediate('"'), - ), - - char: $ => seq( - optional('b'), - '\'', - optional(choice( - $._escape_sequence, - /[^\\']/, - )), - '\'', - ), - - _escape_sequence: $ => - choice( - prec(2, token.immediate(seq('\\', /[^abfnrtvxu'\"\\\?]/))), - prec(1, $.escape_sequence), - ), - escape_sequence: _ => token.immediate( - seq('\\', - choice( - /[^xu]/, - /[0-7]{1,3}/, - /u[0-9a-fA-F]{4}/, - /u{[0-9a-fA-F]+}/, - /x[0-9a-fA-F]{2}/, - ), - )), - - boolean: _ => choice('true', 'false'), - - identifier: _ => /(r#)?[_\p{XID_Start}][_\p{XID_Continue}]*/, - - comment: $ => choice( - $.line_comment, - $.block_comment, - ), - - line_comment: _ => token(seq( - '//', /.*/, - )), - }, -}); - -/** - * Creates a rule to match one or more of the rules separated by the separator. - * - * @param {string|RegExp} sep - The separator to use. - * @param {Rule|RegExp} rule - * - * @return {SeqRule} - * - */ -function sepBy1(sep, rule) { - return seq(rule, repeat(seq(sep, rule))); -} - -/** - * Creates a rule to optionally match one or more of the rules separated by the separator. - * - * @param {string|RegExp} sep - The separator to use. - * @param {Rule|RegExp} rule - * - * @return {ChoiceRule} - * - */ -function sepBy(sep, rule) { - return optional(sepBy1(sep, rule)); -} diff --git a/ratisui-tree-sitter-ron/queries/folds.scm b/ratisui-tree-sitter-ron/queries/folds.scm deleted file mode 100644 index ae79583..0000000 --- a/ratisui-tree-sitter-ron/queries/folds.scm +++ /dev/null @@ -1,7 +0,0 @@ -[ - (array) - (map) - (tuple) - (struct) - (block_comment) -] @fold diff --git a/ratisui-tree-sitter-ron/queries/highlights.scm b/ratisui-tree-sitter-ron/queries/highlights.scm deleted file mode 100644 index 8692643..0000000 --- a/ratisui-tree-sitter-ron/queries/highlights.scm +++ /dev/null @@ -1,53 +0,0 @@ -; Structs -;------------ - -(enum_variant) @constant -(struct_entry (identifier) @property) -(struct_entry (enum_variant (identifier) @constant)) -(struct_name (identifier)) @type - -(unit_struct) @type.builtin - - -; Literals -;------------ - -(string) @string -(boolean) @boolean -(integer) @number -(float) @float -(char) @character - - -; Comments -;------------ - -[ - (line_comment) - (block_comment) -] @comment @spell - - -; Punctuation -;------------ - -["{" "}"] @punctuation.bracket - -["(" ")"] @punctuation.bracket - -["[" "]"] @punctuation.bracket - -[ - "," - ":" -] @punctuation.delimiter - -[ - "-" -] @operator - -; Special -;------------ - -(escape_sequence) @string.escape -(ERROR) @error diff --git a/ratisui-tree-sitter-ron/queries/indents.scm b/ratisui-tree-sitter-ron/queries/indents.scm deleted file mode 100644 index 84701a7..0000000 --- a/ratisui-tree-sitter-ron/queries/indents.scm +++ /dev/null @@ -1,12 +0,0 @@ -[ - (array) - (map) - (tuple) - (struct) -] @indent - -[ "{" "}" ] @branch - -[ "(" ")" ] @branch - -[ "[" "]" ] @branch diff --git a/ratisui-tree-sitter-ron/queries/injections.scm b/ratisui-tree-sitter-ron/queries/injections.scm deleted file mode 100644 index e48ce9a..0000000 --- a/ratisui-tree-sitter-ron/queries/injections.scm +++ /dev/null @@ -1,4 +0,0 @@ -[ - (line_comment) - (block_comment) -] @comment diff --git a/ratisui-tree-sitter-ron/queries/locals.scm b/ratisui-tree-sitter-ron/queries/locals.scm deleted file mode 100644 index de90d35..0000000 --- a/ratisui-tree-sitter-ron/queries/locals.scm +++ /dev/null @@ -1,12 +0,0 @@ -(source_file) @scope -(source_file (array) @scope) -(source_file (map) @scope) -(source_file (struct) @scope) -(source_file (tuple) @scope) - -(identifier) @reference - -(struct_entry (identifier) @definition.field) -(struct_entry (identifier) @definition.enum (enum_variant)) - -(struct (struct_name) @definition.type) diff --git a/ratisui-tree-sitter-ron/src/grammar.json b/ratisui-tree-sitter-ron/src/grammar.json deleted file mode 100644 index c4f845b..0000000 --- a/ratisui-tree-sitter-ron/src/grammar.json +++ /dev/null @@ -1,689 +0,0 @@ -{ - "name": "ron", - "rules": { - "source_file": { - "type": "SEQ", - "members": [ - { - "type": "SYMBOL", - "name": "_value" - } - ] - }, - "_value": { - "type": "CHOICE", - "members": [ - { - "type": "SYMBOL", - "name": "array" - }, - { - "type": "SYMBOL", - "name": "map" - }, - { - "type": "SYMBOL", - "name": "struct" - }, - { - "type": "SYMBOL", - "name": "tuple" - }, - { - "type": "SYMBOL", - "name": "_literal" - }, - { - "type": "SYMBOL", - "name": "enum_variant" - } - ] - }, - "enum_variant": { - "type": "SYMBOL", - "name": "identifier" - }, - "array": { - "type": "SEQ", - "members": [ - { - "type": "STRING", - "value": "[" - }, - { - "type": "CHOICE", - "members": [ - { - "type": "SEQ", - "members": [ - { - "type": "SYMBOL", - "name": "_value" - }, - { - "type": "REPEAT", - "content": { - "type": "SEQ", - "members": [ - { - "type": "STRING", - "value": "," - }, - { - "type": "SYMBOL", - "name": "_value" - } - ] - } - } - ] - }, - { - "type": "BLANK" - } - ] - }, - { - "type": "CHOICE", - "members": [ - { - "type": "STRING", - "value": "," - }, - { - "type": "BLANK" - } - ] - }, - { - "type": "STRING", - "value": "]" - } - ] - }, - "map": { - "type": "SEQ", - "members": [ - { - "type": "STRING", - "value": "{" - }, - { - "type": "CHOICE", - "members": [ - { - "type": "SEQ", - "members": [ - { - "type": "SYMBOL", - "name": "map_entry" - }, - { - "type": "REPEAT", - "content": { - "type": "SEQ", - "members": [ - { - "type": "STRING", - "value": "," - }, - { - "type": "SYMBOL", - "name": "map_entry" - } - ] - } - } - ] - }, - { - "type": "BLANK" - } - ] - }, - { - "type": "CHOICE", - "members": [ - { - "type": "STRING", - "value": "," - }, - { - "type": "BLANK" - } - ] - }, - { - "type": "STRING", - "value": "}" - } - ] - }, - "struct": { - "type": "CHOICE", - "members": [ - { - "type": "SYMBOL", - "name": "unit_struct" - }, - { - "type": "SYMBOL", - "name": "_tuple_struct" - }, - { - "type": "SYMBOL", - "name": "_named_struct" - } - ] - }, - "unit_struct": { - "type": "CHOICE", - "members": [ - { - "type": "STRING", - "value": "()" - } - ] - }, - "struct_name": { - "type": "SYMBOL", - "name": "identifier" - }, - "_tuple_struct": { - "type": "SEQ", - "members": [ - { - "type": "SYMBOL", - "name": "struct_name" - }, - { - "type": "SYMBOL", - "name": "tuple" - } - ] - }, - "_named_struct": { - "type": "SEQ", - "members": [ - { - "type": "CHOICE", - "members": [ - { - "type": "SYMBOL", - "name": "struct_name" - }, - { - "type": "BLANK" - } - ] - }, - { - "type": "FIELD", - "name": "body", - "content": { - "type": "SYMBOL", - "name": "_struct_body" - } - } - ] - }, - "_struct_body": { - "type": "SEQ", - "members": [ - { - "type": "STRING", - "value": "(" - }, - { - "type": "CHOICE", - "members": [ - { - "type": "SEQ", - "members": [ - { - "type": "SYMBOL", - "name": "struct_entry" - }, - { - "type": "REPEAT", - "content": { - "type": "SEQ", - "members": [ - { - "type": "STRING", - "value": "," - }, - { - "type": "SYMBOL", - "name": "struct_entry" - } - ] - } - } - ] - }, - { - "type": "BLANK" - } - ] - }, - { - "type": "CHOICE", - "members": [ - { - "type": "STRING", - "value": "," - }, - { - "type": "BLANK" - } - ] - }, - { - "type": "STRING", - "value": ")" - } - ] - }, - "tuple": { - "type": "SEQ", - "members": [ - { - "type": "STRING", - "value": "(" - }, - { - "type": "SEQ", - "members": [ - { - "type": "SYMBOL", - "name": "_value" - }, - { - "type": "REPEAT", - "content": { - "type": "SEQ", - "members": [ - { - "type": "STRING", - "value": "," - }, - { - "type": "SYMBOL", - "name": "_value" - } - ] - } - } - ] - }, - { - "type": "CHOICE", - "members": [ - { - "type": "STRING", - "value": "," - }, - { - "type": "BLANK" - } - ] - }, - { - "type": "STRING", - "value": ")" - } - ] - }, - "map_entry": { - "type": "SEQ", - "members": [ - { - "type": "SYMBOL", - "name": "_value" - }, - { - "type": "STRING", - "value": ":" - }, - { - "type": "SYMBOL", - "name": "_value" - } - ] - }, - "struct_entry": { - "type": "SEQ", - "members": [ - { - "type": "SYMBOL", - "name": "identifier" - }, - { - "type": "STRING", - "value": ":" - }, - { - "type": "SYMBOL", - "name": "_value" - } - ] - }, - "_literal": { - "type": "CHOICE", - "members": [ - { - "type": "SYMBOL", - "name": "string" - }, - { - "type": "SYMBOL", - "name": "char" - }, - { - "type": "SYMBOL", - "name": "boolean" - }, - { - "type": "SYMBOL", - "name": "integer" - }, - { - "type": "SYMBOL", - "name": "float" - }, - { - "type": "SYMBOL", - "name": "negative" - } - ] - }, - "integer": { - "type": "TOKEN", - "content": { - "type": "SEQ", - "members": [ - { - "type": "CHOICE", - "members": [ - { - "type": "PATTERN", - "value": "[0-9][0-9_]*" - }, - { - "type": "PATTERN", - "value": "0x[0-9a-fA-F_]+" - }, - { - "type": "PATTERN", - "value": "0b[01_]+" - }, - { - "type": "PATTERN", - "value": "0o[0-7_]+" - } - ] - } - ] - } - }, - "negative": { - "type": "SEQ", - "members": [ - { - "type": "STRING", - "value": "-" - }, - { - "type": "CHOICE", - "members": [ - { - "type": "SYMBOL", - "name": "integer" - }, - { - "type": "SYMBOL", - "name": "float" - } - ] - } - ] - }, - "string": { - "type": "SEQ", - "members": [ - { - "type": "ALIAS", - "content": { - "type": "PATTERN", - "value": "b?\"" - }, - "named": false, - "value": "\"" - }, - { - "type": "REPEAT", - "content": { - "type": "CHOICE", - "members": [ - { - "type": "SYMBOL", - "name": "_escape_sequence" - }, - { - "type": "SYMBOL", - "name": "_string_content" - } - ] - } - }, - { - "type": "IMMEDIATE_TOKEN", - "content": { - "type": "STRING", - "value": "\"" - } - } - ] - }, - "char": { - "type": "SEQ", - "members": [ - { - "type": "CHOICE", - "members": [ - { - "type": "STRING", - "value": "b" - }, - { - "type": "BLANK" - } - ] - }, - { - "type": "STRING", - "value": "'" - }, - { - "type": "CHOICE", - "members": [ - { - "type": "CHOICE", - "members": [ - { - "type": "SYMBOL", - "name": "_escape_sequence" - }, - { - "type": "PATTERN", - "value": "[^\\\\']" - } - ] - }, - { - "type": "BLANK" - } - ] - }, - { - "type": "STRING", - "value": "'" - } - ] - }, - "_escape_sequence": { - "type": "CHOICE", - "members": [ - { - "type": "PREC", - "value": 2, - "content": { - "type": "IMMEDIATE_TOKEN", - "content": { - "type": "SEQ", - "members": [ - { - "type": "STRING", - "value": "\\" - }, - { - "type": "PATTERN", - "value": "[^abfnrtvxu'\\\"\\\\\\?]" - } - ] - } - } - }, - { - "type": "PREC", - "value": 1, - "content": { - "type": "SYMBOL", - "name": "escape_sequence" - } - } - ] - }, - "escape_sequence": { - "type": "IMMEDIATE_TOKEN", - "content": { - "type": "SEQ", - "members": [ - { - "type": "STRING", - "value": "\\" - }, - { - "type": "CHOICE", - "members": [ - { - "type": "PATTERN", - "value": "[^xu]" - }, - { - "type": "PATTERN", - "value": "[0-7]{1,3}" - }, - { - "type": "PATTERN", - "value": "u[0-9a-fA-F]{4}" - }, - { - "type": "PATTERN", - "value": "u{[0-9a-fA-F]+}" - }, - { - "type": "PATTERN", - "value": "x[0-9a-fA-F]{2}" - } - ] - } - ] - } - }, - "boolean": { - "type": "CHOICE", - "members": [ - { - "type": "STRING", - "value": "true" - }, - { - "type": "STRING", - "value": "false" - } - ] - }, - "identifier": { - "type": "PATTERN", - "value": "(r#)?[_\\p{XID_Start}][_\\p{XID_Continue}]*" - }, - "comment": { - "type": "CHOICE", - "members": [ - { - "type": "SYMBOL", - "name": "line_comment" - }, - { - "type": "SYMBOL", - "name": "block_comment" - } - ] - }, - "line_comment": { - "type": "TOKEN", - "content": { - "type": "SEQ", - "members": [ - { - "type": "STRING", - "value": "//" - }, - { - "type": "PATTERN", - "value": ".*" - } - ] - } - } - }, - "extras": [ - { - "type": "PATTERN", - "value": "\\s" - }, - { - "type": "SYMBOL", - "name": "line_comment" - }, - { - "type": "SYMBOL", - "name": "block_comment" - } - ], - "conflicts": [], - "precedences": [], - "externals": [ - { - "type": "SYMBOL", - "name": "_string_content" - }, - { - "type": "SYMBOL", - "name": "raw_string" - }, - { - "type": "SYMBOL", - "name": "float" - }, - { - "type": "SYMBOL", - "name": "block_comment" - } - ], - "inline": [], - "supertypes": [] -} - diff --git a/ratisui-tree-sitter-ron/src/node-types.json b/ratisui-tree-sitter-ron/src/node-types.json deleted file mode 100644 index 07fa2b0..0000000 --- a/ratisui-tree-sitter-ron/src/node-types.json +++ /dev/null @@ -1,515 +0,0 @@ -[ - { - "type": "array", - "named": true, - "fields": {}, - "children": { - "multiple": true, - "required": false, - "types": [ - { - "type": "array", - "named": true - }, - { - "type": "boolean", - "named": true - }, - { - "type": "char", - "named": true - }, - { - "type": "enum_variant", - "named": true - }, - { - "type": "float", - "named": true - }, - { - "type": "integer", - "named": true - }, - { - "type": "map", - "named": true - }, - { - "type": "negative", - "named": true - }, - { - "type": "string", - "named": true - }, - { - "type": "struct", - "named": true - }, - { - "type": "tuple", - "named": true - } - ] - } - }, - { - "type": "boolean", - "named": true, - "fields": {} - }, - { - "type": "char", - "named": true, - "fields": {}, - "children": { - "multiple": false, - "required": false, - "types": [ - { - "type": "escape_sequence", - "named": true - } - ] - } - }, - { - "type": "enum_variant", - "named": true, - "fields": {}, - "children": { - "multiple": false, - "required": true, - "types": [ - { - "type": "identifier", - "named": true - } - ] - } - }, - { - "type": "map", - "named": true, - "fields": {}, - "children": { - "multiple": true, - "required": false, - "types": [ - { - "type": "map_entry", - "named": true - } - ] - } - }, - { - "type": "map_entry", - "named": true, - "fields": {}, - "children": { - "multiple": true, - "required": true, - "types": [ - { - "type": "array", - "named": true - }, - { - "type": "boolean", - "named": true - }, - { - "type": "char", - "named": true - }, - { - "type": "enum_variant", - "named": true - }, - { - "type": "float", - "named": true - }, - { - "type": "integer", - "named": true - }, - { - "type": "map", - "named": true - }, - { - "type": "negative", - "named": true - }, - { - "type": "string", - "named": true - }, - { - "type": "struct", - "named": true - }, - { - "type": "tuple", - "named": true - } - ] - } - }, - { - "type": "negative", - "named": true, - "fields": {}, - "children": { - "multiple": false, - "required": true, - "types": [ - { - "type": "float", - "named": true - }, - { - "type": "integer", - "named": true - } - ] - } - }, - { - "type": "source_file", - "named": true, - "fields": {}, - "children": { - "multiple": false, - "required": true, - "types": [ - { - "type": "array", - "named": true - }, - { - "type": "boolean", - "named": true - }, - { - "type": "char", - "named": true - }, - { - "type": "enum_variant", - "named": true - }, - { - "type": "float", - "named": true - }, - { - "type": "integer", - "named": true - }, - { - "type": "map", - "named": true - }, - { - "type": "negative", - "named": true - }, - { - "type": "string", - "named": true - }, - { - "type": "struct", - "named": true - }, - { - "type": "tuple", - "named": true - } - ] - } - }, - { - "type": "string", - "named": true, - "fields": {}, - "children": { - "multiple": true, - "required": false, - "types": [ - { - "type": "escape_sequence", - "named": true - } - ] - } - }, - { - "type": "struct", - "named": true, - "fields": { - "body": { - "multiple": true, - "required": false, - "types": [ - { - "type": "(", - "named": false - }, - { - "type": ")", - "named": false - }, - { - "type": ",", - "named": false - }, - { - "type": "struct_entry", - "named": true - } - ] - } - }, - "children": { - "multiple": true, - "required": false, - "types": [ - { - "type": "struct_name", - "named": true - }, - { - "type": "tuple", - "named": true - }, - { - "type": "unit_struct", - "named": true - } - ] - } - }, - { - "type": "struct_entry", - "named": true, - "fields": {}, - "children": { - "multiple": true, - "required": true, - "types": [ - { - "type": "array", - "named": true - }, - { - "type": "boolean", - "named": true - }, - { - "type": "char", - "named": true - }, - { - "type": "enum_variant", - "named": true - }, - { - "type": "float", - "named": true - }, - { - "type": "identifier", - "named": true - }, - { - "type": "integer", - "named": true - }, - { - "type": "map", - "named": true - }, - { - "type": "negative", - "named": true - }, - { - "type": "string", - "named": true - }, - { - "type": "struct", - "named": true - }, - { - "type": "tuple", - "named": true - } - ] - } - }, - { - "type": "struct_name", - "named": true, - "fields": {}, - "children": { - "multiple": false, - "required": true, - "types": [ - { - "type": "identifier", - "named": true - } - ] - } - }, - { - "type": "tuple", - "named": true, - "fields": {}, - "children": { - "multiple": true, - "required": true, - "types": [ - { - "type": "array", - "named": true - }, - { - "type": "boolean", - "named": true - }, - { - "type": "char", - "named": true - }, - { - "type": "enum_variant", - "named": true - }, - { - "type": "float", - "named": true - }, - { - "type": "integer", - "named": true - }, - { - "type": "map", - "named": true - }, - { - "type": "negative", - "named": true - }, - { - "type": "string", - "named": true - }, - { - "type": "struct", - "named": true - }, - { - "type": "tuple", - "named": true - } - ] - } - }, - { - "type": "unit_struct", - "named": true, - "fields": {} - }, - { - "type": "\"", - "named": false - }, - { - "type": "'", - "named": false - }, - { - "type": "(", - "named": false - }, - { - "type": "()", - "named": false - }, - { - "type": ")", - "named": false - }, - { - "type": ",", - "named": false - }, - { - "type": "-", - "named": false - }, - { - "type": ":", - "named": false - }, - { - "type": "[", - "named": false - }, - { - "type": "]", - "named": false - }, - { - "type": "b", - "named": false - }, - { - "type": "block_comment", - "named": true - }, - { - "type": "escape_sequence", - "named": true - }, - { - "type": "false", - "named": false - }, - { - "type": "float", - "named": true - }, - { - "type": "identifier", - "named": true - }, - { - "type": "integer", - "named": true - }, - { - "type": "line_comment", - "named": true - }, - { - "type": "true", - "named": false - }, - { - "type": "{", - "named": false - }, - { - "type": "}", - "named": false - } -] \ No newline at end of file diff --git a/ratisui-tree-sitter-ron/src/parser.c b/ratisui-tree-sitter-ron/src/parser.c deleted file mode 100644 index ebd4654..0000000 --- a/ratisui-tree-sitter-ron/src/parser.c +++ /dev/null @@ -1,5275 +0,0 @@ -#include - -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wmissing-field-initializers" -#endif - -#define LANGUAGE_VERSION 14 -#define STATE_COUNT 81 -#define LARGE_STATE_COUNT 15 -#define SYMBOL_COUNT 51 -#define ALIAS_COUNT 0 -#define TOKEN_COUNT 27 -#define EXTERNAL_TOKEN_COUNT 4 -#define FIELD_COUNT 1 -#define MAX_ALIAS_SEQUENCE_LENGTH 5 -#define PRODUCTION_ID_COUNT 4 - -enum { - anon_sym_LBRACK = 1, - anon_sym_COMMA = 2, - anon_sym_RBRACK = 3, - anon_sym_LBRACE = 4, - anon_sym_RBRACE = 5, - anon_sym_LPAREN_RPAREN = 6, - anon_sym_LPAREN = 7, - anon_sym_RPAREN = 8, - anon_sym_COLON = 9, - sym_integer = 10, - anon_sym_DASH = 11, - aux_sym_string_token1 = 12, - anon_sym_DQUOTE = 13, - anon_sym_b = 14, - anon_sym_SQUOTE = 15, - aux_sym_char_token1 = 16, - aux_sym__escape_sequence_token1 = 17, - sym_escape_sequence = 18, - anon_sym_true = 19, - anon_sym_false = 20, - sym_identifier = 21, - sym_line_comment = 22, - sym__string_content = 23, - sym_raw_string = 24, - sym_float = 25, - sym_block_comment = 26, - sym_source_file = 27, - sym__value = 28, - sym_enum_variant = 29, - sym_array = 30, - sym_map = 31, - sym_struct = 32, - sym_unit_struct = 33, - sym_struct_name = 34, - sym__tuple_struct = 35, - sym__named_struct = 36, - sym__struct_body = 37, - sym_tuple = 38, - sym_map_entry = 39, - sym_struct_entry = 40, - sym__literal = 41, - sym_negative = 42, - sym_string = 43, - sym_char = 44, - sym__escape_sequence = 45, - sym_boolean = 46, - aux_sym_array_repeat1 = 47, - aux_sym_map_repeat1 = 48, - aux_sym__struct_body_repeat1 = 49, - aux_sym_string_repeat1 = 50, -}; - -static const char * const ts_symbol_names[] = { - [ts_builtin_sym_end] = "end", - [anon_sym_LBRACK] = "[", - [anon_sym_COMMA] = ",", - [anon_sym_RBRACK] = "]", - [anon_sym_LBRACE] = "{", - [anon_sym_RBRACE] = "}", - [anon_sym_LPAREN_RPAREN] = "()", - [anon_sym_LPAREN] = "(", - [anon_sym_RPAREN] = ")", - [anon_sym_COLON] = ":", - [sym_integer] = "integer", - [anon_sym_DASH] = "-", - [aux_sym_string_token1] = "\"", - [anon_sym_DQUOTE] = "\"", - [anon_sym_b] = "b", - [anon_sym_SQUOTE] = "'", - [aux_sym_char_token1] = "char_token1", - [aux_sym__escape_sequence_token1] = "_escape_sequence_token1", - [sym_escape_sequence] = "escape_sequence", - [anon_sym_true] = "true", - [anon_sym_false] = "false", - [sym_identifier] = "identifier", - [sym_line_comment] = "line_comment", - [sym__string_content] = "_string_content", - [sym_raw_string] = "raw_string", - [sym_float] = "float", - [sym_block_comment] = "block_comment", - [sym_source_file] = "source_file", - [sym__value] = "_value", - [sym_enum_variant] = "enum_variant", - [sym_array] = "array", - [sym_map] = "map", - [sym_struct] = "struct", - [sym_unit_struct] = "unit_struct", - [sym_struct_name] = "struct_name", - [sym__tuple_struct] = "_tuple_struct", - [sym__named_struct] = "_named_struct", - [sym__struct_body] = "_struct_body", - [sym_tuple] = "tuple", - [sym_map_entry] = "map_entry", - [sym_struct_entry] = "struct_entry", - [sym__literal] = "_literal", - [sym_negative] = "negative", - [sym_string] = "string", - [sym_char] = "char", - [sym__escape_sequence] = "_escape_sequence", - [sym_boolean] = "boolean", - [aux_sym_array_repeat1] = "array_repeat1", - [aux_sym_map_repeat1] = "map_repeat1", - [aux_sym__struct_body_repeat1] = "_struct_body_repeat1", - [aux_sym_string_repeat1] = "string_repeat1", -}; - -static const TSSymbol ts_symbol_map[] = { - [ts_builtin_sym_end] = ts_builtin_sym_end, - [anon_sym_LBRACK] = anon_sym_LBRACK, - [anon_sym_COMMA] = anon_sym_COMMA, - [anon_sym_RBRACK] = anon_sym_RBRACK, - [anon_sym_LBRACE] = anon_sym_LBRACE, - [anon_sym_RBRACE] = anon_sym_RBRACE, - [anon_sym_LPAREN_RPAREN] = anon_sym_LPAREN_RPAREN, - [anon_sym_LPAREN] = anon_sym_LPAREN, - [anon_sym_RPAREN] = anon_sym_RPAREN, - [anon_sym_COLON] = anon_sym_COLON, - [sym_integer] = sym_integer, - [anon_sym_DASH] = anon_sym_DASH, - [aux_sym_string_token1] = anon_sym_DQUOTE, - [anon_sym_DQUOTE] = anon_sym_DQUOTE, - [anon_sym_b] = anon_sym_b, - [anon_sym_SQUOTE] = anon_sym_SQUOTE, - [aux_sym_char_token1] = aux_sym_char_token1, - [aux_sym__escape_sequence_token1] = aux_sym__escape_sequence_token1, - [sym_escape_sequence] = sym_escape_sequence, - [anon_sym_true] = anon_sym_true, - [anon_sym_false] = anon_sym_false, - [sym_identifier] = sym_identifier, - [sym_line_comment] = sym_line_comment, - [sym__string_content] = sym__string_content, - [sym_raw_string] = sym_raw_string, - [sym_float] = sym_float, - [sym_block_comment] = sym_block_comment, - [sym_source_file] = sym_source_file, - [sym__value] = sym__value, - [sym_enum_variant] = sym_enum_variant, - [sym_array] = sym_array, - [sym_map] = sym_map, - [sym_struct] = sym_struct, - [sym_unit_struct] = sym_unit_struct, - [sym_struct_name] = sym_struct_name, - [sym__tuple_struct] = sym__tuple_struct, - [sym__named_struct] = sym__named_struct, - [sym__struct_body] = sym__struct_body, - [sym_tuple] = sym_tuple, - [sym_map_entry] = sym_map_entry, - [sym_struct_entry] = sym_struct_entry, - [sym__literal] = sym__literal, - [sym_negative] = sym_negative, - [sym_string] = sym_string, - [sym_char] = sym_char, - [sym__escape_sequence] = sym__escape_sequence, - [sym_boolean] = sym_boolean, - [aux_sym_array_repeat1] = aux_sym_array_repeat1, - [aux_sym_map_repeat1] = aux_sym_map_repeat1, - [aux_sym__struct_body_repeat1] = aux_sym__struct_body_repeat1, - [aux_sym_string_repeat1] = aux_sym_string_repeat1, -}; - -static const TSSymbolMetadata ts_symbol_metadata[] = { - [ts_builtin_sym_end] = { - .visible = false, - .named = true, - }, - [anon_sym_LBRACK] = { - .visible = true, - .named = false, - }, - [anon_sym_COMMA] = { - .visible = true, - .named = false, - }, - [anon_sym_RBRACK] = { - .visible = true, - .named = false, - }, - [anon_sym_LBRACE] = { - .visible = true, - .named = false, - }, - [anon_sym_RBRACE] = { - .visible = true, - .named = false, - }, - [anon_sym_LPAREN_RPAREN] = { - .visible = true, - .named = false, - }, - [anon_sym_LPAREN] = { - .visible = true, - .named = false, - }, - [anon_sym_RPAREN] = { - .visible = true, - .named = false, - }, - [anon_sym_COLON] = { - .visible = true, - .named = false, - }, - [sym_integer] = { - .visible = true, - .named = true, - }, - [anon_sym_DASH] = { - .visible = true, - .named = false, - }, - [aux_sym_string_token1] = { - .visible = true, - .named = false, - }, - [anon_sym_DQUOTE] = { - .visible = true, - .named = false, - }, - [anon_sym_b] = { - .visible = true, - .named = false, - }, - [anon_sym_SQUOTE] = { - .visible = true, - .named = false, - }, - [aux_sym_char_token1] = { - .visible = false, - .named = false, - }, - [aux_sym__escape_sequence_token1] = { - .visible = false, - .named = false, - }, - [sym_escape_sequence] = { - .visible = true, - .named = true, - }, - [anon_sym_true] = { - .visible = true, - .named = false, - }, - [anon_sym_false] = { - .visible = true, - .named = false, - }, - [sym_identifier] = { - .visible = true, - .named = true, - }, - [sym_line_comment] = { - .visible = true, - .named = true, - }, - [sym__string_content] = { - .visible = false, - .named = true, - }, - [sym_raw_string] = { - .visible = true, - .named = true, - }, - [sym_float] = { - .visible = true, - .named = true, - }, - [sym_block_comment] = { - .visible = true, - .named = true, - }, - [sym_source_file] = { - .visible = true, - .named = true, - }, - [sym__value] = { - .visible = false, - .named = true, - }, - [sym_enum_variant] = { - .visible = true, - .named = true, - }, - [sym_array] = { - .visible = true, - .named = true, - }, - [sym_map] = { - .visible = true, - .named = true, - }, - [sym_struct] = { - .visible = true, - .named = true, - }, - [sym_unit_struct] = { - .visible = true, - .named = true, - }, - [sym_struct_name] = { - .visible = true, - .named = true, - }, - [sym__tuple_struct] = { - .visible = false, - .named = true, - }, - [sym__named_struct] = { - .visible = false, - .named = true, - }, - [sym__struct_body] = { - .visible = false, - .named = true, - }, - [sym_tuple] = { - .visible = true, - .named = true, - }, - [sym_map_entry] = { - .visible = true, - .named = true, - }, - [sym_struct_entry] = { - .visible = true, - .named = true, - }, - [sym__literal] = { - .visible = false, - .named = true, - }, - [sym_negative] = { - .visible = true, - .named = true, - }, - [sym_string] = { - .visible = true, - .named = true, - }, - [sym_char] = { - .visible = true, - .named = true, - }, - [sym__escape_sequence] = { - .visible = false, - .named = true, - }, - [sym_boolean] = { - .visible = true, - .named = true, - }, - [aux_sym_array_repeat1] = { - .visible = false, - .named = false, - }, - [aux_sym_map_repeat1] = { - .visible = false, - .named = false, - }, - [aux_sym__struct_body_repeat1] = { - .visible = false, - .named = false, - }, - [aux_sym_string_repeat1] = { - .visible = false, - .named = false, - }, -}; - -enum { - field_body = 1, -}; - -static const char * const ts_field_names[] = { - [0] = NULL, - [field_body] = "body", -}; - -static const TSFieldMapSlice ts_field_map_slices[PRODUCTION_ID_COUNT] = { - [1] = {.index = 0, .length = 1}, - [2] = {.index = 1, .length = 1}, - [3] = {.index = 2, .length = 1}, -}; - -static const TSFieldMapEntry ts_field_map_entries[] = { - [0] = - {field_body, 0, .inherited = true}, - [1] = - {field_body, 0}, - [2] = - {field_body, 1}, -}; - -static const TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE_LENGTH] = { - [0] = {0}, -}; - -static const uint16_t ts_non_terminal_alias_map[] = { - 0, -}; - -static const TSStateId ts_primary_state_ids[STATE_COUNT] = { - [0] = 0, - [1] = 1, - [2] = 2, - [3] = 3, - [4] = 4, - [5] = 5, - [6] = 6, - [7] = 7, - [8] = 8, - [9] = 9, - [10] = 10, - [11] = 11, - [12] = 12, - [13] = 13, - [14] = 14, - [15] = 15, - [16] = 16, - [17] = 17, - [18] = 18, - [19] = 19, - [20] = 20, - [21] = 21, - [22] = 22, - [23] = 23, - [24] = 24, - [25] = 25, - [26] = 26, - [27] = 27, - [28] = 28, - [29] = 29, - [30] = 30, - [31] = 31, - [32] = 32, - [33] = 33, - [34] = 34, - [35] = 35, - [36] = 36, - [37] = 37, - [38] = 38, - [39] = 39, - [40] = 40, - [41] = 41, - [42] = 42, - [43] = 43, - [44] = 44, - [45] = 45, - [46] = 46, - [47] = 47, - [48] = 48, - [49] = 49, - [50] = 50, - [51] = 51, - [52] = 52, - [53] = 53, - [54] = 54, - [55] = 55, - [56] = 56, - [57] = 57, - [58] = 58, - [59] = 59, - [60] = 60, - [61] = 61, - [62] = 62, - [63] = 63, - [64] = 64, - [65] = 65, - [66] = 66, - [67] = 67, - [68] = 68, - [69] = 69, - [70] = 70, - [71] = 71, - [72] = 72, - [73] = 73, - [74] = 74, - [75] = 75, - [76] = 76, - [77] = 77, - [78] = 78, - [79] = 79, - [80] = 80, -}; - -static inline bool sym_escape_sequence_character_set_1(int32_t c) { - return (c < 'a' - ? (c < '?' - ? (c < '\'' - ? c == '"' - : c <= '\'') - : (c <= '?' || c == '\\')) - : (c <= 'b' || (c < 'r' - ? (c < 'n' - ? c == 'f' - : c <= 'n') - : (c <= 'r' || (c >= 't' && c <= 'v'))))); -} - -static inline bool sym_identifier_character_set_1(int32_t c) { - return (c < 43642 - ? (c < 4206 - ? (c < 2730 - ? (c < 1994 - ? (c < 910 - ? (c < 736 - ? (c < 186 - ? (c < 'a' - ? (c < '_' - ? (c >= 'A' && c <= 'Z') - : c <= '_') - : (c <= 'z' || (c < 181 - ? c == 170 - : c <= 181))) - : (c <= 186 || (c < 248 - ? (c < 216 - ? (c >= 192 && c <= 214) - : c <= 246) - : (c <= 705 || (c >= 710 && c <= 721))))) - : (c <= 740 || (c < 891 - ? (c < 880 - ? (c < 750 - ? c == 748 - : c <= 750) - : (c <= 884 || (c >= 886 && c <= 887))) - : (c <= 893 || (c < 904 - ? (c < 902 - ? c == 895 - : c <= 902) - : (c <= 906 || c == 908)))))) - : (c <= 929 || (c < 1649 - ? (c < 1376 - ? (c < 1162 - ? (c < 1015 - ? (c >= 931 && c <= 1013) - : c <= 1153) - : (c <= 1327 || (c < 1369 - ? (c >= 1329 && c <= 1366) - : c <= 1369))) - : (c <= 1416 || (c < 1568 - ? (c < 1519 - ? (c >= 1488 && c <= 1514) - : c <= 1522) - : (c <= 1610 || (c >= 1646 && c <= 1647))))) - : (c <= 1747 || (c < 1791 - ? (c < 1774 - ? (c < 1765 - ? c == 1749 - : c <= 1766) - : (c <= 1775 || (c >= 1786 && c <= 1788))) - : (c <= 1791 || (c < 1869 - ? (c < 1810 - ? c == 1808 - : c <= 1839) - : (c <= 1957 || c == 1969)))))))) - : (c <= 2026 || (c < 2482 - ? (c < 2208 - ? (c < 2088 - ? (c < 2048 - ? (c < 2042 - ? (c >= 2036 && c <= 2037) - : c <= 2042) - : (c <= 2069 || (c < 2084 - ? c == 2074 - : c <= 2084))) - : (c <= 2088 || (c < 2160 - ? (c < 2144 - ? (c >= 2112 && c <= 2136) - : c <= 2154) - : (c <= 2183 || (c >= 2185 && c <= 2190))))) - : (c <= 2249 || (c < 2417 - ? (c < 2384 - ? (c < 2365 - ? (c >= 2308 && c <= 2361) - : c <= 2365) - : (c <= 2384 || (c >= 2392 && c <= 2401))) - : (c <= 2432 || (c < 2451 - ? (c < 2447 - ? (c >= 2437 && c <= 2444) - : c <= 2448) - : (c <= 2472 || (c >= 2474 && c <= 2480))))))) - : (c <= 2482 || (c < 2602 - ? (c < 2544 - ? (c < 2510 - ? (c < 2493 - ? (c >= 2486 && c <= 2489) - : c <= 2493) - : (c <= 2510 || (c < 2527 - ? (c >= 2524 && c <= 2525) - : c <= 2529))) - : (c <= 2545 || (c < 2575 - ? (c < 2565 - ? c == 2556 - : c <= 2570) - : (c <= 2576 || (c >= 2579 && c <= 2600))))) - : (c <= 2608 || (c < 2654 - ? (c < 2616 - ? (c < 2613 - ? (c >= 2610 && c <= 2611) - : c <= 2614) - : (c <= 2617 || (c >= 2649 && c <= 2652))) - : (c <= 2654 || (c < 2703 - ? (c < 2693 - ? (c >= 2674 && c <= 2676) - : c <= 2701) - : (c <= 2705 || (c >= 2707 && c <= 2728))))))))))) - : (c <= 2736 || (c < 3261 - ? (c < 2969 - ? (c < 2866 - ? (c < 2809 - ? (c < 2749 - ? (c < 2741 - ? (c >= 2738 && c <= 2739) - : c <= 2745) - : (c <= 2749 || (c < 2784 - ? c == 2768 - : c <= 2785))) - : (c <= 2809 || (c < 2835 - ? (c < 2831 - ? (c >= 2821 && c <= 2828) - : c <= 2832) - : (c <= 2856 || (c >= 2858 && c <= 2864))))) - : (c <= 2867 || (c < 2929 - ? (c < 2908 - ? (c < 2877 - ? (c >= 2869 && c <= 2873) - : c <= 2877) - : (c <= 2909 || (c >= 2911 && c <= 2913))) - : (c <= 2929 || (c < 2958 - ? (c < 2949 - ? c == 2947 - : c <= 2954) - : (c <= 2960 || (c >= 2962 && c <= 2965))))))) - : (c <= 2970 || (c < 3133 - ? (c < 3024 - ? (c < 2979 - ? (c < 2974 - ? c == 2972 - : c <= 2975) - : (c <= 2980 || (c < 2990 - ? (c >= 2984 && c <= 2986) - : c <= 3001))) - : (c <= 3024 || (c < 3090 - ? (c < 3086 - ? (c >= 3077 && c <= 3084) - : c <= 3088) - : (c <= 3112 || (c >= 3114 && c <= 3129))))) - : (c <= 3133 || (c < 3205 - ? (c < 3168 - ? (c < 3165 - ? (c >= 3160 && c <= 3162) - : c <= 3165) - : (c <= 3169 || c == 3200)) - : (c <= 3212 || (c < 3242 - ? (c < 3218 - ? (c >= 3214 && c <= 3216) - : c <= 3240) - : (c <= 3251 || (c >= 3253 && c <= 3257))))))))) - : (c <= 3261 || (c < 3716 - ? (c < 3450 - ? (c < 3346 - ? (c < 3313 - ? (c < 3296 - ? (c >= 3293 && c <= 3294) - : c <= 3297) - : (c <= 3314 || (c < 3342 - ? (c >= 3332 && c <= 3340) - : c <= 3344))) - : (c <= 3386 || (c < 3412 - ? (c < 3406 - ? c == 3389 - : c <= 3406) - : (c <= 3414 || (c >= 3423 && c <= 3425))))) - : (c <= 3455 || (c < 3520 - ? (c < 3507 - ? (c < 3482 - ? (c >= 3461 && c <= 3478) - : c <= 3505) - : (c <= 3515 || c == 3517)) - : (c <= 3526 || (c < 3648 - ? (c < 3634 - ? (c >= 3585 && c <= 3632) - : c <= 3634) - : (c <= 3654 || (c >= 3713 && c <= 3714))))))) - : (c <= 3716 || (c < 3840 - ? (c < 3762 - ? (c < 3749 - ? (c < 3724 - ? (c >= 3718 && c <= 3722) - : c <= 3747) - : (c <= 3749 || (c >= 3751 && c <= 3760))) - : (c <= 3762 || (c < 3782 - ? (c < 3776 - ? c == 3773 - : c <= 3780) - : (c <= 3782 || (c >= 3804 && c <= 3807))))) - : (c <= 3840 || (c < 4159 - ? (c < 3976 - ? (c < 3913 - ? (c >= 3904 && c <= 3911) - : c <= 3948) - : (c <= 3980 || (c >= 4096 && c <= 4138))) - : (c <= 4159 || (c < 4193 - ? (c < 4186 - ? (c >= 4176 && c <= 4181) - : c <= 4189) - : (c <= 4193 || (c >= 4197 && c <= 4198))))))))))))) - : (c <= 4208 || (c < 8178 - ? (c < 6320 - ? (c < 4882 - ? (c < 4698 - ? (c < 4304 - ? (c < 4256 - ? (c < 4238 - ? (c >= 4213 && c <= 4225) - : c <= 4238) - : (c <= 4293 || (c < 4301 - ? c == 4295 - : c <= 4301))) - : (c <= 4346 || (c < 4688 - ? (c < 4682 - ? (c >= 4348 && c <= 4680) - : c <= 4685) - : (c <= 4694 || c == 4696)))) - : (c <= 4701 || (c < 4792 - ? (c < 4752 - ? (c < 4746 - ? (c >= 4704 && c <= 4744) - : c <= 4749) - : (c <= 4784 || (c >= 4786 && c <= 4789))) - : (c <= 4798 || (c < 4808 - ? (c < 4802 - ? c == 4800 - : c <= 4805) - : (c <= 4822 || (c >= 4824 && c <= 4880))))))) - : (c <= 4885 || (c < 5919 - ? (c < 5743 - ? (c < 5024 - ? (c < 4992 - ? (c >= 4888 && c <= 4954) - : c <= 5007) - : (c <= 5109 || (c < 5121 - ? (c >= 5112 && c <= 5117) - : c <= 5740))) - : (c <= 5759 || (c < 5870 - ? (c < 5792 - ? (c >= 5761 && c <= 5786) - : c <= 5866) - : (c <= 5880 || (c >= 5888 && c <= 5905))))) - : (c <= 5937 || (c < 6103 - ? (c < 5998 - ? (c < 5984 - ? (c >= 5952 && c <= 5969) - : c <= 5996) - : (c <= 6000 || (c >= 6016 && c <= 6067))) - : (c <= 6103 || (c < 6272 - ? (c < 6176 - ? c == 6108 - : c <= 6264) - : (c <= 6312 || c == 6314)))))))) - : (c <= 6389 || (c < 7406 - ? (c < 7043 - ? (c < 6656 - ? (c < 6512 - ? (c < 6480 - ? (c >= 6400 && c <= 6430) - : c <= 6509) - : (c <= 6516 || (c < 6576 - ? (c >= 6528 && c <= 6571) - : c <= 6601))) - : (c <= 6678 || (c < 6917 - ? (c < 6823 - ? (c >= 6688 && c <= 6740) - : c <= 6823) - : (c <= 6963 || (c >= 6981 && c <= 6988))))) - : (c <= 7072 || (c < 7258 - ? (c < 7168 - ? (c < 7098 - ? (c >= 7086 && c <= 7087) - : c <= 7141) - : (c <= 7203 || (c >= 7245 && c <= 7247))) - : (c <= 7293 || (c < 7357 - ? (c < 7312 - ? (c >= 7296 && c <= 7304) - : c <= 7354) - : (c <= 7359 || (c >= 7401 && c <= 7404))))))) - : (c <= 7411 || (c < 8029 - ? (c < 7968 - ? (c < 7424 - ? (c < 7418 - ? (c >= 7413 && c <= 7414) - : c <= 7418) - : (c <= 7615 || (c < 7960 - ? (c >= 7680 && c <= 7957) - : c <= 7965))) - : (c <= 8005 || (c < 8025 - ? (c < 8016 - ? (c >= 8008 && c <= 8013) - : c <= 8023) - : (c <= 8025 || c == 8027)))) - : (c <= 8029 || (c < 8130 - ? (c < 8118 - ? (c < 8064 - ? (c >= 8031 && c <= 8061) - : c <= 8116) - : (c <= 8124 || c == 8126)) - : (c <= 8132 || (c < 8150 - ? (c < 8144 - ? (c >= 8134 && c <= 8140) - : c <= 8147) - : (c <= 8155 || (c >= 8160 && c <= 8172))))))))))) - : (c <= 8180 || (c < 12540 - ? (c < 11520 - ? (c < 8486 - ? (c < 8455 - ? (c < 8319 - ? (c < 8305 - ? (c >= 8182 && c <= 8188) - : c <= 8305) - : (c <= 8319 || (c < 8450 - ? (c >= 8336 && c <= 8348) - : c <= 8450))) - : (c <= 8455 || (c < 8472 - ? (c < 8469 - ? (c >= 8458 && c <= 8467) - : c <= 8469) - : (c <= 8477 || c == 8484)))) - : (c <= 8486 || (c < 8526 - ? (c < 8508 - ? (c < 8490 - ? c == 8488 - : c <= 8505) - : (c <= 8511 || (c >= 8517 && c <= 8521))) - : (c <= 8526 || (c < 11499 - ? (c < 11264 - ? (c >= 8544 && c <= 8584) - : c <= 11492) - : (c <= 11502 || (c >= 11506 && c <= 11507))))))) - : (c <= 11557 || (c < 11720 - ? (c < 11680 - ? (c < 11568 - ? (c < 11565 - ? c == 11559 - : c <= 11565) - : (c <= 11623 || (c < 11648 - ? c == 11631 - : c <= 11670))) - : (c <= 11686 || (c < 11704 - ? (c < 11696 - ? (c >= 11688 && c <= 11694) - : c <= 11702) - : (c <= 11710 || (c >= 11712 && c <= 11718))))) - : (c <= 11726 || (c < 12337 - ? (c < 12293 - ? (c < 11736 - ? (c >= 11728 && c <= 11734) - : c <= 11742) - : (c <= 12295 || (c >= 12321 && c <= 12329))) - : (c <= 12341 || (c < 12445 - ? (c < 12353 - ? (c >= 12344 && c <= 12348) - : c <= 12438) - : (c <= 12447 || (c >= 12449 && c <= 12538))))))))) - : (c <= 12543 || (c < 43011 - ? (c < 42560 - ? (c < 19968 - ? (c < 12704 - ? (c < 12593 - ? (c >= 12549 && c <= 12591) - : c <= 12686) - : (c <= 12735 || (c < 13312 - ? (c >= 12784 && c <= 12799) - : c <= 19903))) - : (c <= 42124 || (c < 42512 - ? (c < 42240 - ? (c >= 42192 && c <= 42237) - : c <= 42508) - : (c <= 42527 || (c >= 42538 && c <= 42539))))) - : (c <= 42606 || (c < 42891 - ? (c < 42775 - ? (c < 42656 - ? (c >= 42623 && c <= 42653) - : c <= 42735) - : (c <= 42783 || (c >= 42786 && c <= 42888))) - : (c <= 42954 || (c < 42965 - ? (c < 42963 - ? (c >= 42960 && c <= 42961) - : c <= 42963) - : (c <= 42969 || (c >= 42994 && c <= 43009))))))) - : (c <= 43013 || (c < 43360 - ? (c < 43250 - ? (c < 43072 - ? (c < 43020 - ? (c >= 43015 && c <= 43018) - : c <= 43042) - : (c <= 43123 || (c >= 43138 && c <= 43187))) - : (c <= 43255 || (c < 43274 - ? (c < 43261 - ? c == 43259 - : c <= 43262) - : (c <= 43301 || (c >= 43312 && c <= 43334))))) - : (c <= 43388 || (c < 43514 - ? (c < 43488 - ? (c < 43471 - ? (c >= 43396 && c <= 43442) - : c <= 43471) - : (c <= 43492 || (c >= 43494 && c <= 43503))) - : (c <= 43518 || (c < 43588 - ? (c < 43584 - ? (c >= 43520 && c <= 43560) - : c <= 43586) - : (c <= 43595 || (c >= 43616 && c <= 43638))))))))))))))) - : (c <= 43642 || (c < 71168 - ? (c < 67392 - ? (c < 65147 - ? (c < 63744 - ? (c < 43785 - ? (c < 43714 - ? (c < 43701 - ? (c < 43697 - ? (c >= 43646 && c <= 43695) - : c <= 43697) - : (c <= 43702 || (c < 43712 - ? (c >= 43705 && c <= 43709) - : c <= 43712))) - : (c <= 43714 || (c < 43762 - ? (c < 43744 - ? (c >= 43739 && c <= 43741) - : c <= 43754) - : (c <= 43764 || (c >= 43777 && c <= 43782))))) - : (c <= 43790 || (c < 43868 - ? (c < 43816 - ? (c < 43808 - ? (c >= 43793 && c <= 43798) - : c <= 43814) - : (c <= 43822 || (c >= 43824 && c <= 43866))) - : (c <= 43881 || (c < 55216 - ? (c < 44032 - ? (c >= 43888 && c <= 44002) - : c <= 55203) - : (c <= 55238 || (c >= 55243 && c <= 55291))))))) - : (c <= 64109 || (c < 64326 - ? (c < 64298 - ? (c < 64275 - ? (c < 64256 - ? (c >= 64112 && c <= 64217) - : c <= 64262) - : (c <= 64279 || (c < 64287 - ? c == 64285 - : c <= 64296))) - : (c <= 64310 || (c < 64320 - ? (c < 64318 - ? (c >= 64312 && c <= 64316) - : c <= 64318) - : (c <= 64321 || (c >= 64323 && c <= 64324))))) - : (c <= 64433 || (c < 65008 - ? (c < 64848 - ? (c < 64612 - ? (c >= 64467 && c <= 64605) - : c <= 64829) - : (c <= 64911 || (c >= 64914 && c <= 64967))) - : (c <= 65017 || (c < 65143 - ? (c < 65139 - ? c == 65137 - : c <= 65139) - : (c <= 65143 || c == 65145)))))))) - : (c <= 65147 || (c < 66304 - ? (c < 65536 - ? (c < 65440 - ? (c < 65313 - ? (c < 65151 - ? c == 65149 - : c <= 65276) - : (c <= 65338 || (c < 65382 - ? (c >= 65345 && c <= 65370) - : c <= 65437))) - : (c <= 65470 || (c < 65490 - ? (c < 65482 - ? (c >= 65474 && c <= 65479) - : c <= 65487) - : (c <= 65495 || (c >= 65498 && c <= 65500))))) - : (c <= 65547 || (c < 65616 - ? (c < 65596 - ? (c < 65576 - ? (c >= 65549 && c <= 65574) - : c <= 65594) - : (c <= 65597 || (c >= 65599 && c <= 65613))) - : (c <= 65629 || (c < 66176 - ? (c < 65856 - ? (c >= 65664 && c <= 65786) - : c <= 65908) - : (c <= 66204 || (c >= 66208 && c <= 66256))))))) - : (c <= 66335 || (c < 66864 - ? (c < 66513 - ? (c < 66432 - ? (c < 66384 - ? (c >= 66349 && c <= 66378) - : c <= 66421) - : (c <= 66461 || (c < 66504 - ? (c >= 66464 && c <= 66499) - : c <= 66511))) - : (c <= 66517 || (c < 66776 - ? (c < 66736 - ? (c >= 66560 && c <= 66717) - : c <= 66771) - : (c <= 66811 || (c >= 66816 && c <= 66855))))) - : (c <= 66915 || (c < 66967 - ? (c < 66956 - ? (c < 66940 - ? (c >= 66928 && c <= 66938) - : c <= 66954) - : (c <= 66962 || (c >= 66964 && c <= 66965))) - : (c <= 66977 || (c < 67003 - ? (c < 66995 - ? (c >= 66979 && c <= 66993) - : c <= 67001) - : (c <= 67004 || (c >= 67072 && c <= 67382))))))))))) - : (c <= 67413 || (c < 69600 - ? (c < 68117 - ? (c < 67680 - ? (c < 67592 - ? (c < 67463 - ? (c < 67456 - ? (c >= 67424 && c <= 67431) - : c <= 67461) - : (c <= 67504 || (c < 67584 - ? (c >= 67506 && c <= 67514) - : c <= 67589))) - : (c <= 67592 || (c < 67644 - ? (c < 67639 - ? (c >= 67594 && c <= 67637) - : c <= 67640) - : (c <= 67644 || (c >= 67647 && c <= 67669))))) - : (c <= 67702 || (c < 67872 - ? (c < 67828 - ? (c < 67808 - ? (c >= 67712 && c <= 67742) - : c <= 67826) - : (c <= 67829 || (c >= 67840 && c <= 67861))) - : (c <= 67897 || (c < 68096 - ? (c < 68030 - ? (c >= 67968 && c <= 68023) - : c <= 68031) - : (c <= 68096 || (c >= 68112 && c <= 68115))))))) - : (c <= 68119 || (c < 68736 - ? (c < 68352 - ? (c < 68224 - ? (c < 68192 - ? (c >= 68121 && c <= 68149) - : c <= 68220) - : (c <= 68252 || (c < 68297 - ? (c >= 68288 && c <= 68295) - : c <= 68324))) - : (c <= 68405 || (c < 68480 - ? (c < 68448 - ? (c >= 68416 && c <= 68437) - : c <= 68466) - : (c <= 68497 || (c >= 68608 && c <= 68680))))) - : (c <= 68786 || (c < 69376 - ? (c < 69248 - ? (c < 68864 - ? (c >= 68800 && c <= 68850) - : c <= 68899) - : (c <= 69289 || (c >= 69296 && c <= 69297))) - : (c <= 69404 || (c < 69488 - ? (c < 69424 - ? c == 69415 - : c <= 69445) - : (c <= 69505 || (c >= 69552 && c <= 69572))))))))) - : (c <= 69622 || (c < 70287 - ? (c < 70019 - ? (c < 69891 - ? (c < 69749 - ? (c < 69745 - ? (c >= 69635 && c <= 69687) - : c <= 69746) - : (c <= 69749 || (c < 69840 - ? (c >= 69763 && c <= 69807) - : c <= 69864))) - : (c <= 69926 || (c < 69968 - ? (c < 69959 - ? c == 69956 - : c <= 69959) - : (c <= 70002 || c == 70006)))) - : (c <= 70066 || (c < 70163 - ? (c < 70108 - ? (c < 70106 - ? (c >= 70081 && c <= 70084) - : c <= 70106) - : (c <= 70108 || (c >= 70144 && c <= 70161))) - : (c <= 70187 || (c < 70280 - ? (c < 70272 - ? (c >= 70207 && c <= 70208) - : c <= 70278) - : (c <= 70280 || (c >= 70282 && c <= 70285))))))) - : (c <= 70301 || (c < 70480 - ? (c < 70419 - ? (c < 70405 - ? (c < 70320 - ? (c >= 70303 && c <= 70312) - : c <= 70366) - : (c <= 70412 || (c >= 70415 && c <= 70416))) - : (c <= 70440 || (c < 70453 - ? (c < 70450 - ? (c >= 70442 && c <= 70448) - : c <= 70451) - : (c <= 70457 || c == 70461)))) - : (c <= 70480 || (c < 70784 - ? (c < 70727 - ? (c < 70656 - ? (c >= 70493 && c <= 70497) - : c <= 70708) - : (c <= 70730 || (c >= 70751 && c <= 70753))) - : (c <= 70831 || (c < 71040 - ? (c < 70855 - ? (c >= 70852 && c <= 70853) - : c <= 70855) - : (c <= 71086 || (c >= 71128 && c <= 71131))))))))))))) - : (c <= 71215 || (c < 119973 - ? (c < 73648 - ? (c < 72250 - ? (c < 71957 - ? (c < 71680 - ? (c < 71352 - ? (c < 71296 - ? c == 71236 - : c <= 71338) - : (c <= 71352 || (c < 71488 - ? (c >= 71424 && c <= 71450) - : c <= 71494))) - : (c <= 71723 || (c < 71945 - ? (c < 71935 - ? (c >= 71840 && c <= 71903) - : c <= 71942) - : (c <= 71945 || (c >= 71948 && c <= 71955))))) - : (c <= 71958 || (c < 72106 - ? (c < 72001 - ? (c < 71999 - ? (c >= 71960 && c <= 71983) - : c <= 71999) - : (c <= 72001 || (c >= 72096 && c <= 72103))) - : (c <= 72144 || (c < 72192 - ? (c < 72163 - ? c == 72161 - : c <= 72163) - : (c <= 72192 || (c >= 72203 && c <= 72242))))))) - : (c <= 72250 || (c < 72971 - ? (c < 72714 - ? (c < 72349 - ? (c < 72284 - ? c == 72272 - : c <= 72329) - : (c <= 72349 || (c < 72704 - ? (c >= 72368 && c <= 72440) - : c <= 72712))) - : (c <= 72750 || (c < 72960 - ? (c < 72818 - ? c == 72768 - : c <= 72847) - : (c <= 72966 || (c >= 72968 && c <= 72969))))) - : (c <= 73008 || (c < 73112 - ? (c < 73063 - ? (c < 73056 - ? c == 73030 - : c <= 73061) - : (c <= 73064 || (c >= 73066 && c <= 73097))) - : (c <= 73112 || (c < 73476 - ? (c < 73474 - ? (c >= 73440 && c <= 73458) - : c <= 73474) - : (c <= 73488 || (c >= 73490 && c <= 73523))))))))) - : (c <= 73648 || (c < 94179 - ? (c < 92880 - ? (c < 78913 - ? (c < 74880 - ? (c < 74752 - ? (c >= 73728 && c <= 74649) - : c <= 74862) - : (c <= 75075 || (c < 77824 - ? (c >= 77712 && c <= 77808) - : c <= 78895))) - : (c <= 78918 || (c < 92736 - ? (c < 92160 - ? (c >= 82944 && c <= 83526) - : c <= 92728) - : (c <= 92766 || (c >= 92784 && c <= 92862))))) - : (c <= 92909 || (c < 93760 - ? (c < 93027 - ? (c < 92992 - ? (c >= 92928 && c <= 92975) - : c <= 92995) - : (c <= 93047 || (c >= 93053 && c <= 93071))) - : (c <= 93823 || (c < 94099 - ? (c < 94032 - ? (c >= 93952 && c <= 94026) - : c <= 94032) - : (c <= 94111 || (c >= 94176 && c <= 94177))))))) - : (c <= 94179 || (c < 110948 - ? (c < 110589 - ? (c < 101632 - ? (c < 100352 - ? (c >= 94208 && c <= 100343) - : c <= 101589) - : (c <= 101640 || (c < 110581 - ? (c >= 110576 && c <= 110579) - : c <= 110587))) - : (c <= 110590 || (c < 110928 - ? (c < 110898 - ? (c >= 110592 && c <= 110882) - : c <= 110898) - : (c <= 110930 || c == 110933)))) - : (c <= 110951 || (c < 113808 - ? (c < 113776 - ? (c < 113664 - ? (c >= 110960 && c <= 111355) - : c <= 113770) - : (c <= 113788 || (c >= 113792 && c <= 113800))) - : (c <= 113817 || (c < 119966 - ? (c < 119894 - ? (c >= 119808 && c <= 119892) - : c <= 119964) - : (c <= 119967 || c == 119970)))))))))) - : (c <= 119974 || (c < 126464 - ? (c < 120656 - ? (c < 120128 - ? (c < 120071 - ? (c < 119995 - ? (c < 119982 - ? (c >= 119977 && c <= 119980) - : c <= 119993) - : (c <= 119995 || (c < 120005 - ? (c >= 119997 && c <= 120003) - : c <= 120069))) - : (c <= 120074 || (c < 120094 - ? (c < 120086 - ? (c >= 120077 && c <= 120084) - : c <= 120092) - : (c <= 120121 || (c >= 120123 && c <= 120126))))) - : (c <= 120132 || (c < 120514 - ? (c < 120146 - ? (c < 120138 - ? c == 120134 - : c <= 120144) - : (c <= 120485 || (c >= 120488 && c <= 120512))) - : (c <= 120538 || (c < 120598 - ? (c < 120572 - ? (c >= 120540 && c <= 120570) - : c <= 120596) - : (c <= 120628 || (c >= 120630 && c <= 120654))))))) - : (c <= 120686 || (c < 123536 - ? (c < 122661 - ? (c < 120746 - ? (c < 120714 - ? (c >= 120688 && c <= 120712) - : c <= 120744) - : (c <= 120770 || (c < 122624 - ? (c >= 120772 && c <= 120779) - : c <= 122654))) - : (c <= 122666 || (c < 123191 - ? (c < 123136 - ? (c >= 122928 && c <= 122989) - : c <= 123180) - : (c <= 123197 || c == 123214)))) - : (c <= 123565 || (c < 124909 - ? (c < 124896 - ? (c < 124112 - ? (c >= 123584 && c <= 123627) - : c <= 124139) - : (c <= 124902 || (c >= 124904 && c <= 124907))) - : (c <= 124910 || (c < 125184 - ? (c < 124928 - ? (c >= 124912 && c <= 124926) - : c <= 125124) - : (c <= 125251 || c == 125259)))))))) - : (c <= 126467 || (c < 126561 - ? (c < 126537 - ? (c < 126516 - ? (c < 126500 - ? (c < 126497 - ? (c >= 126469 && c <= 126495) - : c <= 126498) - : (c <= 126500 || (c < 126505 - ? c == 126503 - : c <= 126514))) - : (c <= 126519 || (c < 126530 - ? (c < 126523 - ? c == 126521 - : c <= 126523) - : (c <= 126530 || c == 126535)))) - : (c <= 126537 || (c < 126551 - ? (c < 126545 - ? (c < 126541 - ? c == 126539 - : c <= 126543) - : (c <= 126546 || c == 126548)) - : (c <= 126551 || (c < 126557 - ? (c < 126555 - ? c == 126553 - : c <= 126555) - : (c <= 126557 || c == 126559)))))) - : (c <= 126562 || (c < 126629 - ? (c < 126585 - ? (c < 126572 - ? (c < 126567 - ? c == 126564 - : c <= 126570) - : (c <= 126578 || (c >= 126580 && c <= 126583))) - : (c <= 126588 || (c < 126603 - ? (c < 126592 - ? c == 126590 - : c <= 126601) - : (c <= 126619 || (c >= 126625 && c <= 126627))))) - : (c <= 126633 || (c < 178208 - ? (c < 173824 - ? (c < 131072 - ? (c >= 126635 && c <= 126651) - : c <= 173791) - : (c <= 177977 || (c >= 177984 && c <= 178205))) - : (c <= 183969 || (c < 196608 - ? (c < 194560 - ? (c >= 183984 && c <= 191456) - : c <= 195101) - : (c <= 201546 || (c >= 201552 && c <= 205743))))))))))))))))); -} - -static inline bool sym_identifier_character_set_2(int32_t c) { - return (c < 43785 - ? (c < 3804 - ? (c < 2759 - ? (c < 2048 - ? (c < 1155 - ? (c < 736 - ? (c < 183 - ? (c < 'a' - ? (c < 'A' - ? (c >= '0' && c <= '9') - : (c <= 'Z' || c == '_')) - : (c <= 'z' || (c < 181 - ? c == 170 - : c <= 181))) - : (c <= 183 || (c < 216 - ? (c < 192 - ? c == 186 - : c <= 214) - : (c <= 246 || (c < 710 - ? (c >= 248 && c <= 705) - : c <= 721))))) - : (c <= 740 || (c < 895 - ? (c < 768 - ? (c < 750 - ? c == 748 - : c <= 750) - : (c <= 884 || (c < 891 - ? (c >= 886 && c <= 887) - : c <= 893))) - : (c <= 895 || (c < 910 - ? (c < 908 - ? (c >= 902 && c <= 906) - : c <= 908) - : (c <= 929 || (c < 1015 - ? (c >= 931 && c <= 1013) - : c <= 1153))))))) - : (c <= 1159 || (c < 1552 - ? (c < 1471 - ? (c < 1369 - ? (c < 1329 - ? (c >= 1162 && c <= 1327) - : c <= 1366) - : (c <= 1369 || (c < 1425 - ? (c >= 1376 && c <= 1416) - : c <= 1469))) - : (c <= 1471 || (c < 1479 - ? (c < 1476 - ? (c >= 1473 && c <= 1474) - : c <= 1477) - : (c <= 1479 || (c < 1519 - ? (c >= 1488 && c <= 1514) - : c <= 1522))))) - : (c <= 1562 || (c < 1791 - ? (c < 1749 - ? (c < 1646 - ? (c >= 1568 && c <= 1641) - : c <= 1747) - : (c <= 1756 || (c < 1770 - ? (c >= 1759 && c <= 1768) - : c <= 1788))) - : (c <= 1791 || (c < 1984 - ? (c < 1869 - ? (c >= 1808 && c <= 1866) - : c <= 1969) - : (c <= 2037 || (c < 2045 - ? c == 2042 - : c <= 2045))))))))) - : (c <= 2093 || (c < 2561 - ? (c < 2474 - ? (c < 2275 - ? (c < 2160 - ? (c < 2144 - ? (c >= 2112 && c <= 2139) - : c <= 2154) - : (c <= 2183 || (c < 2200 - ? (c >= 2185 && c <= 2190) - : c <= 2273))) - : (c <= 2403 || (c < 2437 - ? (c < 2417 - ? (c >= 2406 && c <= 2415) - : c <= 2435) - : (c <= 2444 || (c < 2451 - ? (c >= 2447 && c <= 2448) - : c <= 2472))))) - : (c <= 2480 || (c < 2519 - ? (c < 2492 - ? (c < 2486 - ? c == 2482 - : c <= 2489) - : (c <= 2500 || (c < 2507 - ? (c >= 2503 && c <= 2504) - : c <= 2510))) - : (c <= 2519 || (c < 2534 - ? (c < 2527 - ? (c >= 2524 && c <= 2525) - : c <= 2531) - : (c <= 2545 || (c < 2558 - ? c == 2556 - : c <= 2558))))))) - : (c <= 2563 || (c < 2641 - ? (c < 2613 - ? (c < 2579 - ? (c < 2575 - ? (c >= 2565 && c <= 2570) - : c <= 2576) - : (c <= 2600 || (c < 2610 - ? (c >= 2602 && c <= 2608) - : c <= 2611))) - : (c <= 2614 || (c < 2622 - ? (c < 2620 - ? (c >= 2616 && c <= 2617) - : c <= 2620) - : (c <= 2626 || (c < 2635 - ? (c >= 2631 && c <= 2632) - : c <= 2637))))) - : (c <= 2641 || (c < 2703 - ? (c < 2662 - ? (c < 2654 - ? (c >= 2649 && c <= 2652) - : c <= 2654) - : (c <= 2677 || (c < 2693 - ? (c >= 2689 && c <= 2691) - : c <= 2701))) - : (c <= 2705 || (c < 2738 - ? (c < 2730 - ? (c >= 2707 && c <= 2728) - : c <= 2736) - : (c <= 2739 || (c < 2748 - ? (c >= 2741 && c <= 2745) - : c <= 2757))))))))))) - : (c <= 2761 || (c < 3200 - ? (c < 2969 - ? (c < 2876 - ? (c < 2821 - ? (c < 2790 - ? (c < 2768 - ? (c >= 2763 && c <= 2765) - : (c <= 2768 || (c >= 2784 && c <= 2787))) - : (c <= 2799 || (c < 2817 - ? (c >= 2809 && c <= 2815) - : c <= 2819))) - : (c <= 2828 || (c < 2858 - ? (c < 2835 - ? (c >= 2831 && c <= 2832) - : c <= 2856) - : (c <= 2864 || (c < 2869 - ? (c >= 2866 && c <= 2867) - : c <= 2873))))) - : (c <= 2884 || (c < 2918 - ? (c < 2901 - ? (c < 2891 - ? (c >= 2887 && c <= 2888) - : c <= 2893) - : (c <= 2903 || (c < 2911 - ? (c >= 2908 && c <= 2909) - : c <= 2915))) - : (c <= 2927 || (c < 2949 - ? (c < 2946 - ? c == 2929 - : c <= 2947) - : (c <= 2954 || (c < 2962 - ? (c >= 2958 && c <= 2960) - : c <= 2965))))))) - : (c <= 2970 || (c < 3072 - ? (c < 3006 - ? (c < 2979 - ? (c < 2974 - ? c == 2972 - : c <= 2975) - : (c <= 2980 || (c < 2990 - ? (c >= 2984 && c <= 2986) - : c <= 3001))) - : (c <= 3010 || (c < 3024 - ? (c < 3018 - ? (c >= 3014 && c <= 3016) - : c <= 3021) - : (c <= 3024 || (c < 3046 - ? c == 3031 - : c <= 3055))))) - : (c <= 3084 || (c < 3146 - ? (c < 3114 - ? (c < 3090 - ? (c >= 3086 && c <= 3088) - : c <= 3112) - : (c <= 3129 || (c < 3142 - ? (c >= 3132 && c <= 3140) - : c <= 3144))) - : (c <= 3149 || (c < 3165 - ? (c < 3160 - ? (c >= 3157 && c <= 3158) - : c <= 3162) - : (c <= 3165 || (c < 3174 - ? (c >= 3168 && c <= 3171) - : c <= 3183))))))))) - : (c <= 3203 || (c < 3461 - ? (c < 3302 - ? (c < 3260 - ? (c < 3218 - ? (c < 3214 - ? (c >= 3205 && c <= 3212) - : c <= 3216) - : (c <= 3240 || (c < 3253 - ? (c >= 3242 && c <= 3251) - : c <= 3257))) - : (c <= 3268 || (c < 3285 - ? (c < 3274 - ? (c >= 3270 && c <= 3272) - : c <= 3277) - : (c <= 3286 || (c < 3296 - ? (c >= 3293 && c <= 3294) - : c <= 3299))))) - : (c <= 3311 || (c < 3402 - ? (c < 3342 - ? (c < 3328 - ? (c >= 3313 && c <= 3315) - : c <= 3340) - : (c <= 3344 || (c < 3398 - ? (c >= 3346 && c <= 3396) - : c <= 3400))) - : (c <= 3406 || (c < 3430 - ? (c < 3423 - ? (c >= 3412 && c <= 3415) - : c <= 3427) - : (c <= 3439 || (c < 3457 - ? (c >= 3450 && c <= 3455) - : c <= 3459))))))) - : (c <= 3478 || (c < 3648 - ? (c < 3535 - ? (c < 3517 - ? (c < 3507 - ? (c >= 3482 && c <= 3505) - : c <= 3515) - : (c <= 3517 || (c < 3530 - ? (c >= 3520 && c <= 3526) - : c <= 3530))) - : (c <= 3540 || (c < 3558 - ? (c < 3544 - ? c == 3542 - : c <= 3551) - : (c <= 3567 || (c < 3585 - ? (c >= 3570 && c <= 3571) - : c <= 3642))))) - : (c <= 3662 || (c < 3749 - ? (c < 3716 - ? (c < 3713 - ? (c >= 3664 && c <= 3673) - : c <= 3714) - : (c <= 3716 || (c < 3724 - ? (c >= 3718 && c <= 3722) - : c <= 3747))) - : (c <= 3749 || (c < 3782 - ? (c < 3776 - ? (c >= 3751 && c <= 3773) - : c <= 3780) - : (c <= 3782 || (c < 3792 - ? (c >= 3784 && c <= 3790) - : c <= 3801))))))))))))) - : (c <= 3807 || (c < 8064 - ? (c < 5998 - ? (c < 4746 - ? (c < 4096 - ? (c < 3902 - ? (c < 3893 - ? (c < 3864 - ? c == 3840 - : (c <= 3865 || (c >= 3872 && c <= 3881))) - : (c <= 3893 || (c < 3897 - ? c == 3895 - : c <= 3897))) - : (c <= 3911 || (c < 3974 - ? (c < 3953 - ? (c >= 3913 && c <= 3948) - : c <= 3972) - : (c <= 3991 || (c < 4038 - ? (c >= 3993 && c <= 4028) - : c <= 4038))))) - : (c <= 4169 || (c < 4348 - ? (c < 4295 - ? (c < 4256 - ? (c >= 4176 && c <= 4253) - : c <= 4293) - : (c <= 4295 || (c < 4304 - ? c == 4301 - : c <= 4346))) - : (c <= 4680 || (c < 4696 - ? (c < 4688 - ? (c >= 4682 && c <= 4685) - : c <= 4694) - : (c <= 4696 || (c < 4704 - ? (c >= 4698 && c <= 4701) - : c <= 4744))))))) - : (c <= 4749 || (c < 4992 - ? (c < 4808 - ? (c < 4792 - ? (c < 4786 - ? (c >= 4752 && c <= 4784) - : c <= 4789) - : (c <= 4798 || (c < 4802 - ? c == 4800 - : c <= 4805))) - : (c <= 4822 || (c < 4888 - ? (c < 4882 - ? (c >= 4824 && c <= 4880) - : c <= 4885) - : (c <= 4954 || (c < 4969 - ? (c >= 4957 && c <= 4959) - : c <= 4977))))) - : (c <= 5007 || (c < 5792 - ? (c < 5121 - ? (c < 5112 - ? (c >= 5024 && c <= 5109) - : c <= 5117) - : (c <= 5740 || (c < 5761 - ? (c >= 5743 && c <= 5759) - : c <= 5786))) - : (c <= 5866 || (c < 5919 - ? (c < 5888 - ? (c >= 5870 && c <= 5880) - : c <= 5909) - : (c <= 5940 || (c < 5984 - ? (c >= 5952 && c <= 5971) - : c <= 5996))))))))) - : (c <= 6000 || (c < 6823 - ? (c < 6432 - ? (c < 6155 - ? (c < 6103 - ? (c < 6016 - ? (c >= 6002 && c <= 6003) - : c <= 6099) - : (c <= 6103 || (c < 6112 - ? (c >= 6108 && c <= 6109) - : c <= 6121))) - : (c <= 6157 || (c < 6272 - ? (c < 6176 - ? (c >= 6159 && c <= 6169) - : c <= 6264) - : (c <= 6314 || (c < 6400 - ? (c >= 6320 && c <= 6389) - : c <= 6430))))) - : (c <= 6443 || (c < 6608 - ? (c < 6512 - ? (c < 6470 - ? (c >= 6448 && c <= 6459) - : c <= 6509) - : (c <= 6516 || (c < 6576 - ? (c >= 6528 && c <= 6571) - : c <= 6601))) - : (c <= 6618 || (c < 6752 - ? (c < 6688 - ? (c >= 6656 && c <= 6683) - : c <= 6750) - : (c <= 6780 || (c < 6800 - ? (c >= 6783 && c <= 6793) - : c <= 6809))))))) - : (c <= 6823 || (c < 7357 - ? (c < 7040 - ? (c < 6912 - ? (c < 6847 - ? (c >= 6832 && c <= 6845) - : c <= 6862) - : (c <= 6988 || (c < 7019 - ? (c >= 6992 && c <= 7001) - : c <= 7027))) - : (c <= 7155 || (c < 7245 - ? (c < 7232 - ? (c >= 7168 && c <= 7223) - : c <= 7241) - : (c <= 7293 || (c < 7312 - ? (c >= 7296 && c <= 7304) - : c <= 7354))))) - : (c <= 7359 || (c < 8008 - ? (c < 7424 - ? (c < 7380 - ? (c >= 7376 && c <= 7378) - : c <= 7418) - : (c <= 7957 || (c < 7968 - ? (c >= 7960 && c <= 7965) - : c <= 8005))) - : (c <= 8013 || (c < 8027 - ? (c < 8025 - ? (c >= 8016 && c <= 8023) - : c <= 8025) - : (c <= 8027 || (c < 8031 - ? c == 8029 - : c <= 8061))))))))))) - : (c <= 8116 || (c < 12321 - ? (c < 8488 - ? (c < 8319 - ? (c < 8160 - ? (c < 8134 - ? (c < 8126 - ? (c >= 8118 && c <= 8124) - : (c <= 8126 || (c >= 8130 && c <= 8132))) - : (c <= 8140 || (c < 8150 - ? (c >= 8144 && c <= 8147) - : c <= 8155))) - : (c <= 8172 || (c < 8255 - ? (c < 8182 - ? (c >= 8178 && c <= 8180) - : c <= 8188) - : (c <= 8256 || (c < 8305 - ? c == 8276 - : c <= 8305))))) - : (c <= 8319 || (c < 8455 - ? (c < 8417 - ? (c < 8400 - ? (c >= 8336 && c <= 8348) - : c <= 8412) - : (c <= 8417 || (c < 8450 - ? (c >= 8421 && c <= 8432) - : c <= 8450))) - : (c <= 8455 || (c < 8472 - ? (c < 8469 - ? (c >= 8458 && c <= 8467) - : c <= 8469) - : (c <= 8477 || (c < 8486 - ? c == 8484 - : c <= 8486))))))) - : (c <= 8488 || (c < 11631 - ? (c < 11264 - ? (c < 8517 - ? (c < 8508 - ? (c >= 8490 && c <= 8505) - : c <= 8511) - : (c <= 8521 || (c < 8544 - ? c == 8526 - : c <= 8584))) - : (c <= 11492 || (c < 11559 - ? (c < 11520 - ? (c >= 11499 && c <= 11507) - : c <= 11557) - : (c <= 11559 || (c < 11568 - ? c == 11565 - : c <= 11623))))) - : (c <= 11631 || (c < 11712 - ? (c < 11688 - ? (c < 11680 - ? (c >= 11647 && c <= 11670) - : c <= 11686) - : (c <= 11694 || (c < 11704 - ? (c >= 11696 && c <= 11702) - : c <= 11710))) - : (c <= 11718 || (c < 11736 - ? (c < 11728 - ? (c >= 11720 && c <= 11726) - : c <= 11734) - : (c <= 11742 || (c < 12293 - ? (c >= 11744 && c <= 11775) - : c <= 12295))))))))) - : (c <= 12335 || (c < 42963 - ? (c < 13312 - ? (c < 12449 - ? (c < 12353 - ? (c < 12344 - ? (c >= 12337 && c <= 12341) - : c <= 12348) - : (c <= 12438 || (c < 12445 - ? (c >= 12441 && c <= 12442) - : c <= 12447))) - : (c <= 12538 || (c < 12593 - ? (c < 12549 - ? (c >= 12540 && c <= 12543) - : c <= 12591) - : (c <= 12686 || (c < 12784 - ? (c >= 12704 && c <= 12735) - : c <= 12799))))) - : (c <= 19903 || (c < 42612 - ? (c < 42240 - ? (c < 42192 - ? (c >= 19968 && c <= 42124) - : c <= 42237) - : (c <= 42508 || (c < 42560 - ? (c >= 42512 && c <= 42539) - : c <= 42607))) - : (c <= 42621 || (c < 42786 - ? (c < 42775 - ? (c >= 42623 && c <= 42737) - : c <= 42783) - : (c <= 42888 || (c < 42960 - ? (c >= 42891 && c <= 42954) - : c <= 42961))))))) - : (c <= 42963 || (c < 43392 - ? (c < 43216 - ? (c < 43052 - ? (c < 42994 - ? (c >= 42965 && c <= 42969) - : c <= 43047) - : (c <= 43052 || (c < 43136 - ? (c >= 43072 && c <= 43123) - : c <= 43205))) - : (c <= 43225 || (c < 43261 - ? (c < 43259 - ? (c >= 43232 && c <= 43255) - : c <= 43259) - : (c <= 43309 || (c < 43360 - ? (c >= 43312 && c <= 43347) - : c <= 43388))))) - : (c <= 43456 || (c < 43616 - ? (c < 43520 - ? (c < 43488 - ? (c >= 43471 && c <= 43481) - : c <= 43518) - : (c <= 43574 || (c < 43600 - ? (c >= 43584 && c <= 43597) - : c <= 43609))) - : (c <= 43638 || (c < 43744 - ? (c < 43739 - ? (c >= 43642 && c <= 43714) - : c <= 43741) - : (c <= 43759 || (c < 43777 - ? (c >= 43762 && c <= 43766) - : c <= 43782))))))))))))))) - : (c <= 43790 || (c < 71960 - ? (c < 67840 - ? (c < 65549 - ? (c < 64848 - ? (c < 64112 - ? (c < 44012 - ? (c < 43824 - ? (c < 43808 - ? (c >= 43793 && c <= 43798) - : (c <= 43814 || (c >= 43816 && c <= 43822))) - : (c <= 43866 || (c < 43888 - ? (c >= 43868 && c <= 43881) - : c <= 44010))) - : (c <= 44013 || (c < 55216 - ? (c < 44032 - ? (c >= 44016 && c <= 44025) - : c <= 55203) - : (c <= 55238 || (c < 63744 - ? (c >= 55243 && c <= 55291) - : c <= 64109))))) - : (c <= 64217 || (c < 64318 - ? (c < 64285 - ? (c < 64275 - ? (c >= 64256 && c <= 64262) - : c <= 64279) - : (c <= 64296 || (c < 64312 - ? (c >= 64298 && c <= 64310) - : c <= 64316))) - : (c <= 64318 || (c < 64326 - ? (c < 64323 - ? (c >= 64320 && c <= 64321) - : c <= 64324) - : (c <= 64433 || (c < 64612 - ? (c >= 64467 && c <= 64605) - : c <= 64829))))))) - : (c <= 64911 || (c < 65149 - ? (c < 65101 - ? (c < 65024 - ? (c < 65008 - ? (c >= 64914 && c <= 64967) - : c <= 65017) - : (c <= 65039 || (c < 65075 - ? (c >= 65056 && c <= 65071) - : c <= 65076))) - : (c <= 65103 || (c < 65143 - ? (c < 65139 - ? c == 65137 - : c <= 65139) - : (c <= 65143 || (c < 65147 - ? c == 65145 - : c <= 65147))))) - : (c <= 65149 || (c < 65382 - ? (c < 65313 - ? (c < 65296 - ? (c >= 65151 && c <= 65276) - : c <= 65305) - : (c <= 65338 || (c < 65345 - ? c == 65343 - : c <= 65370))) - : (c <= 65470 || (c < 65490 - ? (c < 65482 - ? (c >= 65474 && c <= 65479) - : c <= 65487) - : (c <= 65495 || (c < 65536 - ? (c >= 65498 && c <= 65500) - : c <= 65547))))))))) - : (c <= 65574 || (c < 66928 - ? (c < 66349 - ? (c < 65856 - ? (c < 65599 - ? (c < 65596 - ? (c >= 65576 && c <= 65594) - : c <= 65597) - : (c <= 65613 || (c < 65664 - ? (c >= 65616 && c <= 65629) - : c <= 65786))) - : (c <= 65908 || (c < 66208 - ? (c < 66176 - ? c == 66045 - : c <= 66204) - : (c <= 66256 || (c < 66304 - ? c == 66272 - : c <= 66335))))) - : (c <= 66378 || (c < 66560 - ? (c < 66464 - ? (c < 66432 - ? (c >= 66384 && c <= 66426) - : c <= 66461) - : (c <= 66499 || (c < 66513 - ? (c >= 66504 && c <= 66511) - : c <= 66517))) - : (c <= 66717 || (c < 66776 - ? (c < 66736 - ? (c >= 66720 && c <= 66729) - : c <= 66771) - : (c <= 66811 || (c < 66864 - ? (c >= 66816 && c <= 66855) - : c <= 66915))))))) - : (c <= 66938 || (c < 67463 - ? (c < 66995 - ? (c < 66964 - ? (c < 66956 - ? (c >= 66940 && c <= 66954) - : c <= 66962) - : (c <= 66965 || (c < 66979 - ? (c >= 66967 && c <= 66977) - : c <= 66993))) - : (c <= 67001 || (c < 67392 - ? (c < 67072 - ? (c >= 67003 && c <= 67004) - : c <= 67382) - : (c <= 67413 || (c < 67456 - ? (c >= 67424 && c <= 67431) - : c <= 67461))))) - : (c <= 67504 || (c < 67644 - ? (c < 67592 - ? (c < 67584 - ? (c >= 67506 && c <= 67514) - : c <= 67589) - : (c <= 67592 || (c < 67639 - ? (c >= 67594 && c <= 67637) - : c <= 67640))) - : (c <= 67644 || (c < 67712 - ? (c < 67680 - ? (c >= 67647 && c <= 67669) - : c <= 67702) - : (c <= 67742 || (c < 67828 - ? (c >= 67808 && c <= 67826) - : c <= 67829))))))))))) - : (c <= 67861 || (c < 70163 - ? (c < 69291 - ? (c < 68288 - ? (c < 68117 - ? (c < 68096 - ? (c < 67968 - ? (c >= 67872 && c <= 67897) - : (c <= 68023 || (c >= 68030 && c <= 68031))) - : (c <= 68099 || (c < 68108 - ? (c >= 68101 && c <= 68102) - : c <= 68115))) - : (c <= 68119 || (c < 68159 - ? (c < 68152 - ? (c >= 68121 && c <= 68149) - : c <= 68154) - : (c <= 68159 || (c < 68224 - ? (c >= 68192 && c <= 68220) - : c <= 68252))))) - : (c <= 68295 || (c < 68608 - ? (c < 68416 - ? (c < 68352 - ? (c >= 68297 && c <= 68326) - : c <= 68405) - : (c <= 68437 || (c < 68480 - ? (c >= 68448 && c <= 68466) - : c <= 68497))) - : (c <= 68680 || (c < 68864 - ? (c < 68800 - ? (c >= 68736 && c <= 68786) - : c <= 68850) - : (c <= 68903 || (c < 69248 - ? (c >= 68912 && c <= 68921) - : c <= 69289))))))) - : (c <= 69292 || (c < 69840 - ? (c < 69552 - ? (c < 69415 - ? (c < 69373 - ? (c >= 69296 && c <= 69297) - : c <= 69404) - : (c <= 69415 || (c < 69488 - ? (c >= 69424 && c <= 69456) - : c <= 69509))) - : (c <= 69572 || (c < 69734 - ? (c < 69632 - ? (c >= 69600 && c <= 69622) - : c <= 69702) - : (c <= 69749 || (c < 69826 - ? (c >= 69759 && c <= 69818) - : c <= 69826))))) - : (c <= 69864 || (c < 70006 - ? (c < 69942 - ? (c < 69888 - ? (c >= 69872 && c <= 69881) - : c <= 69940) - : (c <= 69951 || (c < 69968 - ? (c >= 69956 && c <= 69959) - : c <= 70003))) - : (c <= 70006 || (c < 70094 - ? (c < 70089 - ? (c >= 70016 && c <= 70084) - : c <= 70092) - : (c <= 70106 || (c < 70144 - ? c == 70108 - : c <= 70161))))))))) - : (c <= 70199 || (c < 70656 - ? (c < 70419 - ? (c < 70303 - ? (c < 70280 - ? (c < 70272 - ? (c >= 70206 && c <= 70209) - : c <= 70278) - : (c <= 70280 || (c < 70287 - ? (c >= 70282 && c <= 70285) - : c <= 70301))) - : (c <= 70312 || (c < 70400 - ? (c < 70384 - ? (c >= 70320 && c <= 70378) - : c <= 70393) - : (c <= 70403 || (c < 70415 - ? (c >= 70405 && c <= 70412) - : c <= 70416))))) - : (c <= 70440 || (c < 70475 - ? (c < 70453 - ? (c < 70450 - ? (c >= 70442 && c <= 70448) - : c <= 70451) - : (c <= 70457 || (c < 70471 - ? (c >= 70459 && c <= 70468) - : c <= 70472))) - : (c <= 70477 || (c < 70493 - ? (c < 70487 - ? c == 70480 - : c <= 70487) - : (c <= 70499 || (c < 70512 - ? (c >= 70502 && c <= 70508) - : c <= 70516))))))) - : (c <= 70730 || (c < 71296 - ? (c < 71040 - ? (c < 70784 - ? (c < 70750 - ? (c >= 70736 && c <= 70745) - : c <= 70753) - : (c <= 70853 || (c < 70864 - ? c == 70855 - : c <= 70873))) - : (c <= 71093 || (c < 71168 - ? (c < 71128 - ? (c >= 71096 && c <= 71104) - : c <= 71133) - : (c <= 71232 || (c < 71248 - ? c == 71236 - : c <= 71257))))) - : (c <= 71352 || (c < 71680 - ? (c < 71453 - ? (c < 71424 - ? (c >= 71360 && c <= 71369) - : c <= 71450) - : (c <= 71467 || (c < 71488 - ? (c >= 71472 && c <= 71481) - : c <= 71494))) - : (c <= 71738 || (c < 71945 - ? (c < 71935 - ? (c >= 71840 && c <= 71913) - : c <= 71942) - : (c <= 71945 || (c < 71957 - ? (c >= 71948 && c <= 71955) - : c <= 71958))))))))))))) - : (c <= 71989 || (c < 119995 - ? (c < 92784 - ? (c < 73023 - ? (c < 72704 - ? (c < 72163 - ? (c < 72096 - ? (c < 71995 - ? (c >= 71991 && c <= 71992) - : (c <= 72003 || (c >= 72016 && c <= 72025))) - : (c <= 72103 || (c < 72154 - ? (c >= 72106 && c <= 72151) - : c <= 72161))) - : (c <= 72164 || (c < 72272 - ? (c < 72263 - ? (c >= 72192 && c <= 72254) - : c <= 72263) - : (c <= 72345 || (c < 72368 - ? c == 72349 - : c <= 72440))))) - : (c <= 72712 || (c < 72873 - ? (c < 72784 - ? (c < 72760 - ? (c >= 72714 && c <= 72758) - : c <= 72768) - : (c <= 72793 || (c < 72850 - ? (c >= 72818 && c <= 72847) - : c <= 72871))) - : (c <= 72886 || (c < 72971 - ? (c < 72968 - ? (c >= 72960 && c <= 72966) - : c <= 72969) - : (c <= 73014 || (c < 73020 - ? c == 73018 - : c <= 73021))))))) - : (c <= 73031 || (c < 73552 - ? (c < 73107 - ? (c < 73063 - ? (c < 73056 - ? (c >= 73040 && c <= 73049) - : c <= 73061) - : (c <= 73064 || (c < 73104 - ? (c >= 73066 && c <= 73102) - : c <= 73105))) - : (c <= 73112 || (c < 73472 - ? (c < 73440 - ? (c >= 73120 && c <= 73129) - : c <= 73462) - : (c <= 73488 || (c < 73534 - ? (c >= 73490 && c <= 73530) - : c <= 73538))))) - : (c <= 73561 || (c < 77824 - ? (c < 74752 - ? (c < 73728 - ? c == 73648 - : c <= 74649) - : (c <= 74862 || (c < 77712 - ? (c >= 74880 && c <= 75075) - : c <= 77808))) - : (c <= 78895 || (c < 92160 - ? (c < 82944 - ? (c >= 78912 && c <= 78933) - : c <= 83526) - : (c <= 92728 || (c < 92768 - ? (c >= 92736 && c <= 92766) - : c <= 92777))))))))) - : (c <= 92862 || (c < 110928 - ? (c < 94095 - ? (c < 93008 - ? (c < 92912 - ? (c < 92880 - ? (c >= 92864 && c <= 92873) - : c <= 92909) - : (c <= 92916 || (c < 92992 - ? (c >= 92928 && c <= 92982) - : c <= 92995))) - : (c <= 93017 || (c < 93760 - ? (c < 93053 - ? (c >= 93027 && c <= 93047) - : c <= 93071) - : (c <= 93823 || (c < 94031 - ? (c >= 93952 && c <= 94026) - : c <= 94087))))) - : (c <= 94111 || (c < 101632 - ? (c < 94192 - ? (c < 94179 - ? (c >= 94176 && c <= 94177) - : c <= 94180) - : (c <= 94193 || (c < 100352 - ? (c >= 94208 && c <= 100343) - : c <= 101589))) - : (c <= 101640 || (c < 110589 - ? (c < 110581 - ? (c >= 110576 && c <= 110579) - : c <= 110587) - : (c <= 110590 || (c < 110898 - ? (c >= 110592 && c <= 110882) - : c <= 110898))))))) - : (c <= 110930 || (c < 119149 - ? (c < 113792 - ? (c < 110960 - ? (c < 110948 - ? c == 110933 - : c <= 110951) - : (c <= 111355 || (c < 113776 - ? (c >= 113664 && c <= 113770) - : c <= 113788))) - : (c <= 113800 || (c < 118528 - ? (c < 113821 - ? (c >= 113808 && c <= 113817) - : c <= 113822) - : (c <= 118573 || (c < 119141 - ? (c >= 118576 && c <= 118598) - : c <= 119145))))) - : (c <= 119154 || (c < 119894 - ? (c < 119210 - ? (c < 119173 - ? (c >= 119163 && c <= 119170) - : c <= 119179) - : (c <= 119213 || (c < 119808 - ? (c >= 119362 && c <= 119364) - : c <= 119892))) - : (c <= 119964 || (c < 119973 - ? (c < 119970 - ? (c >= 119966 && c <= 119967) - : c <= 119970) - : (c <= 119974 || (c < 119982 - ? (c >= 119977 && c <= 119980) - : c <= 119993))))))))))) - : (c <= 119995 || (c < 124912 - ? (c < 121403 - ? (c < 120514 - ? (c < 120123 - ? (c < 120077 - ? (c < 120005 - ? (c >= 119997 && c <= 120003) - : (c <= 120069 || (c >= 120071 && c <= 120074))) - : (c <= 120084 || (c < 120094 - ? (c >= 120086 && c <= 120092) - : c <= 120121))) - : (c <= 120126 || (c < 120138 - ? (c < 120134 - ? (c >= 120128 && c <= 120132) - : c <= 120134) - : (c <= 120144 || (c < 120488 - ? (c >= 120146 && c <= 120485) - : c <= 120512))))) - : (c <= 120538 || (c < 120688 - ? (c < 120598 - ? (c < 120572 - ? (c >= 120540 && c <= 120570) - : c <= 120596) - : (c <= 120628 || (c < 120656 - ? (c >= 120630 && c <= 120654) - : c <= 120686))) - : (c <= 120712 || (c < 120772 - ? (c < 120746 - ? (c >= 120714 && c <= 120744) - : c <= 120770) - : (c <= 120779 || (c < 121344 - ? (c >= 120782 && c <= 120831) - : c <= 121398))))))) - : (c <= 121452 || (c < 122928 - ? (c < 122661 - ? (c < 121499 - ? (c < 121476 - ? c == 121461 - : c <= 121476) - : (c <= 121503 || (c < 122624 - ? (c >= 121505 && c <= 121519) - : c <= 122654))) - : (c <= 122666 || (c < 122907 - ? (c < 122888 - ? (c >= 122880 && c <= 122886) - : c <= 122904) - : (c <= 122913 || (c < 122918 - ? (c >= 122915 && c <= 122916) - : c <= 122922))))) - : (c <= 122989 || (c < 123536 - ? (c < 123184 - ? (c < 123136 - ? c == 123023 - : c <= 123180) - : (c <= 123197 || (c < 123214 - ? (c >= 123200 && c <= 123209) - : c <= 123214))) - : (c <= 123566 || (c < 124896 - ? (c < 124112 - ? (c >= 123584 && c <= 123641) - : c <= 124153) - : (c <= 124902 || (c < 124909 - ? (c >= 124904 && c <= 124907) - : c <= 124910))))))))) - : (c <= 124926 || (c < 126557 - ? (c < 126521 - ? (c < 126469 - ? (c < 125184 - ? (c < 125136 - ? (c >= 124928 && c <= 125124) - : c <= 125142) - : (c <= 125259 || (c < 126464 - ? (c >= 125264 && c <= 125273) - : c <= 126467))) - : (c <= 126495 || (c < 126503 - ? (c < 126500 - ? (c >= 126497 && c <= 126498) - : c <= 126500) - : (c <= 126503 || (c < 126516 - ? (c >= 126505 && c <= 126514) - : c <= 126519))))) - : (c <= 126521 || (c < 126541 - ? (c < 126535 - ? (c < 126530 - ? c == 126523 - : c <= 126530) - : (c <= 126535 || (c < 126539 - ? c == 126537 - : c <= 126539))) - : (c <= 126543 || (c < 126551 - ? (c < 126548 - ? (c >= 126545 && c <= 126546) - : c <= 126548) - : (c <= 126551 || (c < 126555 - ? c == 126553 - : c <= 126555))))))) - : (c <= 126557 || (c < 126629 - ? (c < 126580 - ? (c < 126564 - ? (c < 126561 - ? c == 126559 - : c <= 126562) - : (c <= 126564 || (c < 126572 - ? (c >= 126567 && c <= 126570) - : c <= 126578))) - : (c <= 126583 || (c < 126592 - ? (c < 126590 - ? (c >= 126585 && c <= 126588) - : c <= 126590) - : (c <= 126601 || (c < 126625 - ? (c >= 126603 && c <= 126619) - : c <= 126627))))) - : (c <= 126633 || (c < 178208 - ? (c < 131072 - ? (c < 130032 - ? (c >= 126635 && c <= 126651) - : c <= 130041) - : (c <= 173791 || (c < 177984 - ? (c >= 173824 && c <= 177977) - : c <= 178205))) - : (c <= 183969 || (c < 196608 - ? (c < 194560 - ? (c >= 183984 && c <= 191456) - : c <= 195101) - : (c <= 201546 || (c < 917760 - ? (c >= 201552 && c <= 205743) - : c <= 917999))))))))))))))))); -} - -static inline bool sym_identifier_character_set_3(int32_t c) { - return (c < 43785 - ? (c < 3804 - ? (c < 2759 - ? (c < 2048 - ? (c < 1155 - ? (c < 736 - ? (c < 183 - ? (c < 'b' - ? (c < 'A' - ? (c >= '0' && c <= '9') - : (c <= 'Z' || c == '_')) - : (c <= 'z' || (c < 181 - ? c == 170 - : c <= 181))) - : (c <= 183 || (c < 216 - ? (c < 192 - ? c == 186 - : c <= 214) - : (c <= 246 || (c < 710 - ? (c >= 248 && c <= 705) - : c <= 721))))) - : (c <= 740 || (c < 895 - ? (c < 768 - ? (c < 750 - ? c == 748 - : c <= 750) - : (c <= 884 || (c < 891 - ? (c >= 886 && c <= 887) - : c <= 893))) - : (c <= 895 || (c < 910 - ? (c < 908 - ? (c >= 902 && c <= 906) - : c <= 908) - : (c <= 929 || (c < 1015 - ? (c >= 931 && c <= 1013) - : c <= 1153))))))) - : (c <= 1159 || (c < 1552 - ? (c < 1471 - ? (c < 1369 - ? (c < 1329 - ? (c >= 1162 && c <= 1327) - : c <= 1366) - : (c <= 1369 || (c < 1425 - ? (c >= 1376 && c <= 1416) - : c <= 1469))) - : (c <= 1471 || (c < 1479 - ? (c < 1476 - ? (c >= 1473 && c <= 1474) - : c <= 1477) - : (c <= 1479 || (c < 1519 - ? (c >= 1488 && c <= 1514) - : c <= 1522))))) - : (c <= 1562 || (c < 1791 - ? (c < 1749 - ? (c < 1646 - ? (c >= 1568 && c <= 1641) - : c <= 1747) - : (c <= 1756 || (c < 1770 - ? (c >= 1759 && c <= 1768) - : c <= 1788))) - : (c <= 1791 || (c < 1984 - ? (c < 1869 - ? (c >= 1808 && c <= 1866) - : c <= 1969) - : (c <= 2037 || (c < 2045 - ? c == 2042 - : c <= 2045))))))))) - : (c <= 2093 || (c < 2561 - ? (c < 2474 - ? (c < 2275 - ? (c < 2160 - ? (c < 2144 - ? (c >= 2112 && c <= 2139) - : c <= 2154) - : (c <= 2183 || (c < 2200 - ? (c >= 2185 && c <= 2190) - : c <= 2273))) - : (c <= 2403 || (c < 2437 - ? (c < 2417 - ? (c >= 2406 && c <= 2415) - : c <= 2435) - : (c <= 2444 || (c < 2451 - ? (c >= 2447 && c <= 2448) - : c <= 2472))))) - : (c <= 2480 || (c < 2519 - ? (c < 2492 - ? (c < 2486 - ? c == 2482 - : c <= 2489) - : (c <= 2500 || (c < 2507 - ? (c >= 2503 && c <= 2504) - : c <= 2510))) - : (c <= 2519 || (c < 2534 - ? (c < 2527 - ? (c >= 2524 && c <= 2525) - : c <= 2531) - : (c <= 2545 || (c < 2558 - ? c == 2556 - : c <= 2558))))))) - : (c <= 2563 || (c < 2641 - ? (c < 2613 - ? (c < 2579 - ? (c < 2575 - ? (c >= 2565 && c <= 2570) - : c <= 2576) - : (c <= 2600 || (c < 2610 - ? (c >= 2602 && c <= 2608) - : c <= 2611))) - : (c <= 2614 || (c < 2622 - ? (c < 2620 - ? (c >= 2616 && c <= 2617) - : c <= 2620) - : (c <= 2626 || (c < 2635 - ? (c >= 2631 && c <= 2632) - : c <= 2637))))) - : (c <= 2641 || (c < 2703 - ? (c < 2662 - ? (c < 2654 - ? (c >= 2649 && c <= 2652) - : c <= 2654) - : (c <= 2677 || (c < 2693 - ? (c >= 2689 && c <= 2691) - : c <= 2701))) - : (c <= 2705 || (c < 2738 - ? (c < 2730 - ? (c >= 2707 && c <= 2728) - : c <= 2736) - : (c <= 2739 || (c < 2748 - ? (c >= 2741 && c <= 2745) - : c <= 2757))))))))))) - : (c <= 2761 || (c < 3200 - ? (c < 2969 - ? (c < 2876 - ? (c < 2821 - ? (c < 2790 - ? (c < 2768 - ? (c >= 2763 && c <= 2765) - : (c <= 2768 || (c >= 2784 && c <= 2787))) - : (c <= 2799 || (c < 2817 - ? (c >= 2809 && c <= 2815) - : c <= 2819))) - : (c <= 2828 || (c < 2858 - ? (c < 2835 - ? (c >= 2831 && c <= 2832) - : c <= 2856) - : (c <= 2864 || (c < 2869 - ? (c >= 2866 && c <= 2867) - : c <= 2873))))) - : (c <= 2884 || (c < 2918 - ? (c < 2901 - ? (c < 2891 - ? (c >= 2887 && c <= 2888) - : c <= 2893) - : (c <= 2903 || (c < 2911 - ? (c >= 2908 && c <= 2909) - : c <= 2915))) - : (c <= 2927 || (c < 2949 - ? (c < 2946 - ? c == 2929 - : c <= 2947) - : (c <= 2954 || (c < 2962 - ? (c >= 2958 && c <= 2960) - : c <= 2965))))))) - : (c <= 2970 || (c < 3072 - ? (c < 3006 - ? (c < 2979 - ? (c < 2974 - ? c == 2972 - : c <= 2975) - : (c <= 2980 || (c < 2990 - ? (c >= 2984 && c <= 2986) - : c <= 3001))) - : (c <= 3010 || (c < 3024 - ? (c < 3018 - ? (c >= 3014 && c <= 3016) - : c <= 3021) - : (c <= 3024 || (c < 3046 - ? c == 3031 - : c <= 3055))))) - : (c <= 3084 || (c < 3146 - ? (c < 3114 - ? (c < 3090 - ? (c >= 3086 && c <= 3088) - : c <= 3112) - : (c <= 3129 || (c < 3142 - ? (c >= 3132 && c <= 3140) - : c <= 3144))) - : (c <= 3149 || (c < 3165 - ? (c < 3160 - ? (c >= 3157 && c <= 3158) - : c <= 3162) - : (c <= 3165 || (c < 3174 - ? (c >= 3168 && c <= 3171) - : c <= 3183))))))))) - : (c <= 3203 || (c < 3461 - ? (c < 3302 - ? (c < 3260 - ? (c < 3218 - ? (c < 3214 - ? (c >= 3205 && c <= 3212) - : c <= 3216) - : (c <= 3240 || (c < 3253 - ? (c >= 3242 && c <= 3251) - : c <= 3257))) - : (c <= 3268 || (c < 3285 - ? (c < 3274 - ? (c >= 3270 && c <= 3272) - : c <= 3277) - : (c <= 3286 || (c < 3296 - ? (c >= 3293 && c <= 3294) - : c <= 3299))))) - : (c <= 3311 || (c < 3402 - ? (c < 3342 - ? (c < 3328 - ? (c >= 3313 && c <= 3315) - : c <= 3340) - : (c <= 3344 || (c < 3398 - ? (c >= 3346 && c <= 3396) - : c <= 3400))) - : (c <= 3406 || (c < 3430 - ? (c < 3423 - ? (c >= 3412 && c <= 3415) - : c <= 3427) - : (c <= 3439 || (c < 3457 - ? (c >= 3450 && c <= 3455) - : c <= 3459))))))) - : (c <= 3478 || (c < 3648 - ? (c < 3535 - ? (c < 3517 - ? (c < 3507 - ? (c >= 3482 && c <= 3505) - : c <= 3515) - : (c <= 3517 || (c < 3530 - ? (c >= 3520 && c <= 3526) - : c <= 3530))) - : (c <= 3540 || (c < 3558 - ? (c < 3544 - ? c == 3542 - : c <= 3551) - : (c <= 3567 || (c < 3585 - ? (c >= 3570 && c <= 3571) - : c <= 3642))))) - : (c <= 3662 || (c < 3749 - ? (c < 3716 - ? (c < 3713 - ? (c >= 3664 && c <= 3673) - : c <= 3714) - : (c <= 3716 || (c < 3724 - ? (c >= 3718 && c <= 3722) - : c <= 3747))) - : (c <= 3749 || (c < 3782 - ? (c < 3776 - ? (c >= 3751 && c <= 3773) - : c <= 3780) - : (c <= 3782 || (c < 3792 - ? (c >= 3784 && c <= 3790) - : c <= 3801))))))))))))) - : (c <= 3807 || (c < 8064 - ? (c < 5998 - ? (c < 4746 - ? (c < 4096 - ? (c < 3902 - ? (c < 3893 - ? (c < 3864 - ? c == 3840 - : (c <= 3865 || (c >= 3872 && c <= 3881))) - : (c <= 3893 || (c < 3897 - ? c == 3895 - : c <= 3897))) - : (c <= 3911 || (c < 3974 - ? (c < 3953 - ? (c >= 3913 && c <= 3948) - : c <= 3972) - : (c <= 3991 || (c < 4038 - ? (c >= 3993 && c <= 4028) - : c <= 4038))))) - : (c <= 4169 || (c < 4348 - ? (c < 4295 - ? (c < 4256 - ? (c >= 4176 && c <= 4253) - : c <= 4293) - : (c <= 4295 || (c < 4304 - ? c == 4301 - : c <= 4346))) - : (c <= 4680 || (c < 4696 - ? (c < 4688 - ? (c >= 4682 && c <= 4685) - : c <= 4694) - : (c <= 4696 || (c < 4704 - ? (c >= 4698 && c <= 4701) - : c <= 4744))))))) - : (c <= 4749 || (c < 4992 - ? (c < 4808 - ? (c < 4792 - ? (c < 4786 - ? (c >= 4752 && c <= 4784) - : c <= 4789) - : (c <= 4798 || (c < 4802 - ? c == 4800 - : c <= 4805))) - : (c <= 4822 || (c < 4888 - ? (c < 4882 - ? (c >= 4824 && c <= 4880) - : c <= 4885) - : (c <= 4954 || (c < 4969 - ? (c >= 4957 && c <= 4959) - : c <= 4977))))) - : (c <= 5007 || (c < 5792 - ? (c < 5121 - ? (c < 5112 - ? (c >= 5024 && c <= 5109) - : c <= 5117) - : (c <= 5740 || (c < 5761 - ? (c >= 5743 && c <= 5759) - : c <= 5786))) - : (c <= 5866 || (c < 5919 - ? (c < 5888 - ? (c >= 5870 && c <= 5880) - : c <= 5909) - : (c <= 5940 || (c < 5984 - ? (c >= 5952 && c <= 5971) - : c <= 5996))))))))) - : (c <= 6000 || (c < 6823 - ? (c < 6432 - ? (c < 6155 - ? (c < 6103 - ? (c < 6016 - ? (c >= 6002 && c <= 6003) - : c <= 6099) - : (c <= 6103 || (c < 6112 - ? (c >= 6108 && c <= 6109) - : c <= 6121))) - : (c <= 6157 || (c < 6272 - ? (c < 6176 - ? (c >= 6159 && c <= 6169) - : c <= 6264) - : (c <= 6314 || (c < 6400 - ? (c >= 6320 && c <= 6389) - : c <= 6430))))) - : (c <= 6443 || (c < 6608 - ? (c < 6512 - ? (c < 6470 - ? (c >= 6448 && c <= 6459) - : c <= 6509) - : (c <= 6516 || (c < 6576 - ? (c >= 6528 && c <= 6571) - : c <= 6601))) - : (c <= 6618 || (c < 6752 - ? (c < 6688 - ? (c >= 6656 && c <= 6683) - : c <= 6750) - : (c <= 6780 || (c < 6800 - ? (c >= 6783 && c <= 6793) - : c <= 6809))))))) - : (c <= 6823 || (c < 7357 - ? (c < 7040 - ? (c < 6912 - ? (c < 6847 - ? (c >= 6832 && c <= 6845) - : c <= 6862) - : (c <= 6988 || (c < 7019 - ? (c >= 6992 && c <= 7001) - : c <= 7027))) - : (c <= 7155 || (c < 7245 - ? (c < 7232 - ? (c >= 7168 && c <= 7223) - : c <= 7241) - : (c <= 7293 || (c < 7312 - ? (c >= 7296 && c <= 7304) - : c <= 7354))))) - : (c <= 7359 || (c < 8008 - ? (c < 7424 - ? (c < 7380 - ? (c >= 7376 && c <= 7378) - : c <= 7418) - : (c <= 7957 || (c < 7968 - ? (c >= 7960 && c <= 7965) - : c <= 8005))) - : (c <= 8013 || (c < 8027 - ? (c < 8025 - ? (c >= 8016 && c <= 8023) - : c <= 8025) - : (c <= 8027 || (c < 8031 - ? c == 8029 - : c <= 8061))))))))))) - : (c <= 8116 || (c < 12321 - ? (c < 8488 - ? (c < 8319 - ? (c < 8160 - ? (c < 8134 - ? (c < 8126 - ? (c >= 8118 && c <= 8124) - : (c <= 8126 || (c >= 8130 && c <= 8132))) - : (c <= 8140 || (c < 8150 - ? (c >= 8144 && c <= 8147) - : c <= 8155))) - : (c <= 8172 || (c < 8255 - ? (c < 8182 - ? (c >= 8178 && c <= 8180) - : c <= 8188) - : (c <= 8256 || (c < 8305 - ? c == 8276 - : c <= 8305))))) - : (c <= 8319 || (c < 8455 - ? (c < 8417 - ? (c < 8400 - ? (c >= 8336 && c <= 8348) - : c <= 8412) - : (c <= 8417 || (c < 8450 - ? (c >= 8421 && c <= 8432) - : c <= 8450))) - : (c <= 8455 || (c < 8472 - ? (c < 8469 - ? (c >= 8458 && c <= 8467) - : c <= 8469) - : (c <= 8477 || (c < 8486 - ? c == 8484 - : c <= 8486))))))) - : (c <= 8488 || (c < 11631 - ? (c < 11264 - ? (c < 8517 - ? (c < 8508 - ? (c >= 8490 && c <= 8505) - : c <= 8511) - : (c <= 8521 || (c < 8544 - ? c == 8526 - : c <= 8584))) - : (c <= 11492 || (c < 11559 - ? (c < 11520 - ? (c >= 11499 && c <= 11507) - : c <= 11557) - : (c <= 11559 || (c < 11568 - ? c == 11565 - : c <= 11623))))) - : (c <= 11631 || (c < 11712 - ? (c < 11688 - ? (c < 11680 - ? (c >= 11647 && c <= 11670) - : c <= 11686) - : (c <= 11694 || (c < 11704 - ? (c >= 11696 && c <= 11702) - : c <= 11710))) - : (c <= 11718 || (c < 11736 - ? (c < 11728 - ? (c >= 11720 && c <= 11726) - : c <= 11734) - : (c <= 11742 || (c < 12293 - ? (c >= 11744 && c <= 11775) - : c <= 12295))))))))) - : (c <= 12335 || (c < 42963 - ? (c < 13312 - ? (c < 12449 - ? (c < 12353 - ? (c < 12344 - ? (c >= 12337 && c <= 12341) - : c <= 12348) - : (c <= 12438 || (c < 12445 - ? (c >= 12441 && c <= 12442) - : c <= 12447))) - : (c <= 12538 || (c < 12593 - ? (c < 12549 - ? (c >= 12540 && c <= 12543) - : c <= 12591) - : (c <= 12686 || (c < 12784 - ? (c >= 12704 && c <= 12735) - : c <= 12799))))) - : (c <= 19903 || (c < 42612 - ? (c < 42240 - ? (c < 42192 - ? (c >= 19968 && c <= 42124) - : c <= 42237) - : (c <= 42508 || (c < 42560 - ? (c >= 42512 && c <= 42539) - : c <= 42607))) - : (c <= 42621 || (c < 42786 - ? (c < 42775 - ? (c >= 42623 && c <= 42737) - : c <= 42783) - : (c <= 42888 || (c < 42960 - ? (c >= 42891 && c <= 42954) - : c <= 42961))))))) - : (c <= 42963 || (c < 43392 - ? (c < 43216 - ? (c < 43052 - ? (c < 42994 - ? (c >= 42965 && c <= 42969) - : c <= 43047) - : (c <= 43052 || (c < 43136 - ? (c >= 43072 && c <= 43123) - : c <= 43205))) - : (c <= 43225 || (c < 43261 - ? (c < 43259 - ? (c >= 43232 && c <= 43255) - : c <= 43259) - : (c <= 43309 || (c < 43360 - ? (c >= 43312 && c <= 43347) - : c <= 43388))))) - : (c <= 43456 || (c < 43616 - ? (c < 43520 - ? (c < 43488 - ? (c >= 43471 && c <= 43481) - : c <= 43518) - : (c <= 43574 || (c < 43600 - ? (c >= 43584 && c <= 43597) - : c <= 43609))) - : (c <= 43638 || (c < 43744 - ? (c < 43739 - ? (c >= 43642 && c <= 43714) - : c <= 43741) - : (c <= 43759 || (c < 43777 - ? (c >= 43762 && c <= 43766) - : c <= 43782))))))))))))))) - : (c <= 43790 || (c < 71960 - ? (c < 67840 - ? (c < 65549 - ? (c < 64848 - ? (c < 64112 - ? (c < 44012 - ? (c < 43824 - ? (c < 43808 - ? (c >= 43793 && c <= 43798) - : (c <= 43814 || (c >= 43816 && c <= 43822))) - : (c <= 43866 || (c < 43888 - ? (c >= 43868 && c <= 43881) - : c <= 44010))) - : (c <= 44013 || (c < 55216 - ? (c < 44032 - ? (c >= 44016 && c <= 44025) - : c <= 55203) - : (c <= 55238 || (c < 63744 - ? (c >= 55243 && c <= 55291) - : c <= 64109))))) - : (c <= 64217 || (c < 64318 - ? (c < 64285 - ? (c < 64275 - ? (c >= 64256 && c <= 64262) - : c <= 64279) - : (c <= 64296 || (c < 64312 - ? (c >= 64298 && c <= 64310) - : c <= 64316))) - : (c <= 64318 || (c < 64326 - ? (c < 64323 - ? (c >= 64320 && c <= 64321) - : c <= 64324) - : (c <= 64433 || (c < 64612 - ? (c >= 64467 && c <= 64605) - : c <= 64829))))))) - : (c <= 64911 || (c < 65149 - ? (c < 65101 - ? (c < 65024 - ? (c < 65008 - ? (c >= 64914 && c <= 64967) - : c <= 65017) - : (c <= 65039 || (c < 65075 - ? (c >= 65056 && c <= 65071) - : c <= 65076))) - : (c <= 65103 || (c < 65143 - ? (c < 65139 - ? c == 65137 - : c <= 65139) - : (c <= 65143 || (c < 65147 - ? c == 65145 - : c <= 65147))))) - : (c <= 65149 || (c < 65382 - ? (c < 65313 - ? (c < 65296 - ? (c >= 65151 && c <= 65276) - : c <= 65305) - : (c <= 65338 || (c < 65345 - ? c == 65343 - : c <= 65370))) - : (c <= 65470 || (c < 65490 - ? (c < 65482 - ? (c >= 65474 && c <= 65479) - : c <= 65487) - : (c <= 65495 || (c < 65536 - ? (c >= 65498 && c <= 65500) - : c <= 65547))))))))) - : (c <= 65574 || (c < 66928 - ? (c < 66349 - ? (c < 65856 - ? (c < 65599 - ? (c < 65596 - ? (c >= 65576 && c <= 65594) - : c <= 65597) - : (c <= 65613 || (c < 65664 - ? (c >= 65616 && c <= 65629) - : c <= 65786))) - : (c <= 65908 || (c < 66208 - ? (c < 66176 - ? c == 66045 - : c <= 66204) - : (c <= 66256 || (c < 66304 - ? c == 66272 - : c <= 66335))))) - : (c <= 66378 || (c < 66560 - ? (c < 66464 - ? (c < 66432 - ? (c >= 66384 && c <= 66426) - : c <= 66461) - : (c <= 66499 || (c < 66513 - ? (c >= 66504 && c <= 66511) - : c <= 66517))) - : (c <= 66717 || (c < 66776 - ? (c < 66736 - ? (c >= 66720 && c <= 66729) - : c <= 66771) - : (c <= 66811 || (c < 66864 - ? (c >= 66816 && c <= 66855) - : c <= 66915))))))) - : (c <= 66938 || (c < 67463 - ? (c < 66995 - ? (c < 66964 - ? (c < 66956 - ? (c >= 66940 && c <= 66954) - : c <= 66962) - : (c <= 66965 || (c < 66979 - ? (c >= 66967 && c <= 66977) - : c <= 66993))) - : (c <= 67001 || (c < 67392 - ? (c < 67072 - ? (c >= 67003 && c <= 67004) - : c <= 67382) - : (c <= 67413 || (c < 67456 - ? (c >= 67424 && c <= 67431) - : c <= 67461))))) - : (c <= 67504 || (c < 67644 - ? (c < 67592 - ? (c < 67584 - ? (c >= 67506 && c <= 67514) - : c <= 67589) - : (c <= 67592 || (c < 67639 - ? (c >= 67594 && c <= 67637) - : c <= 67640))) - : (c <= 67644 || (c < 67712 - ? (c < 67680 - ? (c >= 67647 && c <= 67669) - : c <= 67702) - : (c <= 67742 || (c < 67828 - ? (c >= 67808 && c <= 67826) - : c <= 67829))))))))))) - : (c <= 67861 || (c < 70163 - ? (c < 69291 - ? (c < 68288 - ? (c < 68117 - ? (c < 68096 - ? (c < 67968 - ? (c >= 67872 && c <= 67897) - : (c <= 68023 || (c >= 68030 && c <= 68031))) - : (c <= 68099 || (c < 68108 - ? (c >= 68101 && c <= 68102) - : c <= 68115))) - : (c <= 68119 || (c < 68159 - ? (c < 68152 - ? (c >= 68121 && c <= 68149) - : c <= 68154) - : (c <= 68159 || (c < 68224 - ? (c >= 68192 && c <= 68220) - : c <= 68252))))) - : (c <= 68295 || (c < 68608 - ? (c < 68416 - ? (c < 68352 - ? (c >= 68297 && c <= 68326) - : c <= 68405) - : (c <= 68437 || (c < 68480 - ? (c >= 68448 && c <= 68466) - : c <= 68497))) - : (c <= 68680 || (c < 68864 - ? (c < 68800 - ? (c >= 68736 && c <= 68786) - : c <= 68850) - : (c <= 68903 || (c < 69248 - ? (c >= 68912 && c <= 68921) - : c <= 69289))))))) - : (c <= 69292 || (c < 69840 - ? (c < 69552 - ? (c < 69415 - ? (c < 69373 - ? (c >= 69296 && c <= 69297) - : c <= 69404) - : (c <= 69415 || (c < 69488 - ? (c >= 69424 && c <= 69456) - : c <= 69509))) - : (c <= 69572 || (c < 69734 - ? (c < 69632 - ? (c >= 69600 && c <= 69622) - : c <= 69702) - : (c <= 69749 || (c < 69826 - ? (c >= 69759 && c <= 69818) - : c <= 69826))))) - : (c <= 69864 || (c < 70006 - ? (c < 69942 - ? (c < 69888 - ? (c >= 69872 && c <= 69881) - : c <= 69940) - : (c <= 69951 || (c < 69968 - ? (c >= 69956 && c <= 69959) - : c <= 70003))) - : (c <= 70006 || (c < 70094 - ? (c < 70089 - ? (c >= 70016 && c <= 70084) - : c <= 70092) - : (c <= 70106 || (c < 70144 - ? c == 70108 - : c <= 70161))))))))) - : (c <= 70199 || (c < 70656 - ? (c < 70419 - ? (c < 70303 - ? (c < 70280 - ? (c < 70272 - ? (c >= 70206 && c <= 70209) - : c <= 70278) - : (c <= 70280 || (c < 70287 - ? (c >= 70282 && c <= 70285) - : c <= 70301))) - : (c <= 70312 || (c < 70400 - ? (c < 70384 - ? (c >= 70320 && c <= 70378) - : c <= 70393) - : (c <= 70403 || (c < 70415 - ? (c >= 70405 && c <= 70412) - : c <= 70416))))) - : (c <= 70440 || (c < 70475 - ? (c < 70453 - ? (c < 70450 - ? (c >= 70442 && c <= 70448) - : c <= 70451) - : (c <= 70457 || (c < 70471 - ? (c >= 70459 && c <= 70468) - : c <= 70472))) - : (c <= 70477 || (c < 70493 - ? (c < 70487 - ? c == 70480 - : c <= 70487) - : (c <= 70499 || (c < 70512 - ? (c >= 70502 && c <= 70508) - : c <= 70516))))))) - : (c <= 70730 || (c < 71296 - ? (c < 71040 - ? (c < 70784 - ? (c < 70750 - ? (c >= 70736 && c <= 70745) - : c <= 70753) - : (c <= 70853 || (c < 70864 - ? c == 70855 - : c <= 70873))) - : (c <= 71093 || (c < 71168 - ? (c < 71128 - ? (c >= 71096 && c <= 71104) - : c <= 71133) - : (c <= 71232 || (c < 71248 - ? c == 71236 - : c <= 71257))))) - : (c <= 71352 || (c < 71680 - ? (c < 71453 - ? (c < 71424 - ? (c >= 71360 && c <= 71369) - : c <= 71450) - : (c <= 71467 || (c < 71488 - ? (c >= 71472 && c <= 71481) - : c <= 71494))) - : (c <= 71738 || (c < 71945 - ? (c < 71935 - ? (c >= 71840 && c <= 71913) - : c <= 71942) - : (c <= 71945 || (c < 71957 - ? (c >= 71948 && c <= 71955) - : c <= 71958))))))))))))) - : (c <= 71989 || (c < 119995 - ? (c < 92784 - ? (c < 73023 - ? (c < 72704 - ? (c < 72163 - ? (c < 72096 - ? (c < 71995 - ? (c >= 71991 && c <= 71992) - : (c <= 72003 || (c >= 72016 && c <= 72025))) - : (c <= 72103 || (c < 72154 - ? (c >= 72106 && c <= 72151) - : c <= 72161))) - : (c <= 72164 || (c < 72272 - ? (c < 72263 - ? (c >= 72192 && c <= 72254) - : c <= 72263) - : (c <= 72345 || (c < 72368 - ? c == 72349 - : c <= 72440))))) - : (c <= 72712 || (c < 72873 - ? (c < 72784 - ? (c < 72760 - ? (c >= 72714 && c <= 72758) - : c <= 72768) - : (c <= 72793 || (c < 72850 - ? (c >= 72818 && c <= 72847) - : c <= 72871))) - : (c <= 72886 || (c < 72971 - ? (c < 72968 - ? (c >= 72960 && c <= 72966) - : c <= 72969) - : (c <= 73014 || (c < 73020 - ? c == 73018 - : c <= 73021))))))) - : (c <= 73031 || (c < 73552 - ? (c < 73107 - ? (c < 73063 - ? (c < 73056 - ? (c >= 73040 && c <= 73049) - : c <= 73061) - : (c <= 73064 || (c < 73104 - ? (c >= 73066 && c <= 73102) - : c <= 73105))) - : (c <= 73112 || (c < 73472 - ? (c < 73440 - ? (c >= 73120 && c <= 73129) - : c <= 73462) - : (c <= 73488 || (c < 73534 - ? (c >= 73490 && c <= 73530) - : c <= 73538))))) - : (c <= 73561 || (c < 77824 - ? (c < 74752 - ? (c < 73728 - ? c == 73648 - : c <= 74649) - : (c <= 74862 || (c < 77712 - ? (c >= 74880 && c <= 75075) - : c <= 77808))) - : (c <= 78895 || (c < 92160 - ? (c < 82944 - ? (c >= 78912 && c <= 78933) - : c <= 83526) - : (c <= 92728 || (c < 92768 - ? (c >= 92736 && c <= 92766) - : c <= 92777))))))))) - : (c <= 92862 || (c < 110928 - ? (c < 94095 - ? (c < 93008 - ? (c < 92912 - ? (c < 92880 - ? (c >= 92864 && c <= 92873) - : c <= 92909) - : (c <= 92916 || (c < 92992 - ? (c >= 92928 && c <= 92982) - : c <= 92995))) - : (c <= 93017 || (c < 93760 - ? (c < 93053 - ? (c >= 93027 && c <= 93047) - : c <= 93071) - : (c <= 93823 || (c < 94031 - ? (c >= 93952 && c <= 94026) - : c <= 94087))))) - : (c <= 94111 || (c < 101632 - ? (c < 94192 - ? (c < 94179 - ? (c >= 94176 && c <= 94177) - : c <= 94180) - : (c <= 94193 || (c < 100352 - ? (c >= 94208 && c <= 100343) - : c <= 101589))) - : (c <= 101640 || (c < 110589 - ? (c < 110581 - ? (c >= 110576 && c <= 110579) - : c <= 110587) - : (c <= 110590 || (c < 110898 - ? (c >= 110592 && c <= 110882) - : c <= 110898))))))) - : (c <= 110930 || (c < 119149 - ? (c < 113792 - ? (c < 110960 - ? (c < 110948 - ? c == 110933 - : c <= 110951) - : (c <= 111355 || (c < 113776 - ? (c >= 113664 && c <= 113770) - : c <= 113788))) - : (c <= 113800 || (c < 118528 - ? (c < 113821 - ? (c >= 113808 && c <= 113817) - : c <= 113822) - : (c <= 118573 || (c < 119141 - ? (c >= 118576 && c <= 118598) - : c <= 119145))))) - : (c <= 119154 || (c < 119894 - ? (c < 119210 - ? (c < 119173 - ? (c >= 119163 && c <= 119170) - : c <= 119179) - : (c <= 119213 || (c < 119808 - ? (c >= 119362 && c <= 119364) - : c <= 119892))) - : (c <= 119964 || (c < 119973 - ? (c < 119970 - ? (c >= 119966 && c <= 119967) - : c <= 119970) - : (c <= 119974 || (c < 119982 - ? (c >= 119977 && c <= 119980) - : c <= 119993))))))))))) - : (c <= 119995 || (c < 124912 - ? (c < 121403 - ? (c < 120514 - ? (c < 120123 - ? (c < 120077 - ? (c < 120005 - ? (c >= 119997 && c <= 120003) - : (c <= 120069 || (c >= 120071 && c <= 120074))) - : (c <= 120084 || (c < 120094 - ? (c >= 120086 && c <= 120092) - : c <= 120121))) - : (c <= 120126 || (c < 120138 - ? (c < 120134 - ? (c >= 120128 && c <= 120132) - : c <= 120134) - : (c <= 120144 || (c < 120488 - ? (c >= 120146 && c <= 120485) - : c <= 120512))))) - : (c <= 120538 || (c < 120688 - ? (c < 120598 - ? (c < 120572 - ? (c >= 120540 && c <= 120570) - : c <= 120596) - : (c <= 120628 || (c < 120656 - ? (c >= 120630 && c <= 120654) - : c <= 120686))) - : (c <= 120712 || (c < 120772 - ? (c < 120746 - ? (c >= 120714 && c <= 120744) - : c <= 120770) - : (c <= 120779 || (c < 121344 - ? (c >= 120782 && c <= 120831) - : c <= 121398))))))) - : (c <= 121452 || (c < 122928 - ? (c < 122661 - ? (c < 121499 - ? (c < 121476 - ? c == 121461 - : c <= 121476) - : (c <= 121503 || (c < 122624 - ? (c >= 121505 && c <= 121519) - : c <= 122654))) - : (c <= 122666 || (c < 122907 - ? (c < 122888 - ? (c >= 122880 && c <= 122886) - : c <= 122904) - : (c <= 122913 || (c < 122918 - ? (c >= 122915 && c <= 122916) - : c <= 122922))))) - : (c <= 122989 || (c < 123536 - ? (c < 123184 - ? (c < 123136 - ? c == 123023 - : c <= 123180) - : (c <= 123197 || (c < 123214 - ? (c >= 123200 && c <= 123209) - : c <= 123214))) - : (c <= 123566 || (c < 124896 - ? (c < 124112 - ? (c >= 123584 && c <= 123641) - : c <= 124153) - : (c <= 124902 || (c < 124909 - ? (c >= 124904 && c <= 124907) - : c <= 124910))))))))) - : (c <= 124926 || (c < 126557 - ? (c < 126521 - ? (c < 126469 - ? (c < 125184 - ? (c < 125136 - ? (c >= 124928 && c <= 125124) - : c <= 125142) - : (c <= 125259 || (c < 126464 - ? (c >= 125264 && c <= 125273) - : c <= 126467))) - : (c <= 126495 || (c < 126503 - ? (c < 126500 - ? (c >= 126497 && c <= 126498) - : c <= 126500) - : (c <= 126503 || (c < 126516 - ? (c >= 126505 && c <= 126514) - : c <= 126519))))) - : (c <= 126521 || (c < 126541 - ? (c < 126535 - ? (c < 126530 - ? c == 126523 - : c <= 126530) - : (c <= 126535 || (c < 126539 - ? c == 126537 - : c <= 126539))) - : (c <= 126543 || (c < 126551 - ? (c < 126548 - ? (c >= 126545 && c <= 126546) - : c <= 126548) - : (c <= 126551 || (c < 126555 - ? c == 126553 - : c <= 126555))))))) - : (c <= 126557 || (c < 126629 - ? (c < 126580 - ? (c < 126564 - ? (c < 126561 - ? c == 126559 - : c <= 126562) - : (c <= 126564 || (c < 126572 - ? (c >= 126567 && c <= 126570) - : c <= 126578))) - : (c <= 126583 || (c < 126592 - ? (c < 126590 - ? (c >= 126585 && c <= 126588) - : c <= 126590) - : (c <= 126601 || (c < 126625 - ? (c >= 126603 && c <= 126619) - : c <= 126627))))) - : (c <= 126633 || (c < 178208 - ? (c < 131072 - ? (c < 130032 - ? (c >= 126635 && c <= 126651) - : c <= 130041) - : (c <= 173791 || (c < 177984 - ? (c >= 173824 && c <= 177977) - : c <= 178205))) - : (c <= 183969 || (c < 196608 - ? (c < 194560 - ? (c >= 183984 && c <= 191456) - : c <= 195101) - : (c <= 201546 || (c < 917760 - ? (c >= 201552 && c <= 205743) - : c <= 917999))))))))))))))))); -} - -static bool ts_lex(TSLexer *lexer, TSStateId state) { - START_LEXER(); - eof = lexer->eof(lexer); - switch (state) { - case 0: - if (eof) ADVANCE(18); - if (lookahead == '"') ADVANCE(36); - if (lookahead == '\'') ADVANCE(38); - if (lookahead == '(') ADVANCE(26); - if (lookahead == ')') ADVANCE(27); - if (lookahead == ',') ADVANCE(20); - if (lookahead == '-') ADVANCE(34); - if (lookahead == '/') ADVANCE(3); - if (lookahead == '0') ADVANCE(29); - if (lookahead == ':') ADVANCE(28); - if (lookahead == '[') ADVANCE(19); - if (lookahead == '\\') ADVANCE(4); - if (lookahead == ']') ADVANCE(21); - if (lookahead == 'b') ADVANCE(37); - if (lookahead == 'f') ADVANCE(49); - if (lookahead == 'r') ADVANCE(48); - if (lookahead == 't') ADVANCE(53); - if (lookahead == '{') ADVANCE(22); - if (lookahead == '}') ADVANCE(23); - if (lookahead == '\t' || - lookahead == '\n' || - lookahead == '\r' || - lookahead == ' ') SKIP(16) - if (('1' <= lookahead && lookahead <= '9')) ADVANCE(32); - if (sym_identifier_character_set_1(lookahead)) ADVANCE(56); - END_STATE(); - case 1: - if (lookahead == '"') ADVANCE(35); - if (lookahead == '\'') ADVANCE(38); - if (lookahead == '(') ADVANCE(26); - if (lookahead == ')') ADVANCE(27); - if (lookahead == ',') ADVANCE(20); - if (lookahead == '-') ADVANCE(34); - if (lookahead == '/') ADVANCE(3); - if (lookahead == '0') ADVANCE(29); - if (lookahead == '[') ADVANCE(19); - if (lookahead == ']') ADVANCE(21); - if (lookahead == 'b') ADVANCE(37); - if (lookahead == 'f') ADVANCE(49); - if (lookahead == 'r') ADVANCE(48); - if (lookahead == 't') ADVANCE(53); - if (lookahead == '{') ADVANCE(22); - if (lookahead == '}') ADVANCE(23); - if (lookahead == '\t' || - lookahead == '\n' || - lookahead == '\r' || - lookahead == ' ') SKIP(1) - if (('1' <= lookahead && lookahead <= '9')) ADVANCE(32); - if (sym_identifier_character_set_1(lookahead)) ADVANCE(56); - END_STATE(); - case 2: - if (lookahead == '\'') ADVANCE(38); - if (lookahead == '/') ADVANCE(40); - if (lookahead == '\\') ADVANCE(4); - if (lookahead == '\t' || - lookahead == '\n' || - lookahead == '\r' || - lookahead == ' ') ADVANCE(41); - if (lookahead != 0) ADVANCE(39); - END_STATE(); - case 3: - if (lookahead == '/') ADVANCE(57); - END_STATE(); - case 4: - if (lookahead == 'u') ADVANCE(5); - if (lookahead == 'x') ADVANCE(12); - if (('0' <= lookahead && lookahead <= '7')) ADVANCE(43); - if (sym_escape_sequence_character_set_1(lookahead)) ADVANCE(44); - if (lookahead != 0) ADVANCE(42); - END_STATE(); - case 5: - if (lookahead == '{') ADVANCE(11); - if (('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'F') || - ('a' <= lookahead && lookahead <= 'f')) ADVANCE(9); - END_STATE(); - case 6: - if (lookahead == '}') ADVANCE(44); - if (('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'F') || - ('a' <= lookahead && lookahead <= 'f')) ADVANCE(6); - END_STATE(); - case 7: - if (lookahead == '0' || - lookahead == '1' || - lookahead == '_') ADVANCE(30); - END_STATE(); - case 8: - if (('0' <= lookahead && lookahead <= '7') || - lookahead == '_') ADVANCE(31); - END_STATE(); - case 9: - if (('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'F') || - ('a' <= lookahead && lookahead <= 'f')) ADVANCE(12); - END_STATE(); - case 10: - if (('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'F') || - ('a' <= lookahead && lookahead <= 'f')) ADVANCE(44); - END_STATE(); - case 11: - if (('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'F') || - ('a' <= lookahead && lookahead <= 'f')) ADVANCE(6); - END_STATE(); - case 12: - if (('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'F') || - ('a' <= lookahead && lookahead <= 'f')) ADVANCE(10); - END_STATE(); - case 13: - if (('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'F') || - lookahead == '_' || - ('a' <= lookahead && lookahead <= 'f')) ADVANCE(33); - END_STATE(); - case 14: - if (sym_identifier_character_set_1(lookahead)) ADVANCE(56); - END_STATE(); - case 15: - if (eof) ADVANCE(18); - if (lookahead == '"') ADVANCE(36); - if (lookahead == '(') ADVANCE(25); - if (lookahead == ')') ADVANCE(27); - if (lookahead == ',') ADVANCE(20); - if (lookahead == '/') ADVANCE(3); - if (lookahead == ':') ADVANCE(28); - if (lookahead == '\\') ADVANCE(4); - if (lookahead == ']') ADVANCE(21); - if (lookahead == 'r') ADVANCE(48); - if (lookahead == '}') ADVANCE(23); - if (lookahead == '\t' || - lookahead == '\n' || - lookahead == '\r' || - lookahead == ' ') SKIP(17) - if (sym_identifier_character_set_1(lookahead)) ADVANCE(56); - END_STATE(); - case 16: - if (eof) ADVANCE(18); - if (lookahead == '"') ADVANCE(35); - if (lookahead == '\'') ADVANCE(38); - if (lookahead == '(') ADVANCE(26); - if (lookahead == ')') ADVANCE(27); - if (lookahead == ',') ADVANCE(20); - if (lookahead == '-') ADVANCE(34); - if (lookahead == '/') ADVANCE(3); - if (lookahead == '0') ADVANCE(29); - if (lookahead == ':') ADVANCE(28); - if (lookahead == '[') ADVANCE(19); - if (lookahead == ']') ADVANCE(21); - if (lookahead == 'b') ADVANCE(37); - if (lookahead == 'f') ADVANCE(49); - if (lookahead == 'r') ADVANCE(48); - if (lookahead == 't') ADVANCE(53); - if (lookahead == '{') ADVANCE(22); - if (lookahead == '}') ADVANCE(23); - if (lookahead == '\t' || - lookahead == '\n' || - lookahead == '\r' || - lookahead == ' ') SKIP(16) - if (('1' <= lookahead && lookahead <= '9')) ADVANCE(32); - if (sym_identifier_character_set_1(lookahead)) ADVANCE(56); - END_STATE(); - case 17: - if (eof) ADVANCE(18); - if (lookahead == '(') ADVANCE(25); - if (lookahead == ')') ADVANCE(27); - if (lookahead == ',') ADVANCE(20); - if (lookahead == '/') ADVANCE(3); - if (lookahead == ':') ADVANCE(28); - if (lookahead == ']') ADVANCE(21); - if (lookahead == 'r') ADVANCE(48); - if (lookahead == '}') ADVANCE(23); - if (lookahead == '\t' || - lookahead == '\n' || - lookahead == '\r' || - lookahead == ' ') SKIP(17) - if (sym_identifier_character_set_1(lookahead)) ADVANCE(56); - END_STATE(); - case 18: - ACCEPT_TOKEN(ts_builtin_sym_end); - END_STATE(); - case 19: - ACCEPT_TOKEN(anon_sym_LBRACK); - END_STATE(); - case 20: - ACCEPT_TOKEN(anon_sym_COMMA); - END_STATE(); - case 21: - ACCEPT_TOKEN(anon_sym_RBRACK); - END_STATE(); - case 22: - ACCEPT_TOKEN(anon_sym_LBRACE); - END_STATE(); - case 23: - ACCEPT_TOKEN(anon_sym_RBRACE); - END_STATE(); - case 24: - ACCEPT_TOKEN(anon_sym_LPAREN_RPAREN); - END_STATE(); - case 25: - ACCEPT_TOKEN(anon_sym_LPAREN); - END_STATE(); - case 26: - ACCEPT_TOKEN(anon_sym_LPAREN); - if (lookahead == ')') ADVANCE(24); - END_STATE(); - case 27: - ACCEPT_TOKEN(anon_sym_RPAREN); - END_STATE(); - case 28: - ACCEPT_TOKEN(anon_sym_COLON); - END_STATE(); - case 29: - ACCEPT_TOKEN(sym_integer); - if (lookahead == 'b') ADVANCE(7); - if (lookahead == 'o') ADVANCE(8); - if (lookahead == 'x') ADVANCE(13); - if (('0' <= lookahead && lookahead <= '9') || - lookahead == '_') ADVANCE(32); - END_STATE(); - case 30: - ACCEPT_TOKEN(sym_integer); - if (lookahead == '0' || - lookahead == '1' || - lookahead == '_') ADVANCE(30); - END_STATE(); - case 31: - ACCEPT_TOKEN(sym_integer); - if (('0' <= lookahead && lookahead <= '7') || - lookahead == '_') ADVANCE(31); - END_STATE(); - case 32: - ACCEPT_TOKEN(sym_integer); - if (('0' <= lookahead && lookahead <= '9') || - lookahead == '_') ADVANCE(32); - END_STATE(); - case 33: - ACCEPT_TOKEN(sym_integer); - if (('0' <= lookahead && lookahead <= '9') || - ('A' <= lookahead && lookahead <= 'F') || - lookahead == '_' || - ('a' <= lookahead && lookahead <= 'f')) ADVANCE(33); - END_STATE(); - case 34: - ACCEPT_TOKEN(anon_sym_DASH); - END_STATE(); - case 35: - ACCEPT_TOKEN(aux_sym_string_token1); - END_STATE(); - case 36: - ACCEPT_TOKEN(anon_sym_DQUOTE); - END_STATE(); - case 37: - ACCEPT_TOKEN(anon_sym_b); - if (lookahead == '"') ADVANCE(35); - if (sym_identifier_character_set_2(lookahead)) ADVANCE(56); - END_STATE(); - case 38: - ACCEPT_TOKEN(anon_sym_SQUOTE); - END_STATE(); - case 39: - ACCEPT_TOKEN(aux_sym_char_token1); - END_STATE(); - case 40: - ACCEPT_TOKEN(aux_sym_char_token1); - if (lookahead == '/') ADVANCE(57); - END_STATE(); - case 41: - ACCEPT_TOKEN(aux_sym_char_token1); - if (lookahead == '/') ADVANCE(40); - if (lookahead == '\t' || - lookahead == '\n' || - lookahead == '\r' || - lookahead == ' ') ADVANCE(41); - if (lookahead != 0 && - lookahead != '\'' && - lookahead != '\\') ADVANCE(39); - END_STATE(); - case 42: - ACCEPT_TOKEN(aux_sym__escape_sequence_token1); - END_STATE(); - case 43: - ACCEPT_TOKEN(aux_sym__escape_sequence_token1); - if (('0' <= lookahead && lookahead <= '7')) ADVANCE(45); - END_STATE(); - case 44: - ACCEPT_TOKEN(sym_escape_sequence); - END_STATE(); - case 45: - ACCEPT_TOKEN(sym_escape_sequence); - if (('0' <= lookahead && lookahead <= '7')) ADVANCE(44); - END_STATE(); - case 46: - ACCEPT_TOKEN(anon_sym_true); - if (sym_identifier_character_set_2(lookahead)) ADVANCE(56); - END_STATE(); - case 47: - ACCEPT_TOKEN(anon_sym_false); - if (sym_identifier_character_set_2(lookahead)) ADVANCE(56); - END_STATE(); - case 48: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == '#') ADVANCE(14); - if (sym_identifier_character_set_2(lookahead)) ADVANCE(56); - END_STATE(); - case 49: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'a') ADVANCE(52); - if (sym_identifier_character_set_3(lookahead)) ADVANCE(56); - END_STATE(); - case 50: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'e') ADVANCE(46); - if (sym_identifier_character_set_2(lookahead)) ADVANCE(56); - END_STATE(); - case 51: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'e') ADVANCE(47); - if (sym_identifier_character_set_2(lookahead)) ADVANCE(56); - END_STATE(); - case 52: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'l') ADVANCE(54); - if (sym_identifier_character_set_2(lookahead)) ADVANCE(56); - END_STATE(); - case 53: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'r') ADVANCE(55); - if (sym_identifier_character_set_2(lookahead)) ADVANCE(56); - END_STATE(); - case 54: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == 's') ADVANCE(51); - if (sym_identifier_character_set_2(lookahead)) ADVANCE(56); - END_STATE(); - case 55: - ACCEPT_TOKEN(sym_identifier); - if (lookahead == 'u') ADVANCE(50); - if (sym_identifier_character_set_2(lookahead)) ADVANCE(56); - END_STATE(); - case 56: - ACCEPT_TOKEN(sym_identifier); - if (sym_identifier_character_set_2(lookahead)) ADVANCE(56); - END_STATE(); - case 57: - ACCEPT_TOKEN(sym_line_comment); - if (lookahead != 0 && - lookahead != '\n') ADVANCE(57); - END_STATE(); - default: - return false; - } -} - -static const TSLexMode ts_lex_modes[STATE_COUNT] = { - [0] = {.lex_state = 0, .external_lex_state = 1}, - [1] = {.lex_state = 1, .external_lex_state = 2}, - [2] = {.lex_state = 1, .external_lex_state = 2}, - [3] = {.lex_state = 1, .external_lex_state = 2}, - [4] = {.lex_state = 1, .external_lex_state = 2}, - [5] = {.lex_state = 1, .external_lex_state = 2}, - [6] = {.lex_state = 1, .external_lex_state = 2}, - [7] = {.lex_state = 1, .external_lex_state = 2}, - [8] = {.lex_state = 1, .external_lex_state = 2}, - [9] = {.lex_state = 1, .external_lex_state = 2}, - [10] = {.lex_state = 1, .external_lex_state = 2}, - [11] = {.lex_state = 1, .external_lex_state = 2}, - [12] = {.lex_state = 1, .external_lex_state = 2}, - [13] = {.lex_state = 1, .external_lex_state = 2}, - [14] = {.lex_state = 1, .external_lex_state = 2}, - [15] = {.lex_state = 15, .external_lex_state = 3}, - [16] = {.lex_state = 0, .external_lex_state = 3}, - [17] = {.lex_state = 0, .external_lex_state = 3}, - [18] = {.lex_state = 0, .external_lex_state = 3}, - [19] = {.lex_state = 0, .external_lex_state = 3}, - [20] = {.lex_state = 0, .external_lex_state = 3}, - [21] = {.lex_state = 0, .external_lex_state = 3}, - [22] = {.lex_state = 0, .external_lex_state = 3}, - [23] = {.lex_state = 0, .external_lex_state = 3}, - [24] = {.lex_state = 15, .external_lex_state = 4}, - [25] = {.lex_state = 0, .external_lex_state = 3}, - [26] = {.lex_state = 0, .external_lex_state = 3}, - [27] = {.lex_state = 0, .external_lex_state = 3}, - [28] = {.lex_state = 0, .external_lex_state = 3}, - [29] = {.lex_state = 0, .external_lex_state = 3}, - [30] = {.lex_state = 0, .external_lex_state = 3}, - [31] = {.lex_state = 0, .external_lex_state = 3}, - [32] = {.lex_state = 15, .external_lex_state = 4}, - [33] = {.lex_state = 0, .external_lex_state = 3}, - [34] = {.lex_state = 0, .external_lex_state = 3}, - [35] = {.lex_state = 0, .external_lex_state = 3}, - [36] = {.lex_state = 0, .external_lex_state = 3}, - [37] = {.lex_state = 0, .external_lex_state = 3}, - [38] = {.lex_state = 0, .external_lex_state = 3}, - [39] = {.lex_state = 0, .external_lex_state = 3}, - [40] = {.lex_state = 0, .external_lex_state = 3}, - [41] = {.lex_state = 0, .external_lex_state = 3}, - [42] = {.lex_state = 0, .external_lex_state = 3}, - [43] = {.lex_state = 0, .external_lex_state = 3}, - [44] = {.lex_state = 0, .external_lex_state = 3}, - [45] = {.lex_state = 15, .external_lex_state = 4}, - [46] = {.lex_state = 0, .external_lex_state = 3}, - [47] = {.lex_state = 2, .external_lex_state = 3}, - [48] = {.lex_state = 2, .external_lex_state = 3}, - [49] = {.lex_state = 0, .external_lex_state = 3}, - [50] = {.lex_state = 15, .external_lex_state = 3}, - [51] = {.lex_state = 0, .external_lex_state = 3}, - [52] = {.lex_state = 0, .external_lex_state = 3}, - [53] = {.lex_state = 0, .external_lex_state = 3}, - [54] = {.lex_state = 0, .external_lex_state = 3}, - [55] = {.lex_state = 0, .external_lex_state = 3}, - [56] = {.lex_state = 15, .external_lex_state = 3}, - [57] = {.lex_state = 0, .external_lex_state = 3}, - [58] = {.lex_state = 0, .external_lex_state = 3}, - [59] = {.lex_state = 0, .external_lex_state = 3}, - [60] = {.lex_state = 15, .external_lex_state = 3}, - [61] = {.lex_state = 0, .external_lex_state = 3}, - [62] = {.lex_state = 0, .external_lex_state = 3}, - [63] = {.lex_state = 15, .external_lex_state = 3}, - [64] = {.lex_state = 0, .external_lex_state = 3}, - [65] = {.lex_state = 0, .external_lex_state = 3}, - [66] = {.lex_state = 15, .external_lex_state = 3}, - [67] = {.lex_state = 0, .external_lex_state = 3}, - [68] = {.lex_state = 0, .external_lex_state = 3}, - [69] = {.lex_state = 0, .external_lex_state = 2}, - [70] = {.lex_state = 0, .external_lex_state = 3}, - [71] = {.lex_state = 0, .external_lex_state = 3}, - [72] = {.lex_state = 0, .external_lex_state = 3}, - [73] = {.lex_state = 0, .external_lex_state = 3}, - [74] = {.lex_state = 0, .external_lex_state = 3}, - [75] = {.lex_state = 0, .external_lex_state = 3}, - [76] = {.lex_state = 0, .external_lex_state = 3}, - [77] = {.lex_state = 0, .external_lex_state = 3}, - [78] = {.lex_state = 0, .external_lex_state = 3}, - [79] = {.lex_state = 0, .external_lex_state = 3}, - [80] = {.lex_state = 0, .external_lex_state = 3}, -}; - -enum { - ts_external_token__string_content = 0, - ts_external_token_raw_string = 1, - ts_external_token_float = 2, - ts_external_token_block_comment = 3, -}; - -static const TSSymbol ts_external_scanner_symbol_map[EXTERNAL_TOKEN_COUNT] = { - [ts_external_token__string_content] = sym__string_content, - [ts_external_token_raw_string] = sym_raw_string, - [ts_external_token_float] = sym_float, - [ts_external_token_block_comment] = sym_block_comment, -}; - -static const bool ts_external_scanner_states[5][EXTERNAL_TOKEN_COUNT] = { - [1] = { - [ts_external_token__string_content] = true, - [ts_external_token_raw_string] = true, - [ts_external_token_float] = true, - [ts_external_token_block_comment] = true, - }, - [2] = { - [ts_external_token_float] = true, - [ts_external_token_block_comment] = true, - }, - [3] = { - [ts_external_token_block_comment] = true, - }, - [4] = { - [ts_external_token__string_content] = true, - [ts_external_token_block_comment] = true, - }, -}; - -static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { - [0] = { - [ts_builtin_sym_end] = ACTIONS(1), - [anon_sym_LBRACK] = ACTIONS(1), - [anon_sym_COMMA] = ACTIONS(1), - [anon_sym_RBRACK] = ACTIONS(1), - [anon_sym_LBRACE] = ACTIONS(1), - [anon_sym_RBRACE] = ACTIONS(1), - [anon_sym_LPAREN_RPAREN] = ACTIONS(1), - [anon_sym_LPAREN] = ACTIONS(1), - [anon_sym_RPAREN] = ACTIONS(1), - [anon_sym_COLON] = ACTIONS(1), - [sym_integer] = ACTIONS(1), - [anon_sym_DASH] = ACTIONS(1), - [aux_sym_string_token1] = ACTIONS(1), - [anon_sym_DQUOTE] = ACTIONS(1), - [anon_sym_b] = ACTIONS(1), - [anon_sym_SQUOTE] = ACTIONS(1), - [aux_sym__escape_sequence_token1] = ACTIONS(1), - [sym_escape_sequence] = ACTIONS(1), - [anon_sym_true] = ACTIONS(1), - [anon_sym_false] = ACTIONS(1), - [sym_identifier] = ACTIONS(1), - [sym_line_comment] = ACTIONS(3), - [sym__string_content] = ACTIONS(1), - [sym_raw_string] = ACTIONS(1), - [sym_float] = ACTIONS(1), - [sym_block_comment] = ACTIONS(3), - }, - [1] = { - [sym_source_file] = STATE(78), - [sym__value] = STATE(77), - [sym_enum_variant] = STATE(77), - [sym_array] = STATE(77), - [sym_map] = STATE(77), - [sym_struct] = STATE(77), - [sym_unit_struct] = STATE(28), - [sym_struct_name] = STATE(56), - [sym__tuple_struct] = STATE(28), - [sym__named_struct] = STATE(41), - [sym__struct_body] = STATE(18), - [sym_tuple] = STATE(77), - [sym__literal] = STATE(77), - [sym_negative] = STATE(77), - [sym_string] = STATE(77), - [sym_char] = STATE(77), - [sym_boolean] = STATE(77), - [anon_sym_LBRACK] = ACTIONS(5), - [anon_sym_LBRACE] = ACTIONS(7), - [anon_sym_LPAREN_RPAREN] = ACTIONS(9), - [anon_sym_LPAREN] = ACTIONS(11), - [sym_integer] = ACTIONS(13), - [anon_sym_DASH] = ACTIONS(15), - [aux_sym_string_token1] = ACTIONS(17), - [anon_sym_b] = ACTIONS(19), - [anon_sym_SQUOTE] = ACTIONS(21), - [anon_sym_true] = ACTIONS(23), - [anon_sym_false] = ACTIONS(23), - [sym_identifier] = ACTIONS(25), - [sym_line_comment] = ACTIONS(3), - [sym_float] = ACTIONS(13), - [sym_block_comment] = ACTIONS(3), - }, - [2] = { - [sym__value] = STATE(72), - [sym_enum_variant] = STATE(72), - [sym_array] = STATE(72), - [sym_map] = STATE(72), - [sym_struct] = STATE(72), - [sym_unit_struct] = STATE(28), - [sym_struct_name] = STATE(56), - [sym__tuple_struct] = STATE(28), - [sym__named_struct] = STATE(41), - [sym__struct_body] = STATE(18), - [sym_tuple] = STATE(72), - [sym_map_entry] = STATE(53), - [sym__literal] = STATE(72), - [sym_negative] = STATE(72), - [sym_string] = STATE(72), - [sym_char] = STATE(72), - [sym_boolean] = STATE(72), - [anon_sym_LBRACK] = ACTIONS(5), - [anon_sym_COMMA] = ACTIONS(27), - [anon_sym_LBRACE] = ACTIONS(7), - [anon_sym_RBRACE] = ACTIONS(29), - [anon_sym_LPAREN_RPAREN] = ACTIONS(9), - [anon_sym_LPAREN] = ACTIONS(11), - [sym_integer] = ACTIONS(31), - [anon_sym_DASH] = ACTIONS(15), - [aux_sym_string_token1] = ACTIONS(17), - [anon_sym_b] = ACTIONS(19), - [anon_sym_SQUOTE] = ACTIONS(21), - [anon_sym_true] = ACTIONS(23), - [anon_sym_false] = ACTIONS(23), - [sym_identifier] = ACTIONS(25), - [sym_line_comment] = ACTIONS(3), - [sym_float] = ACTIONS(31), - [sym_block_comment] = ACTIONS(3), - }, - [3] = { - [sym__value] = STATE(58), - [sym_enum_variant] = STATE(58), - [sym_array] = STATE(58), - [sym_map] = STATE(58), - [sym_struct] = STATE(58), - [sym_unit_struct] = STATE(28), - [sym_struct_name] = STATE(56), - [sym__tuple_struct] = STATE(28), - [sym__named_struct] = STATE(41), - [sym__struct_body] = STATE(18), - [sym_tuple] = STATE(58), - [sym_struct_entry] = STATE(57), - [sym__literal] = STATE(58), - [sym_negative] = STATE(58), - [sym_string] = STATE(58), - [sym_char] = STATE(58), - [sym_boolean] = STATE(58), - [anon_sym_LBRACK] = ACTIONS(5), - [anon_sym_COMMA] = ACTIONS(33), - [anon_sym_LBRACE] = ACTIONS(7), - [anon_sym_LPAREN_RPAREN] = ACTIONS(9), - [anon_sym_LPAREN] = ACTIONS(11), - [anon_sym_RPAREN] = ACTIONS(35), - [sym_integer] = ACTIONS(37), - [anon_sym_DASH] = ACTIONS(15), - [aux_sym_string_token1] = ACTIONS(17), - [anon_sym_b] = ACTIONS(19), - [anon_sym_SQUOTE] = ACTIONS(21), - [anon_sym_true] = ACTIONS(23), - [anon_sym_false] = ACTIONS(23), - [sym_identifier] = ACTIONS(39), - [sym_line_comment] = ACTIONS(3), - [sym_float] = ACTIONS(37), - [sym_block_comment] = ACTIONS(3), - }, - [4] = { - [sym__value] = STATE(52), - [sym_enum_variant] = STATE(52), - [sym_array] = STATE(52), - [sym_map] = STATE(52), - [sym_struct] = STATE(52), - [sym_unit_struct] = STATE(28), - [sym_struct_name] = STATE(56), - [sym__tuple_struct] = STATE(28), - [sym__named_struct] = STATE(41), - [sym__struct_body] = STATE(18), - [sym_tuple] = STATE(52), - [sym__literal] = STATE(52), - [sym_negative] = STATE(52), - [sym_string] = STATE(52), - [sym_char] = STATE(52), - [sym_boolean] = STATE(52), - [anon_sym_LBRACK] = ACTIONS(5), - [anon_sym_COMMA] = ACTIONS(41), - [anon_sym_RBRACK] = ACTIONS(43), - [anon_sym_LBRACE] = ACTIONS(7), - [anon_sym_LPAREN_RPAREN] = ACTIONS(9), - [anon_sym_LPAREN] = ACTIONS(11), - [sym_integer] = ACTIONS(45), - [anon_sym_DASH] = ACTIONS(15), - [aux_sym_string_token1] = ACTIONS(17), - [anon_sym_b] = ACTIONS(19), - [anon_sym_SQUOTE] = ACTIONS(21), - [anon_sym_true] = ACTIONS(23), - [anon_sym_false] = ACTIONS(23), - [sym_identifier] = ACTIONS(25), - [sym_line_comment] = ACTIONS(3), - [sym_float] = ACTIONS(45), - [sym_block_comment] = ACTIONS(3), - }, - [5] = { - [sym__value] = STATE(72), - [sym_enum_variant] = STATE(72), - [sym_array] = STATE(72), - [sym_map] = STATE(72), - [sym_struct] = STATE(72), - [sym_unit_struct] = STATE(28), - [sym_struct_name] = STATE(56), - [sym__tuple_struct] = STATE(28), - [sym__named_struct] = STATE(41), - [sym__struct_body] = STATE(18), - [sym_tuple] = STATE(72), - [sym_map_entry] = STATE(68), - [sym__literal] = STATE(72), - [sym_negative] = STATE(72), - [sym_string] = STATE(72), - [sym_char] = STATE(72), - [sym_boolean] = STATE(72), - [anon_sym_LBRACK] = ACTIONS(5), - [anon_sym_LBRACE] = ACTIONS(7), - [anon_sym_RBRACE] = ACTIONS(47), - [anon_sym_LPAREN_RPAREN] = ACTIONS(9), - [anon_sym_LPAREN] = ACTIONS(11), - [sym_integer] = ACTIONS(31), - [anon_sym_DASH] = ACTIONS(15), - [aux_sym_string_token1] = ACTIONS(17), - [anon_sym_b] = ACTIONS(19), - [anon_sym_SQUOTE] = ACTIONS(21), - [anon_sym_true] = ACTIONS(23), - [anon_sym_false] = ACTIONS(23), - [sym_identifier] = ACTIONS(25), - [sym_line_comment] = ACTIONS(3), - [sym_float] = ACTIONS(31), - [sym_block_comment] = ACTIONS(3), - }, - [6] = { - [sym__value] = STATE(72), - [sym_enum_variant] = STATE(72), - [sym_array] = STATE(72), - [sym_map] = STATE(72), - [sym_struct] = STATE(72), - [sym_unit_struct] = STATE(28), - [sym_struct_name] = STATE(56), - [sym__tuple_struct] = STATE(28), - [sym__named_struct] = STATE(41), - [sym__struct_body] = STATE(18), - [sym_tuple] = STATE(72), - [sym_map_entry] = STATE(68), - [sym__literal] = STATE(72), - [sym_negative] = STATE(72), - [sym_string] = STATE(72), - [sym_char] = STATE(72), - [sym_boolean] = STATE(72), - [anon_sym_LBRACK] = ACTIONS(5), - [anon_sym_LBRACE] = ACTIONS(7), - [anon_sym_RBRACE] = ACTIONS(49), - [anon_sym_LPAREN_RPAREN] = ACTIONS(9), - [anon_sym_LPAREN] = ACTIONS(11), - [sym_integer] = ACTIONS(31), - [anon_sym_DASH] = ACTIONS(15), - [aux_sym_string_token1] = ACTIONS(17), - [anon_sym_b] = ACTIONS(19), - [anon_sym_SQUOTE] = ACTIONS(21), - [anon_sym_true] = ACTIONS(23), - [anon_sym_false] = ACTIONS(23), - [sym_identifier] = ACTIONS(25), - [sym_line_comment] = ACTIONS(3), - [sym_float] = ACTIONS(31), - [sym_block_comment] = ACTIONS(3), - }, - [7] = { - [sym__value] = STATE(55), - [sym_enum_variant] = STATE(55), - [sym_array] = STATE(55), - [sym_map] = STATE(55), - [sym_struct] = STATE(55), - [sym_unit_struct] = STATE(28), - [sym_struct_name] = STATE(56), - [sym__tuple_struct] = STATE(28), - [sym__named_struct] = STATE(41), - [sym__struct_body] = STATE(18), - [sym_tuple] = STATE(55), - [sym__literal] = STATE(55), - [sym_negative] = STATE(55), - [sym_string] = STATE(55), - [sym_char] = STATE(55), - [sym_boolean] = STATE(55), - [anon_sym_LBRACK] = ACTIONS(5), - [anon_sym_LBRACE] = ACTIONS(7), - [anon_sym_LPAREN_RPAREN] = ACTIONS(9), - [anon_sym_LPAREN] = ACTIONS(11), - [anon_sym_RPAREN] = ACTIONS(51), - [sym_integer] = ACTIONS(53), - [anon_sym_DASH] = ACTIONS(15), - [aux_sym_string_token1] = ACTIONS(17), - [anon_sym_b] = ACTIONS(19), - [anon_sym_SQUOTE] = ACTIONS(21), - [anon_sym_true] = ACTIONS(23), - [anon_sym_false] = ACTIONS(23), - [sym_identifier] = ACTIONS(25), - [sym_line_comment] = ACTIONS(3), - [sym_float] = ACTIONS(53), - [sym_block_comment] = ACTIONS(3), - }, - [8] = { - [sym__value] = STATE(55), - [sym_enum_variant] = STATE(55), - [sym_array] = STATE(55), - [sym_map] = STATE(55), - [sym_struct] = STATE(55), - [sym_unit_struct] = STATE(28), - [sym_struct_name] = STATE(56), - [sym__tuple_struct] = STATE(28), - [sym__named_struct] = STATE(41), - [sym__struct_body] = STATE(18), - [sym_tuple] = STATE(55), - [sym__literal] = STATE(55), - [sym_negative] = STATE(55), - [sym_string] = STATE(55), - [sym_char] = STATE(55), - [sym_boolean] = STATE(55), - [anon_sym_LBRACK] = ACTIONS(5), - [anon_sym_LBRACE] = ACTIONS(7), - [anon_sym_LPAREN_RPAREN] = ACTIONS(9), - [anon_sym_LPAREN] = ACTIONS(11), - [anon_sym_RPAREN] = ACTIONS(55), - [sym_integer] = ACTIONS(53), - [anon_sym_DASH] = ACTIONS(15), - [aux_sym_string_token1] = ACTIONS(17), - [anon_sym_b] = ACTIONS(19), - [anon_sym_SQUOTE] = ACTIONS(21), - [anon_sym_true] = ACTIONS(23), - [anon_sym_false] = ACTIONS(23), - [sym_identifier] = ACTIONS(25), - [sym_line_comment] = ACTIONS(3), - [sym_float] = ACTIONS(53), - [sym_block_comment] = ACTIONS(3), - }, - [9] = { - [sym__value] = STATE(55), - [sym_enum_variant] = STATE(55), - [sym_array] = STATE(55), - [sym_map] = STATE(55), - [sym_struct] = STATE(55), - [sym_unit_struct] = STATE(28), - [sym_struct_name] = STATE(56), - [sym__tuple_struct] = STATE(28), - [sym__named_struct] = STATE(41), - [sym__struct_body] = STATE(18), - [sym_tuple] = STATE(55), - [sym__literal] = STATE(55), - [sym_negative] = STATE(55), - [sym_string] = STATE(55), - [sym_char] = STATE(55), - [sym_boolean] = STATE(55), - [anon_sym_LBRACK] = ACTIONS(5), - [anon_sym_RBRACK] = ACTIONS(57), - [anon_sym_LBRACE] = ACTIONS(7), - [anon_sym_LPAREN_RPAREN] = ACTIONS(9), - [anon_sym_LPAREN] = ACTIONS(11), - [sym_integer] = ACTIONS(53), - [anon_sym_DASH] = ACTIONS(15), - [aux_sym_string_token1] = ACTIONS(17), - [anon_sym_b] = ACTIONS(19), - [anon_sym_SQUOTE] = ACTIONS(21), - [anon_sym_true] = ACTIONS(23), - [anon_sym_false] = ACTIONS(23), - [sym_identifier] = ACTIONS(25), - [sym_line_comment] = ACTIONS(3), - [sym_float] = ACTIONS(53), - [sym_block_comment] = ACTIONS(3), - }, - [10] = { - [sym__value] = STATE(55), - [sym_enum_variant] = STATE(55), - [sym_array] = STATE(55), - [sym_map] = STATE(55), - [sym_struct] = STATE(55), - [sym_unit_struct] = STATE(28), - [sym_struct_name] = STATE(56), - [sym__tuple_struct] = STATE(28), - [sym__named_struct] = STATE(41), - [sym__struct_body] = STATE(18), - [sym_tuple] = STATE(55), - [sym__literal] = STATE(55), - [sym_negative] = STATE(55), - [sym_string] = STATE(55), - [sym_char] = STATE(55), - [sym_boolean] = STATE(55), - [anon_sym_LBRACK] = ACTIONS(5), - [anon_sym_RBRACK] = ACTIONS(59), - [anon_sym_LBRACE] = ACTIONS(7), - [anon_sym_LPAREN_RPAREN] = ACTIONS(9), - [anon_sym_LPAREN] = ACTIONS(11), - [sym_integer] = ACTIONS(53), - [anon_sym_DASH] = ACTIONS(15), - [aux_sym_string_token1] = ACTIONS(17), - [anon_sym_b] = ACTIONS(19), - [anon_sym_SQUOTE] = ACTIONS(21), - [anon_sym_true] = ACTIONS(23), - [anon_sym_false] = ACTIONS(23), - [sym_identifier] = ACTIONS(25), - [sym_line_comment] = ACTIONS(3), - [sym_float] = ACTIONS(53), - [sym_block_comment] = ACTIONS(3), - }, - [11] = { - [sym__value] = STATE(72), - [sym_enum_variant] = STATE(72), - [sym_array] = STATE(72), - [sym_map] = STATE(72), - [sym_struct] = STATE(72), - [sym_unit_struct] = STATE(28), - [sym_struct_name] = STATE(56), - [sym__tuple_struct] = STATE(28), - [sym__named_struct] = STATE(41), - [sym__struct_body] = STATE(18), - [sym_tuple] = STATE(72), - [sym_map_entry] = STATE(68), - [sym__literal] = STATE(72), - [sym_negative] = STATE(72), - [sym_string] = STATE(72), - [sym_char] = STATE(72), - [sym_boolean] = STATE(72), - [anon_sym_LBRACK] = ACTIONS(5), - [anon_sym_LBRACE] = ACTIONS(7), - [anon_sym_LPAREN_RPAREN] = ACTIONS(9), - [anon_sym_LPAREN] = ACTIONS(11), - [sym_integer] = ACTIONS(31), - [anon_sym_DASH] = ACTIONS(15), - [aux_sym_string_token1] = ACTIONS(17), - [anon_sym_b] = ACTIONS(19), - [anon_sym_SQUOTE] = ACTIONS(21), - [anon_sym_true] = ACTIONS(23), - [anon_sym_false] = ACTIONS(23), - [sym_identifier] = ACTIONS(25), - [sym_line_comment] = ACTIONS(3), - [sym_float] = ACTIONS(31), - [sym_block_comment] = ACTIONS(3), - }, - [12] = { - [sym__value] = STATE(65), - [sym_enum_variant] = STATE(65), - [sym_array] = STATE(65), - [sym_map] = STATE(65), - [sym_struct] = STATE(65), - [sym_unit_struct] = STATE(28), - [sym_struct_name] = STATE(56), - [sym__tuple_struct] = STATE(28), - [sym__named_struct] = STATE(41), - [sym__struct_body] = STATE(18), - [sym_tuple] = STATE(65), - [sym__literal] = STATE(65), - [sym_negative] = STATE(65), - [sym_string] = STATE(65), - [sym_char] = STATE(65), - [sym_boolean] = STATE(65), - [anon_sym_LBRACK] = ACTIONS(5), - [anon_sym_LBRACE] = ACTIONS(7), - [anon_sym_LPAREN_RPAREN] = ACTIONS(9), - [anon_sym_LPAREN] = ACTIONS(11), - [sym_integer] = ACTIONS(61), - [anon_sym_DASH] = ACTIONS(15), - [aux_sym_string_token1] = ACTIONS(17), - [anon_sym_b] = ACTIONS(19), - [anon_sym_SQUOTE] = ACTIONS(21), - [anon_sym_true] = ACTIONS(23), - [anon_sym_false] = ACTIONS(23), - [sym_identifier] = ACTIONS(25), - [sym_line_comment] = ACTIONS(3), - [sym_float] = ACTIONS(61), - [sym_block_comment] = ACTIONS(3), - }, - [13] = { - [sym__value] = STATE(67), - [sym_enum_variant] = STATE(67), - [sym_array] = STATE(67), - [sym_map] = STATE(67), - [sym_struct] = STATE(67), - [sym_unit_struct] = STATE(28), - [sym_struct_name] = STATE(56), - [sym__tuple_struct] = STATE(28), - [sym__named_struct] = STATE(41), - [sym__struct_body] = STATE(18), - [sym_tuple] = STATE(67), - [sym__literal] = STATE(67), - [sym_negative] = STATE(67), - [sym_string] = STATE(67), - [sym_char] = STATE(67), - [sym_boolean] = STATE(67), - [anon_sym_LBRACK] = ACTIONS(5), - [anon_sym_LBRACE] = ACTIONS(7), - [anon_sym_LPAREN_RPAREN] = ACTIONS(9), - [anon_sym_LPAREN] = ACTIONS(11), - [sym_integer] = ACTIONS(63), - [anon_sym_DASH] = ACTIONS(15), - [aux_sym_string_token1] = ACTIONS(17), - [anon_sym_b] = ACTIONS(19), - [anon_sym_SQUOTE] = ACTIONS(21), - [anon_sym_true] = ACTIONS(23), - [anon_sym_false] = ACTIONS(23), - [sym_identifier] = ACTIONS(25), - [sym_line_comment] = ACTIONS(3), - [sym_float] = ACTIONS(63), - [sym_block_comment] = ACTIONS(3), - }, - [14] = { - [sym__value] = STATE(55), - [sym_enum_variant] = STATE(55), - [sym_array] = STATE(55), - [sym_map] = STATE(55), - [sym_struct] = STATE(55), - [sym_unit_struct] = STATE(28), - [sym_struct_name] = STATE(56), - [sym__tuple_struct] = STATE(28), - [sym__named_struct] = STATE(41), - [sym__struct_body] = STATE(18), - [sym_tuple] = STATE(55), - [sym__literal] = STATE(55), - [sym_negative] = STATE(55), - [sym_string] = STATE(55), - [sym_char] = STATE(55), - [sym_boolean] = STATE(55), - [anon_sym_LBRACK] = ACTIONS(5), - [anon_sym_LBRACE] = ACTIONS(7), - [anon_sym_LPAREN_RPAREN] = ACTIONS(9), - [anon_sym_LPAREN] = ACTIONS(11), - [sym_integer] = ACTIONS(53), - [anon_sym_DASH] = ACTIONS(15), - [aux_sym_string_token1] = ACTIONS(17), - [anon_sym_b] = ACTIONS(19), - [anon_sym_SQUOTE] = ACTIONS(21), - [anon_sym_true] = ACTIONS(23), - [anon_sym_false] = ACTIONS(23), - [sym_identifier] = ACTIONS(25), - [sym_line_comment] = ACTIONS(3), - [sym_float] = ACTIONS(53), - [sym_block_comment] = ACTIONS(3), - }, -}; - -static const uint16_t ts_small_parse_table[] = { - [0] = 3, - ACTIONS(67), 1, - anon_sym_LPAREN, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(65), 6, - ts_builtin_sym_end, - anon_sym_COMMA, - anon_sym_RBRACK, - anon_sym_RBRACE, - anon_sym_RPAREN, - anon_sym_COLON, - [16] = 2, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(69), 6, - ts_builtin_sym_end, - anon_sym_COMMA, - anon_sym_RBRACK, - anon_sym_RBRACE, - anon_sym_RPAREN, - anon_sym_COLON, - [29] = 2, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(71), 6, - ts_builtin_sym_end, - anon_sym_COMMA, - anon_sym_RBRACK, - anon_sym_RBRACE, - anon_sym_RPAREN, - anon_sym_COLON, - [42] = 2, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(73), 6, - ts_builtin_sym_end, - anon_sym_COMMA, - anon_sym_RBRACK, - anon_sym_RBRACE, - anon_sym_RPAREN, - anon_sym_COLON, - [55] = 2, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(75), 6, - ts_builtin_sym_end, - anon_sym_COMMA, - anon_sym_RBRACK, - anon_sym_RBRACE, - anon_sym_RPAREN, - anon_sym_COLON, - [68] = 2, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(77), 6, - ts_builtin_sym_end, - anon_sym_COMMA, - anon_sym_RBRACK, - anon_sym_RBRACE, - anon_sym_RPAREN, - anon_sym_COLON, - [81] = 2, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(79), 6, - ts_builtin_sym_end, - anon_sym_COMMA, - anon_sym_RBRACK, - anon_sym_RBRACE, - anon_sym_RPAREN, - anon_sym_COLON, - [94] = 2, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(81), 6, - ts_builtin_sym_end, - anon_sym_COMMA, - anon_sym_RBRACK, - anon_sym_RBRACE, - anon_sym_RPAREN, - anon_sym_COLON, - [107] = 2, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(83), 6, - ts_builtin_sym_end, - anon_sym_COMMA, - anon_sym_RBRACK, - anon_sym_RBRACE, - anon_sym_RPAREN, - anon_sym_COLON, - [120] = 5, - ACTIONS(85), 1, - anon_sym_DQUOTE, - ACTIONS(90), 1, - sym__string_content, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(87), 2, - aux_sym__escape_sequence_token1, - sym_escape_sequence, - STATE(24), 2, - sym__escape_sequence, - aux_sym_string_repeat1, - [139] = 2, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(93), 6, - ts_builtin_sym_end, - anon_sym_COMMA, - anon_sym_RBRACK, - anon_sym_RBRACE, - anon_sym_RPAREN, - anon_sym_COLON, - [152] = 2, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(95), 6, - ts_builtin_sym_end, - anon_sym_COMMA, - anon_sym_RBRACK, - anon_sym_RBRACE, - anon_sym_RPAREN, - anon_sym_COLON, - [165] = 2, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(97), 6, - ts_builtin_sym_end, - anon_sym_COMMA, - anon_sym_RBRACK, - anon_sym_RBRACE, - anon_sym_RPAREN, - anon_sym_COLON, - [178] = 2, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(99), 6, - ts_builtin_sym_end, - anon_sym_COMMA, - anon_sym_RBRACK, - anon_sym_RBRACE, - anon_sym_RPAREN, - anon_sym_COLON, - [191] = 2, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(101), 6, - ts_builtin_sym_end, - anon_sym_COMMA, - anon_sym_RBRACK, - anon_sym_RBRACE, - anon_sym_RPAREN, - anon_sym_COLON, - [204] = 2, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(103), 6, - ts_builtin_sym_end, - anon_sym_COMMA, - anon_sym_RBRACK, - anon_sym_RBRACE, - anon_sym_RPAREN, - anon_sym_COLON, - [217] = 2, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(105), 6, - ts_builtin_sym_end, - anon_sym_COMMA, - anon_sym_RBRACK, - anon_sym_RBRACE, - anon_sym_RPAREN, - anon_sym_COLON, - [230] = 5, - ACTIONS(107), 1, - anon_sym_DQUOTE, - ACTIONS(111), 1, - sym__string_content, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(109), 2, - aux_sym__escape_sequence_token1, - sym_escape_sequence, - STATE(24), 2, - sym__escape_sequence, - aux_sym_string_repeat1, - [249] = 2, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(113), 6, - ts_builtin_sym_end, - anon_sym_COMMA, - anon_sym_RBRACK, - anon_sym_RBRACE, - anon_sym_RPAREN, - anon_sym_COLON, - [262] = 2, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(115), 6, - ts_builtin_sym_end, - anon_sym_COMMA, - anon_sym_RBRACK, - anon_sym_RBRACE, - anon_sym_RPAREN, - anon_sym_COLON, - [275] = 2, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(117), 6, - ts_builtin_sym_end, - anon_sym_COMMA, - anon_sym_RBRACK, - anon_sym_RBRACE, - anon_sym_RPAREN, - anon_sym_COLON, - [288] = 2, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(119), 6, - ts_builtin_sym_end, - anon_sym_COMMA, - anon_sym_RBRACK, - anon_sym_RBRACE, - anon_sym_RPAREN, - anon_sym_COLON, - [301] = 2, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(121), 6, - ts_builtin_sym_end, - anon_sym_COMMA, - anon_sym_RBRACK, - anon_sym_RBRACE, - anon_sym_RPAREN, - anon_sym_COLON, - [314] = 2, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(123), 6, - ts_builtin_sym_end, - anon_sym_COMMA, - anon_sym_RBRACK, - anon_sym_RBRACE, - anon_sym_RPAREN, - anon_sym_COLON, - [327] = 2, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(125), 6, - ts_builtin_sym_end, - anon_sym_COMMA, - anon_sym_RBRACK, - anon_sym_RBRACE, - anon_sym_RPAREN, - anon_sym_COLON, - [340] = 2, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(127), 6, - ts_builtin_sym_end, - anon_sym_COMMA, - anon_sym_RBRACK, - anon_sym_RBRACE, - anon_sym_RPAREN, - anon_sym_COLON, - [353] = 2, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(129), 6, - ts_builtin_sym_end, - anon_sym_COMMA, - anon_sym_RBRACK, - anon_sym_RBRACE, - anon_sym_RPAREN, - anon_sym_COLON, - [366] = 2, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(131), 6, - ts_builtin_sym_end, - anon_sym_COMMA, - anon_sym_RBRACK, - anon_sym_RBRACE, - anon_sym_RPAREN, - anon_sym_COLON, - [379] = 2, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(133), 6, - ts_builtin_sym_end, - anon_sym_COMMA, - anon_sym_RBRACK, - anon_sym_RBRACE, - anon_sym_RPAREN, - anon_sym_COLON, - [392] = 2, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(135), 6, - ts_builtin_sym_end, - anon_sym_COMMA, - anon_sym_RBRACK, - anon_sym_RBRACE, - anon_sym_RPAREN, - anon_sym_COLON, - [405] = 5, - ACTIONS(137), 1, - anon_sym_DQUOTE, - ACTIONS(141), 1, - sym__string_content, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(139), 2, - aux_sym__escape_sequence_token1, - sym_escape_sequence, - STATE(32), 2, - sym__escape_sequence, - aux_sym_string_repeat1, - [424] = 2, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(143), 6, - ts_builtin_sym_end, - anon_sym_COMMA, - anon_sym_RBRACK, - anon_sym_RBRACE, - anon_sym_RPAREN, - anon_sym_COLON, - [437] = 5, - ACTIONS(3), 1, - sym_block_comment, - ACTIONS(145), 1, - anon_sym_SQUOTE, - ACTIONS(149), 1, - sym_line_comment, - STATE(80), 1, - sym__escape_sequence, - ACTIONS(147), 3, - aux_sym_char_token1, - aux_sym__escape_sequence_token1, - sym_escape_sequence, - [455] = 5, - ACTIONS(3), 1, - sym_block_comment, - ACTIONS(149), 1, - sym_line_comment, - ACTIONS(151), 1, - anon_sym_SQUOTE, - STATE(71), 1, - sym__escape_sequence, - ACTIONS(153), 3, - aux_sym_char_token1, - aux_sym__escape_sequence_token1, - sym_escape_sequence, - [473] = 4, - ACTIONS(155), 1, - anon_sym_COMMA, - STATE(49), 1, - aux_sym_array_repeat1, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(158), 2, - anon_sym_RBRACK, - anon_sym_RPAREN, - [488] = 4, - ACTIONS(67), 1, - anon_sym_LPAREN, - ACTIONS(160), 1, - anon_sym_COLON, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(65), 2, - anon_sym_COMMA, - anon_sym_RPAREN, - [503] = 4, - ACTIONS(162), 1, - anon_sym_COMMA, - ACTIONS(165), 1, - anon_sym_RBRACE, - STATE(51), 1, - aux_sym_map_repeat1, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - [517] = 4, - ACTIONS(167), 1, - anon_sym_COMMA, - ACTIONS(169), 1, - anon_sym_RBRACK, - STATE(54), 1, - aux_sym_array_repeat1, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - [531] = 4, - ACTIONS(171), 1, - anon_sym_COMMA, - ACTIONS(173), 1, - anon_sym_RBRACE, - STATE(62), 1, - aux_sym_map_repeat1, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - [545] = 4, - ACTIONS(57), 1, - anon_sym_RBRACK, - ACTIONS(175), 1, - anon_sym_COMMA, - STATE(49), 1, - aux_sym_array_repeat1, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - [559] = 2, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(158), 3, - anon_sym_COMMA, - anon_sym_RBRACK, - anon_sym_RPAREN, - [569] = 4, - ACTIONS(177), 1, - anon_sym_LPAREN, - STATE(36), 1, - sym__struct_body, - STATE(37), 1, - sym_tuple, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - [583] = 4, - ACTIONS(179), 1, - anon_sym_COMMA, - ACTIONS(181), 1, - anon_sym_RPAREN, - STATE(59), 1, - aux_sym__struct_body_repeat1, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - [597] = 4, - ACTIONS(183), 1, - anon_sym_COMMA, - ACTIONS(185), 1, - anon_sym_RPAREN, - STATE(61), 1, - aux_sym_array_repeat1, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - [611] = 4, - ACTIONS(187), 1, - anon_sym_COMMA, - ACTIONS(189), 1, - anon_sym_RPAREN, - STATE(64), 1, - aux_sym__struct_body_repeat1, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - [625] = 4, - ACTIONS(189), 1, - anon_sym_RPAREN, - ACTIONS(191), 1, - sym_identifier, - STATE(70), 1, - sym_struct_entry, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - [639] = 4, - ACTIONS(55), 1, - anon_sym_RPAREN, - ACTIONS(193), 1, - anon_sym_COMMA, - STATE(49), 1, - aux_sym_array_repeat1, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - [653] = 4, - ACTIONS(47), 1, - anon_sym_RBRACE, - ACTIONS(195), 1, - anon_sym_COMMA, - STATE(51), 1, - aux_sym_map_repeat1, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - [667] = 4, - ACTIONS(191), 1, - sym_identifier, - ACTIONS(197), 1, - anon_sym_RPAREN, - STATE(70), 1, - sym_struct_entry, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - [681] = 4, - ACTIONS(199), 1, - anon_sym_COMMA, - ACTIONS(202), 1, - anon_sym_RPAREN, - STATE(64), 1, - aux_sym__struct_body_repeat1, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - [695] = 2, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(204), 2, - anon_sym_COMMA, - anon_sym_RPAREN, - [704] = 3, - ACTIONS(191), 1, - sym_identifier, - STATE(70), 1, - sym_struct_entry, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - [715] = 2, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(206), 2, - anon_sym_COMMA, - anon_sym_RBRACE, - [724] = 2, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(165), 2, - anon_sym_COMMA, - anon_sym_RBRACE, - [733] = 2, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(208), 2, - sym_float, - sym_integer, - [742] = 2, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - ACTIONS(202), 2, - anon_sym_COMMA, - anon_sym_RPAREN, - [751] = 2, - ACTIONS(210), 1, - anon_sym_SQUOTE, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - [759] = 2, - ACTIONS(212), 1, - anon_sym_COLON, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - [767] = 2, - ACTIONS(173), 1, - anon_sym_RBRACE, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - [775] = 2, - ACTIONS(160), 1, - anon_sym_COLON, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - [783] = 2, - ACTIONS(169), 1, - anon_sym_RBRACK, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - [791] = 2, - ACTIONS(181), 1, - anon_sym_RPAREN, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - [799] = 2, - ACTIONS(214), 1, - ts_builtin_sym_end, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - [807] = 2, - ACTIONS(216), 1, - ts_builtin_sym_end, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - [815] = 2, - ACTIONS(218), 1, - anon_sym_SQUOTE, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, - [823] = 2, - ACTIONS(220), 1, - anon_sym_SQUOTE, - ACTIONS(3), 2, - sym_block_comment, - sym_line_comment, -}; - -static const uint32_t ts_small_parse_table_map[] = { - [SMALL_STATE(15)] = 0, - [SMALL_STATE(16)] = 16, - [SMALL_STATE(17)] = 29, - [SMALL_STATE(18)] = 42, - [SMALL_STATE(19)] = 55, - [SMALL_STATE(20)] = 68, - [SMALL_STATE(21)] = 81, - [SMALL_STATE(22)] = 94, - [SMALL_STATE(23)] = 107, - [SMALL_STATE(24)] = 120, - [SMALL_STATE(25)] = 139, - [SMALL_STATE(26)] = 152, - [SMALL_STATE(27)] = 165, - [SMALL_STATE(28)] = 178, - [SMALL_STATE(29)] = 191, - [SMALL_STATE(30)] = 204, - [SMALL_STATE(31)] = 217, - [SMALL_STATE(32)] = 230, - [SMALL_STATE(33)] = 249, - [SMALL_STATE(34)] = 262, - [SMALL_STATE(35)] = 275, - [SMALL_STATE(36)] = 288, - [SMALL_STATE(37)] = 301, - [SMALL_STATE(38)] = 314, - [SMALL_STATE(39)] = 327, - [SMALL_STATE(40)] = 340, - [SMALL_STATE(41)] = 353, - [SMALL_STATE(42)] = 366, - [SMALL_STATE(43)] = 379, - [SMALL_STATE(44)] = 392, - [SMALL_STATE(45)] = 405, - [SMALL_STATE(46)] = 424, - [SMALL_STATE(47)] = 437, - [SMALL_STATE(48)] = 455, - [SMALL_STATE(49)] = 473, - [SMALL_STATE(50)] = 488, - [SMALL_STATE(51)] = 503, - [SMALL_STATE(52)] = 517, - [SMALL_STATE(53)] = 531, - [SMALL_STATE(54)] = 545, - [SMALL_STATE(55)] = 559, - [SMALL_STATE(56)] = 569, - [SMALL_STATE(57)] = 583, - [SMALL_STATE(58)] = 597, - [SMALL_STATE(59)] = 611, - [SMALL_STATE(60)] = 625, - [SMALL_STATE(61)] = 639, - [SMALL_STATE(62)] = 653, - [SMALL_STATE(63)] = 667, - [SMALL_STATE(64)] = 681, - [SMALL_STATE(65)] = 695, - [SMALL_STATE(66)] = 704, - [SMALL_STATE(67)] = 715, - [SMALL_STATE(68)] = 724, - [SMALL_STATE(69)] = 733, - [SMALL_STATE(70)] = 742, - [SMALL_STATE(71)] = 751, - [SMALL_STATE(72)] = 759, - [SMALL_STATE(73)] = 767, - [SMALL_STATE(74)] = 775, - [SMALL_STATE(75)] = 783, - [SMALL_STATE(76)] = 791, - [SMALL_STATE(77)] = 799, - [SMALL_STATE(78)] = 807, - [SMALL_STATE(79)] = 815, - [SMALL_STATE(80)] = 823, -}; - -static const TSParseActionEntry ts_parse_actions[] = { - [0] = {.entry = {.count = 0, .reusable = false}}, - [1] = {.entry = {.count = 1, .reusable = false}}, RECOVER(), - [3] = {.entry = {.count = 1, .reusable = true}}, SHIFT_EXTRA(), - [5] = {.entry = {.count = 1, .reusable = true}}, SHIFT(4), - [7] = {.entry = {.count = 1, .reusable = true}}, SHIFT(2), - [9] = {.entry = {.count = 1, .reusable = true}}, SHIFT(25), - [11] = {.entry = {.count = 1, .reusable = false}}, SHIFT(3), - [13] = {.entry = {.count = 1, .reusable = true}}, SHIFT(77), - [15] = {.entry = {.count = 1, .reusable = true}}, SHIFT(69), - [17] = {.entry = {.count = 1, .reusable = true}}, SHIFT(45), - [19] = {.entry = {.count = 1, .reusable = false}}, SHIFT(79), - [21] = {.entry = {.count = 1, .reusable = true}}, SHIFT(47), - [23] = {.entry = {.count = 1, .reusable = false}}, SHIFT(39), - [25] = {.entry = {.count = 1, .reusable = false}}, SHIFT(15), - [27] = {.entry = {.count = 1, .reusable = true}}, SHIFT(73), - [29] = {.entry = {.count = 1, .reusable = true}}, SHIFT(23), - [31] = {.entry = {.count = 1, .reusable = true}}, SHIFT(72), - [33] = {.entry = {.count = 1, .reusable = true}}, SHIFT(76), - [35] = {.entry = {.count = 1, .reusable = true}}, SHIFT(26), - [37] = {.entry = {.count = 1, .reusable = true}}, SHIFT(58), - [39] = {.entry = {.count = 1, .reusable = false}}, SHIFT(50), - [41] = {.entry = {.count = 1, .reusable = true}}, SHIFT(75), - [43] = {.entry = {.count = 1, .reusable = true}}, SHIFT(20), - [45] = {.entry = {.count = 1, .reusable = true}}, SHIFT(52), - [47] = {.entry = {.count = 1, .reusable = true}}, SHIFT(27), - [49] = {.entry = {.count = 1, .reusable = true}}, SHIFT(29), - [51] = {.entry = {.count = 1, .reusable = true}}, SHIFT(43), - [53] = {.entry = {.count = 1, .reusable = true}}, SHIFT(55), - [55] = {.entry = {.count = 1, .reusable = true}}, SHIFT(16), - [57] = {.entry = {.count = 1, .reusable = true}}, SHIFT(35), - [59] = {.entry = {.count = 1, .reusable = true}}, SHIFT(19), - [61] = {.entry = {.count = 1, .reusable = true}}, SHIFT(65), - [63] = {.entry = {.count = 1, .reusable = true}}, SHIFT(67), - [65] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_enum_variant, 1), - [67] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_struct_name, 1), - [69] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_tuple, 4), - [71] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_map, 3), - [73] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__named_struct, 1, .production_id = 2), - [75] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_array, 5), - [77] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_array, 2), - [79] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_char, 4), - [81] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__struct_body, 4), - [83] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_map, 2), - [85] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_string_repeat1, 2), - [87] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_string_repeat1, 2), SHIFT_REPEAT(24), - [90] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_string_repeat1, 2), SHIFT_REPEAT(24), - [93] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_unit_struct, 1), - [95] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__struct_body, 2), - [97] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_map, 4), - [99] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_struct, 1), - [101] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_map, 5), - [103] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_negative, 2), - [105] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_string, 2), - [107] = {.entry = {.count = 1, .reusable = true}}, SHIFT(33), - [109] = {.entry = {.count = 1, .reusable = false}}, SHIFT(24), - [111] = {.entry = {.count = 1, .reusable = true}}, SHIFT(24), - [113] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_string, 3), - [115] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_char, 2), - [117] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_array, 4), - [119] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__named_struct, 2, .production_id = 3), - [121] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__tuple_struct, 2), - [123] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_array, 3), - [125] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_boolean, 1), - [127] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_char, 3), - [129] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_struct, 1, .production_id = 1), - [131] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_tuple, 3), - [133] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_tuple, 5), - [135] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__struct_body, 3), - [137] = {.entry = {.count = 1, .reusable = true}}, SHIFT(31), - [139] = {.entry = {.count = 1, .reusable = false}}, SHIFT(32), - [141] = {.entry = {.count = 1, .reusable = true}}, SHIFT(32), - [143] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__struct_body, 5), - [145] = {.entry = {.count = 1, .reusable = false}}, SHIFT(34), - [147] = {.entry = {.count = 1, .reusable = false}}, SHIFT(80), - [149] = {.entry = {.count = 1, .reusable = false}}, SHIFT_EXTRA(), - [151] = {.entry = {.count = 1, .reusable = false}}, SHIFT(40), - [153] = {.entry = {.count = 1, .reusable = false}}, SHIFT(71), - [155] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_array_repeat1, 2), SHIFT_REPEAT(14), - [158] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_array_repeat1, 2), - [160] = {.entry = {.count = 1, .reusable = true}}, SHIFT(12), - [162] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_map_repeat1, 2), SHIFT_REPEAT(11), - [165] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_map_repeat1, 2), - [167] = {.entry = {.count = 1, .reusable = true}}, SHIFT(9), - [169] = {.entry = {.count = 1, .reusable = true}}, SHIFT(38), - [171] = {.entry = {.count = 1, .reusable = true}}, SHIFT(5), - [173] = {.entry = {.count = 1, .reusable = true}}, SHIFT(17), - [175] = {.entry = {.count = 1, .reusable = true}}, SHIFT(10), - [177] = {.entry = {.count = 1, .reusable = true}}, SHIFT(3), - [179] = {.entry = {.count = 1, .reusable = true}}, SHIFT(60), - [181] = {.entry = {.count = 1, .reusable = true}}, SHIFT(44), - [183] = {.entry = {.count = 1, .reusable = true}}, SHIFT(8), - [185] = {.entry = {.count = 1, .reusable = true}}, SHIFT(42), - [187] = {.entry = {.count = 1, .reusable = true}}, SHIFT(63), - [189] = {.entry = {.count = 1, .reusable = true}}, SHIFT(22), - [191] = {.entry = {.count = 1, .reusable = true}}, SHIFT(74), - [193] = {.entry = {.count = 1, .reusable = true}}, SHIFT(7), - [195] = {.entry = {.count = 1, .reusable = true}}, SHIFT(6), - [197] = {.entry = {.count = 1, .reusable = true}}, SHIFT(46), - [199] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym__struct_body_repeat1, 2), SHIFT_REPEAT(66), - [202] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym__struct_body_repeat1, 2), - [204] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_struct_entry, 3), - [206] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_map_entry, 3), - [208] = {.entry = {.count = 1, .reusable = true}}, SHIFT(30), - [210] = {.entry = {.count = 1, .reusable = true}}, SHIFT(21), - [212] = {.entry = {.count = 1, .reusable = true}}, SHIFT(13), - [214] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 1), - [216] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(), - [218] = {.entry = {.count = 1, .reusable = true}}, SHIFT(48), - [220] = {.entry = {.count = 1, .reusable = true}}, SHIFT(40), -}; - -#ifdef __cplusplus -extern "C" { -#endif -void *tree_sitter_ron_external_scanner_create(void); -void tree_sitter_ron_external_scanner_destroy(void *); -bool tree_sitter_ron_external_scanner_scan(void *, TSLexer *, const bool *); -unsigned tree_sitter_ron_external_scanner_serialize(void *, char *); -void tree_sitter_ron_external_scanner_deserialize(void *, const char *, unsigned); - -#ifdef _WIN32 -#define extern __declspec(dllexport) -#endif - -extern const TSLanguage *tree_sitter_ron(void) { - static const TSLanguage language = { - .version = LANGUAGE_VERSION, - .symbol_count = SYMBOL_COUNT, - .alias_count = ALIAS_COUNT, - .token_count = TOKEN_COUNT, - .external_token_count = EXTERNAL_TOKEN_COUNT, - .state_count = STATE_COUNT, - .large_state_count = LARGE_STATE_COUNT, - .production_id_count = PRODUCTION_ID_COUNT, - .field_count = FIELD_COUNT, - .max_alias_sequence_length = MAX_ALIAS_SEQUENCE_LENGTH, - .parse_table = &ts_parse_table[0][0], - .small_parse_table = ts_small_parse_table, - .small_parse_table_map = ts_small_parse_table_map, - .parse_actions = ts_parse_actions, - .symbol_names = ts_symbol_names, - .field_names = ts_field_names, - .field_map_slices = ts_field_map_slices, - .field_map_entries = ts_field_map_entries, - .symbol_metadata = ts_symbol_metadata, - .public_symbol_map = ts_symbol_map, - .alias_map = ts_non_terminal_alias_map, - .alias_sequences = &ts_alias_sequences[0][0], - .lex_modes = ts_lex_modes, - .lex_fn = ts_lex, - .external_scanner = { - &ts_external_scanner_states[0][0], - ts_external_scanner_symbol_map, - tree_sitter_ron_external_scanner_create, - tree_sitter_ron_external_scanner_destroy, - tree_sitter_ron_external_scanner_scan, - tree_sitter_ron_external_scanner_serialize, - tree_sitter_ron_external_scanner_deserialize, - }, - .primary_state_ids = ts_primary_state_ids, - }; - return &language; -} -#ifdef __cplusplus -} -#endif diff --git a/ratisui-tree-sitter-ron/src/scanner.c b/ratisui-tree-sitter-ron/src/scanner.c deleted file mode 100644 index 36b0c35..0000000 --- a/ratisui-tree-sitter-ron/src/scanner.c +++ /dev/null @@ -1,191 +0,0 @@ -#include -#include - -enum TokenType { - STRING_CONTENT, - RAW_STRING, - FLOAT, - BLOCK_COMMENT, -}; - -void *tree_sitter_ron_external_scanner_create() { return NULL; } -void tree_sitter_ron_external_scanner_destroy(void *p) {} -void tree_sitter_ron_external_scanner_reset(void *p) {} -unsigned tree_sitter_ron_external_scanner_serialize(void *p, char *buffer) { - return 0; -} -void tree_sitter_ron_external_scanner_deserialize(void *p, const char *b, - unsigned n) {} - -static void advance(TSLexer *lexer) { lexer->advance(lexer, false); } - -static bool is_num_char(int32_t c) { return c == '_' || iswdigit(c); } - -bool tree_sitter_ron_external_scanner_scan(void *payload, TSLexer *lexer, - const bool *valid_symbols) { - if (valid_symbols[STRING_CONTENT] && !valid_symbols[FLOAT]) { - bool has_content = false; - for (;;) { - if (lexer->lookahead == '\"' || lexer->lookahead == '\\') { - break; - } else if (lexer->lookahead == 0) { - return false; - } - has_content = true; - advance(lexer); - } - lexer->result_symbol = STRING_CONTENT; - return has_content; - } - - while (iswspace(lexer->lookahead)) - lexer->advance(lexer, true); - - if (valid_symbols[RAW_STRING] && - (lexer->lookahead == 'r' || lexer->lookahead == 'b')) { - lexer->result_symbol = RAW_STRING; - if (lexer->lookahead == 'b') - advance(lexer); - if (lexer->lookahead != 'r') - return false; - advance(lexer); - - unsigned opening_hash_count = 0; - while (lexer->lookahead == '#') { - advance(lexer); - opening_hash_count++; - } - - if (lexer->lookahead != '"') - return false; - advance(lexer); - - for (;;) { - if (lexer->lookahead == 0) { - return false; - } else if (lexer->lookahead == '"') { - advance(lexer); - unsigned hash_count = 0; - while (lexer->lookahead == '#' && hash_count < opening_hash_count) { - advance(lexer); - hash_count++; - } - if (hash_count == opening_hash_count) { - return true; - } - } else { - advance(lexer); - } - } - } - - if (valid_symbols[FLOAT] && iswdigit(lexer->lookahead)) { - lexer->result_symbol = FLOAT; - - advance(lexer); - while (is_num_char(lexer->lookahead)) { - advance(lexer); - } - - bool has_fraction = false, has_exponent = false; - - if (lexer->lookahead == '.') { - has_fraction = true; - advance(lexer); - if (iswalpha(lexer->lookahead)) { - // The dot is followed by a letter: 1.max(2) => not a float but an - // integer - return false; - } - - if (lexer->lookahead == '.') { - return false; - } - while (is_num_char(lexer->lookahead)) { - advance(lexer); - } - } - - lexer->mark_end(lexer); - - if (lexer->lookahead == 'e' || lexer->lookahead == 'E') { - has_exponent = true; - advance(lexer); - if (lexer->lookahead == '+' || lexer->lookahead == '-') { - advance(lexer); - } - if (!is_num_char(lexer->lookahead)) { - return true; - } - advance(lexer); - while (is_num_char(lexer->lookahead)) { - advance(lexer); - } - - lexer->mark_end(lexer); - } - - if (!has_exponent && !has_fraction) - return false; - - if (lexer->lookahead != 'u' && lexer->lookahead != 'i' && - lexer->lookahead != 'f') { - return true; - } - advance(lexer); - if (!iswdigit(lexer->lookahead)) { - return true; - } - - while (iswdigit(lexer->lookahead)) { - advance(lexer); - } - - lexer->mark_end(lexer); - return true; - } - - if (lexer->lookahead == '/') { - advance(lexer); - if (lexer->lookahead != '*') - return false; - advance(lexer); - - bool after_star = false; - unsigned nesting_depth = 1; - for (;;) { - switch (lexer->lookahead) { - case '\0': - return false; - case '*': - advance(lexer); - after_star = true; - break; - case '/': - if (after_star) { - advance(lexer); - after_star = false; - nesting_depth--; - if (nesting_depth == 0) { - lexer->result_symbol = BLOCK_COMMENT; - return true; - } - } else { - advance(lexer); - after_star = false; - if (lexer->lookahead == '*') { - nesting_depth++; - advance(lexer); - } - } - break; - default: - advance(lexer); - after_star = false; - break; - } - } - } - - return false; -} diff --git a/ratisui-tree-sitter-ron/src/tree_sitter/parser.h b/ratisui-tree-sitter-ron/src/tree_sitter/parser.h deleted file mode 100644 index 2b14ac1..0000000 --- a/ratisui-tree-sitter-ron/src/tree_sitter/parser.h +++ /dev/null @@ -1,224 +0,0 @@ -#ifndef TREE_SITTER_PARSER_H_ -#define TREE_SITTER_PARSER_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include - -#define ts_builtin_sym_error ((TSSymbol)-1) -#define ts_builtin_sym_end 0 -#define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024 - -typedef uint16_t TSStateId; - -#ifndef TREE_SITTER_API_H_ -typedef uint16_t TSSymbol; -typedef uint16_t TSFieldId; -typedef struct TSLanguage TSLanguage; -#endif - -typedef struct { - TSFieldId field_id; - uint8_t child_index; - bool inherited; -} TSFieldMapEntry; - -typedef struct { - uint16_t index; - uint16_t length; -} TSFieldMapSlice; - -typedef struct { - bool visible; - bool named; - bool supertype; -} TSSymbolMetadata; - -typedef struct TSLexer TSLexer; - -struct TSLexer { - int32_t lookahead; - TSSymbol result_symbol; - void (*advance)(TSLexer *, bool); - void (*mark_end)(TSLexer *); - uint32_t (*get_column)(TSLexer *); - bool (*is_at_included_range_start)(const TSLexer *); - bool (*eof)(const TSLexer *); -}; - -typedef enum { - TSParseActionTypeShift, - TSParseActionTypeReduce, - TSParseActionTypeAccept, - TSParseActionTypeRecover, -} TSParseActionType; - -typedef union { - struct { - uint8_t type; - TSStateId state; - bool extra; - bool repetition; - } shift; - struct { - uint8_t type; - uint8_t child_count; - TSSymbol symbol; - int16_t dynamic_precedence; - uint16_t production_id; - } reduce; - uint8_t type; -} TSParseAction; - -typedef struct { - uint16_t lex_state; - uint16_t external_lex_state; -} TSLexMode; - -typedef union { - TSParseAction action; - struct { - uint8_t count; - bool reusable; - } entry; -} TSParseActionEntry; - -struct TSLanguage { - uint32_t version; - uint32_t symbol_count; - uint32_t alias_count; - uint32_t token_count; - uint32_t external_token_count; - uint32_t state_count; - uint32_t large_state_count; - uint32_t production_id_count; - uint32_t field_count; - uint16_t max_alias_sequence_length; - const uint16_t *parse_table; - const uint16_t *small_parse_table; - const uint32_t *small_parse_table_map; - const TSParseActionEntry *parse_actions; - const char * const *symbol_names; - const char * const *field_names; - const TSFieldMapSlice *field_map_slices; - const TSFieldMapEntry *field_map_entries; - const TSSymbolMetadata *symbol_metadata; - const TSSymbol *public_symbol_map; - const uint16_t *alias_map; - const TSSymbol *alias_sequences; - const TSLexMode *lex_modes; - bool (*lex_fn)(TSLexer *, TSStateId); - bool (*keyword_lex_fn)(TSLexer *, TSStateId); - TSSymbol keyword_capture_token; - struct { - const bool *states; - const TSSymbol *symbol_map; - void *(*create)(void); - void (*destroy)(void *); - bool (*scan)(void *, TSLexer *, const bool *symbol_whitelist); - unsigned (*serialize)(void *, char *); - void (*deserialize)(void *, const char *, unsigned); - } external_scanner; - const TSStateId *primary_state_ids; -}; - -/* - * Lexer Macros - */ - -#define START_LEXER() \ - bool result = false; \ - bool skip = false; \ - bool eof = false; \ - int32_t lookahead; \ - goto start; \ - next_state: \ - lexer->advance(lexer, skip); \ - start: \ - skip = false; \ - lookahead = lexer->lookahead; - -#define ADVANCE(state_value) \ - { \ - state = state_value; \ - goto next_state; \ - } - -#define SKIP(state_value) \ - { \ - skip = true; \ - state = state_value; \ - goto next_state; \ - } - -#define ACCEPT_TOKEN(symbol_value) \ - result = true; \ - lexer->result_symbol = symbol_value; \ - lexer->mark_end(lexer); - -#define END_STATE() return result; - -/* - * Parse Table Macros - */ - -#define SMALL_STATE(id) id - LARGE_STATE_COUNT - -#define STATE(id) id - -#define ACTIONS(id) id - -#define SHIFT(state_value) \ - {{ \ - .shift = { \ - .type = TSParseActionTypeShift, \ - .state = state_value \ - } \ - }} - -#define SHIFT_REPEAT(state_value) \ - {{ \ - .shift = { \ - .type = TSParseActionTypeShift, \ - .state = state_value, \ - .repetition = true \ - } \ - }} - -#define SHIFT_EXTRA() \ - {{ \ - .shift = { \ - .type = TSParseActionTypeShift, \ - .extra = true \ - } \ - }} - -#define REDUCE(symbol_val, child_count_val, ...) \ - {{ \ - .reduce = { \ - .type = TSParseActionTypeReduce, \ - .symbol = symbol_val, \ - .child_count = child_count_val, \ - __VA_ARGS__ \ - }, \ - }} - -#define RECOVER() \ - {{ \ - .type = TSParseActionTypeRecover \ - }} - -#define ACCEPT_INPUT() \ - {{ \ - .type = TSParseActionTypeAccept \ - }} - -#ifdef __cplusplus -} -#endif - -#endif // TREE_SITTER_PARSER_H_ diff --git a/src/app.rs b/src/app.rs index 75647a7..7b9d598 100644 --- a/src/app.rs +++ b/src/app.rs @@ -7,7 +7,7 @@ use ratatui::style::palette::tailwind; use ratatui::text::Line; use ratatui::Frame; use crate::bus::GlobalEvent; -use crate::configuration::Databases; +use crate::configuration::{Configuration, Databases}; pub struct App { pub state: AppState, @@ -26,6 +26,7 @@ pub enum AppState { #[derive(Clone, Debug, PartialEq, Eq)] pub enum AppEvent { Init, + InitConfig(Configuration), Reset, Destroy, Bus(GlobalEvent), diff --git a/src/components/highlight_value.rs b/src/components/highlight_value.rs index 1cfda34..e737f5d 100644 --- a/src/components/highlight_value.rs +++ b/src/components/highlight_value.rs @@ -143,7 +143,9 @@ impl HighlightProcessor { fn process_json(&mut self) -> Result { if self.do_formatting { if let Ok(v) = serde_json::from_str::(self.source.as_ref()) { - self.source = serde_json::to_string_pretty(&v)?; + if let Ok(v) = serde_json::to_string_pretty(&v) { + self.source = v; + } } } diff --git a/src/components/raw_paragraph.rs b/src/components/raw_paragraph.rs index 9994376..f09be9d 100644 --- a/src/components/raw_paragraph.rs +++ b/src/components/raw_paragraph.rs @@ -19,8 +19,8 @@ pub struct RawParagraph<'a> { } impl<'a> RawParagraph<'a> { - pub fn new(raw: String, content_type: Option) -> Self { - let text = raw_value_to_highlight_text_with_content_type(Cow::from(raw.clone()), content_type.clone(), false); + pub fn new(raw: String, content_type: Option, format: bool) -> Self { + let text = raw_value_to_highlight_text_with_content_type(Cow::from(raw.clone()), content_type.clone(), format); let paragraph = Paragraph::new(text).wrap(Wrap { trim: false }); Self { raw, diff --git a/src/configuration.rs b/src/configuration.rs index 323e872..735fae7 100644 --- a/src/configuration.rs +++ b/src/configuration.rs @@ -80,10 +80,11 @@ fn get_file_path(file_name: &str) -> Result { Ok(dir_path) } -#[derive(Serialize, Deserialize, Debug)] +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] pub struct Configuration { pub fps: Option, pub scan_size: Option, + pub try_format: Option, } #[derive(Serialize, Deserialize)] @@ -97,6 +98,7 @@ impl Configuration { Self { fps: Some(30), scan_size: Some(2_000), + try_format: Some(false), } } } diff --git a/src/main.rs b/src/main.rs index daf4c20..3760f12 100644 --- a/src/main.rs +++ b/src/main.rs @@ -85,7 +85,7 @@ async fn main() -> Result<()> { } async fn run(mut app: App, mut terminal: TerminalBackEnd, config: Configuration) -> Result<()> { - let fps = cmp::min(config.fps.unwrap_or(30) as usize, 60); + let fps = cmp::min(config.fps.clone().unwrap_or(30) as usize, 60); let delay_millis = 1000 / fps; let delay_duration = Duration::from_millis(delay_millis as u64); let mut fps_calculator = FpsCalculator::default(); @@ -121,6 +121,7 @@ async fn run(mut app: App, mut terminal: TerminalBackEnd, config: Configuration) if app.state == AppState::Preparing { app.context.on_app_event(AppEvent::Init)?; + app.context.on_app_event(AppEvent::InitConfig(config.clone()))?; app.state = AppState::Running; continue; } diff --git a/src/tabs/explorer.rs b/src/tabs/explorer.rs index a556369..354eeee 100644 --- a/src/tabs/explorer.rs +++ b/src/tabs/explorer.rs @@ -38,6 +38,7 @@ pub struct ExplorerTab { show_delete_popup: bool, filter_mod: FilterMod, scan_size: u16, + try_format: bool, filter_text_area: TextArea<'static>, create_key_form: Form, rename_key_text_area: TextArea<'static>, @@ -207,6 +208,7 @@ impl ExplorerTab { show_delete_popup: false, filter_mod: FilterMod::Fuzzy, scan_size: 2_000, + try_format: false, filter_text_area, create_key_form: Form::default().title("Create Key"), rename_key_text_area, @@ -247,7 +249,7 @@ impl ExplorerTab { } if data.selected_string_value.0 { let raw = data.selected_string_value.1.unwrap_or_default(); - self.selected_raw_value = Some(RawParagraph::new(raw.0, raw.1)); + self.selected_raw_value = Some(RawParagraph::new(raw.0, raw.1, self.try_format)); } if data.selected_list_value.0 { self.selected_list_value = Some(ListValue::new(data.selected_list_value.1.unwrap_or_default())); @@ -1214,23 +1216,34 @@ impl Listenable for ExplorerTab { } fn on_app_event(&mut self, _app_event: AppEvent) -> Result<()> { - if _app_event == AppEvent::Reset { - self.show_delete_popup = false; - self.show_filter = false; - self.filter_text_area = TextArea::default(); - if let Some(first_line) = self.get_filter_text() { - self.do_scan(first_line)?; + match _app_event { + AppEvent::InitConfig(configuration) => { + if let Some(scan_size) = configuration.scan_size { + self.scan_size = scan_size; + } + if let Some(try_format) = configuration.try_format { + self.try_format = try_format; + } } - } - if let AppEvent::Bus(global_event) = _app_event { - match global_event { - GlobalEvent::ClientChanged => { - if let Some(first_line) = self.get_filter_text() { - self.do_scan(first_line)?; + AppEvent::Reset => { + self.show_delete_popup = false; + self.show_filter = false; + self.filter_text_area = TextArea::default(); + if let Some(first_line) = self.get_filter_text() { + self.do_scan(first_line)?; + } + } + AppEvent::Bus(global_event) => { + match global_event { + GlobalEvent::ClientChanged => { + if let Some(first_line) = self.get_filter_text() { + self.do_scan(first_line)?; + } } + _ => {} } - _ => {} } + _ => {} } Ok(()) }