Skip to content

Commit

Permalink
CI fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
skius committed Aug 8, 2023
1 parent c6c4844 commit 6f35ea5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
4 changes: 3 additions & 1 deletion experimental/transliterator_parser/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 5 additions & 9 deletions experimental/transliterator_parser/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ as described in the zero-copy format, and the maps here are just arrays)
*/

use crate::parse;
use crate::parse::{ElementKind as EK, ElementLocation as EL, HalfRule, QuantifierKind};
use parse::ParseError;
use crate::parse::{ElementLocation as EL, HalfRule, QuantifierKind};
use parse::Result;
use parse::PEK;
use std::collections::{HashMap, HashSet};
Expand Down Expand Up @@ -402,8 +401,7 @@ impl<'a, 'p, F: Fn(&str) -> bool> TargetValidator<'a, 'p, F> {
fn validate_section(&mut self, section: &[parse::Element], top_level: bool) -> Result<()> {
section
.iter()
.map(|element| self.validate_element(element, top_level))
.collect()
.try_for_each(|element| self.validate_element(element, top_level))
}

fn validate_element(&mut self, element: &parse::Element, top_level: bool) -> Result<()> {
Expand Down Expand Up @@ -509,14 +507,13 @@ impl<'a, 'p, F: Fn(&str) -> bool> SourceValidator<'a, 'p, F> {

// now neither start nor end anchors may appear anywhere in `order`

sections.iter().map(|s| self.validate_section(s)).collect()
sections.iter().try_for_each(|s| self.validate_section(s))
}

fn validate_section(&mut self, section: &[parse::Element]) -> Result<()> {
section
.iter()
.map(|element| self.validate_element(element))
.collect()
.try_for_each(|element| self.validate_element(element))
}

fn validate_element(&mut self, element: &parse::Element) -> Result<()> {
Expand Down Expand Up @@ -589,8 +586,7 @@ impl<'a, 'p, F: Fn(&str) -> bool> VariableDefinitionValidator<'a, 'p, F> {
fn validate_section(&mut self, section: &[parse::Element]) -> Result<()> {
section
.iter()
.map(|element| self.validate_element(element))
.collect()
.try_for_each(|element| self.validate_element(element))
}

fn validate_element(&mut self, element: &parse::Element) -> Result<()> {
Expand Down
11 changes: 8 additions & 3 deletions experimental/transliterator_parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
//!
//! This crate provides parsing functionality for [UTS #35 - Transliterators](https://unicode.org/reports/tr35/tr35-general.html#Transforms).
//!
//! See [`parse`](crate::parse) for more information.
//! See [`parse`](crate::parse()) for more information.
//!
//! [`ICU4X`]: ../icu/index.html

// https://github.com/unicode-org/icu4x/blob/main/docs/process/boilerplate.md#library-annotations
#![cfg_attr(
Expand All @@ -30,6 +32,8 @@ use icu_transliteration::provider::RuleBasedTransliterator;
mod compile;
mod parse;

pub use parse::ElementKind;
pub use parse::ElementLocation;
pub use parse::ParseError;
pub use parse::ParseErrorKind;

Expand All @@ -41,7 +45,7 @@ pub fn parse(source: &str) -> Result<RuleBasedTransliterator<'static>, parse::Pa
parse_unstable(source, &icu_properties::provider::Baked)
}

#[doc = icu_provider::gen_any_buffer_unstable_docs!(UNSTABLE, parse)]
#[doc = icu_provider::gen_any_buffer_unstable_docs!(UNSTABLE, parse())]
pub fn parse_unstable<P>(
source: &str,
provider: &P,
Expand Down Expand Up @@ -105,5 +109,6 @@ where
+ DataProvider<XidStartV1Marker>,
{
let parsed = parse::parse_unstable(source, provider)?;
compile::compile(parsed)
// TODO(#3736): pass direction from metadata
compile::compile(parsed, parse::Direction::Both)
}
12 changes: 11 additions & 1 deletion experimental/transliterator_parser/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,25 @@ use icu_unicodeset_parser::{VariableMap, VariableValue};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum ElementKind {
/// A literal string: `abc 'abc'`.
Literal,
/// A variable reference: `$var`.
VariableReference,
/// A backreference to a segment: `$1`.
BackReference,
/// A quantifier of any sort: `c*`, `c+`, `c?`.
Quantifier,
/// A segment: `(abc)`.
Segment,
/// A UnicodeSet: `[a-z]`.
UnicodeSet,
/// A function call: `&[a-z] Remove(...)`.
FunctionCall,
/// A cursor: `|`.
Cursor,
/// A start anchor: `^`.
AnchorStart,
/// An end anchor: `$`.
AnchorEnd,
}

Expand Down Expand Up @@ -73,7 +83,7 @@ pub enum ParseErrorKind {
// errors originating from compilation step
/// A global filter (forward or backward) in an unexpected position.
UnexpectedGlobalFilter,
/// An element of `[ElementKind]` appeared in the given [`ElementLocation`], but that is prohibited.
/// An element of [`ElementKind`] appeared in the given [`ElementLocation`], but that is prohibited.
UnexpectedElement(ElementKind, ElementLocation),
/// The start anchor `^` was not placed at the beginning of a source.
AnchorStartNotAtStart,
Expand Down

0 comments on commit 6f35ea5

Please sign in to comment.