Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove '-' as a valid char in identifiers #1571

Merged
merged 3 commits into from
Apr 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## Unreleased

## Breaking Changes

- the `-` is no longer a valid part of identifiers.
- binaries now use `_` to sepoerate type names as `-` is no longer a identifier.

## [0.12.0-rc.1]

### New featues
Expand Down
2 changes: 1 addition & 1 deletion tests/scripts/bytes_create/script.tremor
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
use std::string;
string::from_utf8_lossy(<< << event/binary, 32 >>/binary, 0x22/signed-integer, "snot"/binary, 0x2122:16/big-integer >>)
string::from_utf8_lossy(<< << event/binary, 32 >>/binary, 0x22/signed_integer, "snot"/binary, 0x2122:16/big_integer >>)
4 changes: 2 additions & 2 deletions tremor-script/lib/std/type.tremor
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
## > "string" == type::as_string("snot");
## > "array" == type::as_string([null,true,"snot"]);
## > "record" == type::as_string({"snot": [1, 1.e23, "badger"]});
## > "bytes" == type::as_string(<< 1/unsigned-integer >>);
## > "bytes" == type::as_string(<< 1/unsigned_integer >>);
## > ```
##
## Returns a `string`
Expand Down Expand Up @@ -110,7 +110,7 @@ intrinsic fn is_record(value) as type::is_record;
##
## > ```tremor
## > use std::type;
## > true == type::is_binary(<< 1/unsigned-integer >>);;
## > true == type::is_binary(<< 1/unsigned_integer >>);;
## > false == type::is_binary(true);
## > ```
##
Expand Down
8 changes: 4 additions & 4 deletions tremor-script/src/ast/eq/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ fn test_list_eq() -> Result<()> {
test_ast_eq(
r#"
let x = event.len;
[1, -x, <<x:7/unsigned-integer>>, "foo"];
[1, -x, <<x:7/unsigned-integer>>, "foo"]
[1, -x, <<x:7/unsigned_integer>>, "foo"];
[1, -x, <<x:7/unsigned_integer>>, "foo"]
"#,
true,
)
Expand All @@ -126,8 +126,8 @@ fn test_list_not_eq() -> Result<()> {
test_ast_eq(
r#"
let x = event.len;
[1, -x, <<x:7/unsigned-integer>>, "foo"];
[1, -x, <<x:7/signed-integer>>, "foo"]
[1, -x, <<x:7/unsigned_integer>>, "foo"];
[1, -x, <<x:7/signed_integer>>, "foo"]
"#,
false,
)
Expand Down
2 changes: 1 addition & 1 deletion tremor-script/src/ast/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ impl<'script> Upable<'script> for BytesPartRaw<'script> {
// We allow this for casting the bits
#[allow(clippy::cast_sign_loss)]
fn up<'registry>(self, helper: &mut Helper<'script, 'registry>) -> Result<Self::Target> {
let data_type: Vec<&str> = self.data_type.id.split('-').collect();
let data_type: Vec<&str> = self.data_type.id.split('_').collect();
let (data_type, endianess) = match data_type.as_slice() {
["binary"] => (BytesDataType::Binary, Endian::Big),
[]
Expand Down
4 changes: 2 additions & 2 deletions tremor-script/src/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ fn is_ws(ch: char) -> bool {
}

fn is_ident_start(ch: char) -> bool {
UnicodeXID::is_xid_start(ch) || ch == '_' || ch == '-'
UnicodeXID::is_xid_start(ch) || ch == '_'
}

fn is_ident_continue(ch: char) -> bool {
let ch = ch as char;
UnicodeXID::is_xid_continue(ch) || ch == '_' || ch == '-'
UnicodeXID::is_xid_continue(ch) || ch == '_'
}

fn is_test_start(ch: char) -> bool {
Expand Down
4 changes: 2 additions & 2 deletions tremor-script/src/lexer/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ fn number_parsing() -> Result<()> {
#[test]
fn paths() -> Result<()> {
lex_ok! {
" hello-hahaha8ABC ",
" ~~~~~~~~~~~~~~~~ " => Token::Ident("hello-hahaha8ABC".into(), false),
" hello_hahaha8ABC ",
" ~~~~~~~~~~~~~~~~ " => Token::Ident("hello_hahaha8ABC".into(), false),
};
lex_ok! {
" .florp ",
Expand Down