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

fix(#3635): rust returns bytes + remove /? #3637

Merged
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: 6 additions & 1 deletion eo-parser/src/main/antlr4/org/eolang/parser/Eo.g4
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,12 @@ void
;

// Type of atom
type: SPACE SLASH (NAME | QUESTION)
type: SPACE SLASH typeFqn
;

// Type FQN
typeFqn
: NAME (DOT NAME)*
;

// Application
Expand Down
20 changes: 13 additions & 7 deletions eo-parser/src/main/java/org/eolang/parser/XeEoListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -292,13 +292,9 @@ public void exitJustNamed(final EoParser.JustNamedContext ctx) {
@Override
@SuppressWarnings("PMD.ConfusingTernary")
public void enterAtom(final EoParser.AtomContext ctx) {
this.startObject(ctx);
if (ctx.type().NAME() != null) {
this.objects.prop("atom", ctx.type().NAME().getText());
} else if (ctx.type().QUESTION() != null) {
this.objects.prop("atom", ctx.type().QUESTION().getText());
}
this.objects.leave();
this.startObject(ctx)
.prop("atom", ctx.type().typeFqn().getText())
.leave();
}

@Override
Expand Down Expand Up @@ -366,6 +362,16 @@ public void exitType(final EoParser.TypeContext ctx) {
// Nothing here
}

@Override
public void enterTypeFqn(final EoParser.TypeFqnContext ctx) {
// Nothing here
}

@Override
public void exitTypeFqn(final EoParser.TypeFqnContext ctx) {
// Nothing here
}

@Override
public void enterApplication(final EoParser.ApplicationContext ctx) {
// Nothing here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ asserts:
- //o[@base='.five']
- //objects[not(.//o[@name=''])]
- //o[@atom and @name='atom' and count(o)=2 and o[@name='a']]
- //o[@atom='org.eolang.number']
input: |
# The purpose of this test case is to make
# sure all possible syntax scenarios can
Expand Down Expand Up @@ -123,7 +124,7 @@ input: |

# No comments.
[] > ooo
[] > o-1 /?
[] > o-1 /org.eolang.number

[] > o2

Expand Down
2 changes: 1 addition & 1 deletion eo-runtime/src/main/eo/org/eolang/as-phi.eo
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@
# This object is mostly used for testing/debugging, when it's necessary
# to inspect the structure of an object. The output will omit recursive
# links.
[x] > as-phi /string
[x] > as-phi /org.eolang.string
18 changes: 9 additions & 9 deletions eo-runtime/src/main/eo/org/eolang/bytes.eo
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@
*

# Equals to another object.
[b] > eq /bool
[b] > eq /org.eolang.bool

# Total number of bytes.
[] > size /number
[] > size /org.eolang.number

# Represents a sub-sequence inside the current one.
[start len] > slice /bytes
[start len] > slice /org.eolang.bytes

# Turn this chain of eight bytes into a i64 number.
# If there are less or more than eight bytes, there will
Expand Down Expand Up @@ -104,24 +104,24 @@
* ^

# Calculate bitwise and.
[b] > and /bytes
[b] > and /org.eolang.bytes

# Calculate bitwise or.
[b] > or /bytes
[b] > or /org.eolang.bytes

# Calculate bitwise xor.
[b] > xor /bytes
[b] > xor /org.eolang.bytes

# Calculate bitwise not.
[] > not /bytes
[] > not /org.eolang.bytes

# Calculate bitwise left shift.
^.right x.neg > [x] > left

# Calculate bitwise right shift.
[x] > right /bytes
[x] > right /org.eolang.bytes

# Concatenation of two byte sequences:
# the current and the provided one,
# as a new sequence.
[b] > concat /bytes
[b] > concat /org.eolang.bytes
2 changes: 1 addition & 1 deletion eo-runtime/src/main/eo/org/eolang/error.eo
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@
# The first attempt to dataize it will lead to runtime error and program
# termination. The only way to catch such an error is by using
# the `try` object.
[message] > error /error
[message] > error /org.eolang.error
6 changes: 3 additions & 3 deletions eo-runtime/src/main/eo/org/eolang/fs/dir.eo
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@
#
# Attention! The object is for internal usage only, please
# don't use it programmatically outside of `dir` object.
[] > mkdir /true
[] > mkdir /org.eolang.true

# Goes though all files in the directory, recursively
# finding them with the `glob` provided.
# Returns `tuple` of all files in the directory.
[glob] > walk /tuple
[glob] > walk /org.eolang.tuple

# Deletes directory and all files in it, recursively.
# Returns the deleted directory.
Expand Down Expand Up @@ -101,7 +101,7 @@
#
# Attention! The object is for internal usage only, please
# don't use the object programmatically outside of the `dir` object.
[] > touch /string
[] > touch /org.eolang.string

# Opens the file for I/O operations.
# Since current file is a directory - returns an `error`.
Expand Down
18 changes: 9 additions & 9 deletions eo-runtime/src/main/eo/org/eolang/fs/file.eo
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
$.path > @

# Returns `true` if current file is a directory, returns `false` otherwise.
[] > is-directory /bool
[] > is-directory /org.eolang.bool

# Returns `true` if file with current `path` exists in filesystem.
[] > exists /bool
[] > exists /org.eolang.bool

# If current file exists - returns the file.
# If current file does not exist - create an empty file
Expand All @@ -54,7 +54,7 @@
#
# Attention! The object is for internal usage only, please
# don't use the object programmatically outside of `file` object.
[] > touch /true
[] > touch /org.eolang.true

# If current file exists - deletes it and returns it.
# If current file does not exist - just returns it.
Expand All @@ -71,10 +71,10 @@
#
# Attention! The object is for internal usage only, please
# don't use the object programmatically outside of `file` object.
[] > delete /true
[] > delete /org.eolang.true

# Get file size in bytes.
[] > size /number
[] > size /org.eolang.number

# Move current file to `target`, making and returning a new `file` from it.
[target] > moved
Expand All @@ -86,7 +86,7 @@
#
# Attention! The object is for internal usage only, please
# don't use the object programmatically outside of `file` object.
[] > move /string
[] > move /org.eolang.string

# Convert the `file` to `path`.
(QQ.fs.path ^.path).determined > [] > as-path
Expand Down Expand Up @@ -185,7 +185,7 @@
#
# Attention! The object is for internal usage only, please
# don't use the object programmatically outside of the `file` object.
[] > process-file /true
[] > process-file /org.eolang.true

# File stream.
# The objects provides an API for using file as input or output.
Expand Down Expand Up @@ -227,7 +227,7 @@
#
# Attention! The object is for internal usage only, please
# don't use the object programmatically outside of `file` object.
[size] > read-bytes /bytes
[size] > read-bytes /org.eolang.bytes

# Write given `buffer` to file output stream.
# Here `buffer` is either sequence of bytes or and object that can be
Expand Down Expand Up @@ -269,4 +269,4 @@
#
# Attention! The object is for internal usage only, please
# don't use the object programmatically outside of `file` object.
[buffer] > written-bytes /true
[buffer] > written-bytes /org.eolang.true
2 changes: 1 addition & 1 deletion eo-runtime/src/main/eo/org/eolang/i16.eo
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
# The object is an atom because it's not possible to check what
# bytes should be added from left so the number is valid.
# The different bytes should be added if number is positive and negative.
[] > as-i32 /i32
[] > as-i32 /org.eolang.i32

# Returns `true` if `$` < `x`.
# Here `x` must be an `i16` object.
Expand Down
2 changes: 1 addition & 1 deletion eo-runtime/src/main/eo/org/eolang/i32.eo
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
# The object is an atom because it's not possible to check what
# bytes should be added from left so the number is valid.
# The different bytes should be added if number is positive and negative.
[] > as-i64 /i64
[] > as-i64 /org.eolang.i64

# Convert this `i32` to `i16`.
# The `error` is returned if the `i32` number is more than
Expand Down
10 changes: 5 additions & 5 deletions eo-runtime/src/main/eo/org/eolang/i64.eo
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
* ^.as-number

# Convert this `i64` to `number` object.
[] > as-number /number
[] > as-number /org.eolang.number

# Returns `true` if `$` < `x`.
# Here `x` must be an `i64` object.
Expand All @@ -72,7 +72,7 @@

# Returns `true` if `$` > `x`.
# Here `x` must be an `i64` object.
[x] > gt /bool
[x] > gt /org.eolang.bool

# Returns `true` if `$` >= `x`.
# Here `x` must be an `i64` object.
Expand All @@ -84,11 +84,11 @@

# Multiplication of `$` and `x`.
# Here `x` must be an `i64` object.
[x] > times /i64
[x] > times /org.eolang.i64

# Sum of `$` and `x`.
# Here `x` must be an `i64` object.
[x] > plus /i64
[x] > plus /org.eolang.i64

# Subtraction between `$` and `x`.
# Here `x` must be an `i64` object.
Expand All @@ -100,4 +100,4 @@
# Quotient of the division of `$` by `x`.
# Here `x` must be an `i64` object.
# An `error` is returned if or `x` is equal to 0.
[x] > div /i64
[x] > div /org.eolang.i64
10 changes: 5 additions & 5 deletions eo-runtime/src/main/eo/org/eolang/malloc.eo
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
# Allocates block in memory of given `size`. After allocation the `size` zero bytes bytes are
# written into memory.
[size scope] > of
[] > @ /bytes
[] > @ /org.eolang.bytes

# Allocated block in memory that provides an API for writing and reading.
[id] > allocated
Expand All @@ -111,18 +111,18 @@
read 0 size > get

# Returns size of allocated block in memory.
[] > size /number
[] > size /org.eolang.number

# Resizes allocated block in memory and returns `true`.
# Here `new-size` must be positive `number`.
# The `error` returned if failed to resize block in memory.
[new-size] > resized /allocated
[new-size] > resized /org.eolang.malloc.of.allocated

# Read `length` bytes with `offset` from the allocated block in memory.
[offset length] > read /bytes
[offset length] > read /org.eolang.bytes

# Write `data` with `offset` to the allocated block in memory.
[offset data] > write /true
[offset data] > write /org.eolang.true

# Put `object` into the allocated block in memory. The `object` is supposed to be dataizable.
[object] > put
Expand Down
4 changes: 2 additions & 2 deletions eo-runtime/src/main/eo/org/eolang/math/angle.eo
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@

# Sine of current angle.
# Please note, that `sin` is calculated from the angle in radians.
[] > sin /number
[] > sin /org.eolang.number

# Cosine of current angle.
# Please note, that `cos` is calculated from the angle in radians.
[] > cos /number
[] > cos /org.eolang.number

# Tangent of current angle.
# Please note, that `tan` is calculated from the angle in radians.
Expand Down
10 changes: 5 additions & 5 deletions eo-runtime/src/main/eo/org/eolang/math/real.eo
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@
value.neg

# Make `^.num` power `x`.
[x] > pow /number
[x] > pow /org.eolang.number

# Returns the positive square root of a `num`.
[] > sqrt /number
[] > sqrt /org.eolang.number

# Returns the natural logarithm `e` of a `num`.
[] > ln /number
[] > ln /org.eolang.number

# Calculates arc cosine of a `num`.
[] > acos /number
[] > acos /org.eolang.number

# Calculates arc sine of a `num`.
[] > asin /number
[] > asin /org.eolang.number
12 changes: 6 additions & 6 deletions eo-runtime/src/main/eo/org/eolang/number.eo
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
as-bytes.eq nan.as-bytes > is-nan

# Convert this `number` to `i64` object.
[] > as-i64 /i64
[] > as-i64 /org.eolang.i64

# Returns true if `$` = `x` in terms of bytes.
# Here `x` can be a `number` or any other object which
Expand Down Expand Up @@ -85,7 +85,7 @@
# Returns `true` if `$` > `x`.
# Here `x` can be a `number` or any other object which
# can be converted to 8 `bytes` via `as-bytes` object.
[x] > gt /bool
[x] > gt /org.eolang.bool

# Returns `true` if `$` > `x`.
# Here `x` can be a `number` or any other object which
Expand All @@ -99,12 +99,12 @@
# Multiplication of `$` and `x`.
# Here `x` can be a `number` or any other object which
# can be converted to 8 `bytes` via `as-bytes` object.
[x] > times /number
[x] > times /org.eolang.number

# Sum of `$` and `x`.
# Here `x` can be a `number` or any other object which
# can be converted to 8 `bytes` via `as-bytes` object.
[x] > plus /number
[x] > plus /org.eolang.number

# Difference between `$` and `x`.
# Here `x` can be a `number` or any other object which
Expand All @@ -117,11 +117,11 @@
# Quotient of the division of `$` by `x`.
# Here `x` can be a `number` or any other object which
# can be converted to 8 `bytes` via `as-bytes` object.
[x] > div /number
[x] > div /org.eolang.number

# The object rounds down the original `number` to the nearest
# whole `number` that is less than or equal to the original one.
[] > floor /number
[] > floor /org.eolang.number

# Returns `true` if current number does not have a fractional component.
[] > is-integer
Expand Down
2 changes: 1 addition & 1 deletion eo-runtime/src/main/eo/org/eolang/rust.eo
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@
+version 0.0.0

# Rust insert.
[code portal params] > rust /?
[code portal params] > rust /org.eolang.bytes
2 changes: 1 addition & 1 deletion eo-runtime/src/main/eo/org/eolang/sys/os.eo
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@
((regex "/linux/i").matches name).as-bool > is-linux
((regex "/mac/i").matches name).as-bool > is-macos

[] > name /string
[] > name /org.eolang.string
Loading
Loading