ecal | simple embeddable scripting language | Pub Sub library

 by   krotik Go Version: v1.6.1 License: MIT

kandi X-RAY | ecal Summary

kandi X-RAY | ecal Summary

ecal is a Go library typically used in Messaging, Pub Sub applications. ecal has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can download it from GitHub.

The primary purpose of ECAL is to be a simple multi-purpose language which can be embedded into other software: - It has a minimal (quite generic) syntax. - By default the language can only reach outside the interpreter via return values, injecting events or logging. - External systems can interact with the code via events which maybe be handled in sink systems with varying complexity. - A standard library of function can easily be created by either generating proxy code to standard Go functions or by adding simple straight-forward function objects. The core of the ECAL interpreter is the runtime provider object which is constructed with a given logger and import locator. The import locator is used by the import statement to load other ECAL code at runtime. The logger is used to process log statements from the interpreter. The ECALRuntimeProvider provides additionally to the logger and import locator also the following: A cron object to schedule recurring events. An ECA processor which triggers sinks and can be used to inject events into the interpreter. A debugger object which can be used to debug ECAL code supporting thread suspension, thread inspection, value injection and extraction and stepping through statements. The actual ECAL code has to be first parsed into an Abstract Syntax Tree. The tree is annotated during its construction with runtime components created by the runtime provider. The code is executed by calling the Validate() and Eval() function. Eval is given a variable scope which stores the values of variables, an instance state for internal use and a thread ID identifying the executing thread. If events are to be used then the processor of the runtime provider needs to be started first. The processor must be started after all sinks have been declared and before events are thrown. Events can then be injected into the interpreter. All errors are collected in the returned monitor.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              ecal has a low active ecosystem.
              It has 10 star(s) with 0 fork(s). There are 1 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 0 open issues and 1 have been closed. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of ecal is v1.6.1

            kandi-Quality Quality

              ecal has no bugs reported.

            kandi-Security Security

              ecal has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.

            kandi-License License

              ecal is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              ecal releases are available to install and integrate.
              Installation instructions, examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi has reviewed ecal and discovered the below as its top functions. This is intended to give you an instant insight into ecal implemented functionality, and help decide if they suit your requirements.
            • main is the main package .
            • ASTFromJSONObject creates an ASTNode from a JSON object
            • node identifier
            • Run unpacked binary
            • postPostProcessing preprocesses the AST node
            • lexToken scans a single token
            • PrettyPrint returns a string representation of an ASTNode .
            • lexValue lexes a value
            • ppSpecialStatements recursively prints special statements
            • pContainerBlocks parses container blocks .
            Get all kandi verified functions for this library.

            ecal Key Features

            No Key Features are available at this moment for ecal.

            ecal Examples and Code Snippets

            No Code Snippets are available at this moment for ecal.

            Community Discussions

            QUESTION

            Lexical or Dynamic scope - Haskell implemented evaluator
            Asked 2021-May-22 at 07:32

            My professor has given us a question after talking about the difference between lexical and dynamic scope. He presented us a simple evaluator (of a fictional language) coded in Haskell. The following is the code:

            ...

            ANSWER

            Answered 2021-May-22 at 07:32

            Your code is incomplete:

            Source https://stackoverflow.com/questions/67644733

            QUESTION

            How to output an integer to screen risc-v assembly
            Asked 2021-Apr-22 at 12:27

            The following is the assembly I have used in an attempt to print to console:

            ...

            ANSWER

            Answered 2021-Apr-04 at 18:56

            System calls depend on the environment. "Toy" systems like Venus or RARS have their own set of toy system calls that do things like print an integer.

            In a real-world system like GNU/Linux, true system calls that you can access with ecall can only copy bytes to a file descriptor. If you want to output text, you need to create text in memory in user-space and pass a pointer to a write system call.

            Spike + pk is apparently more like Linux, with a POSIX write(2) system call, not like those toy system-call environments where you could pass an integer directly to a print-int ecall. https://www.reddit.com/r/RISCV/comments/dagvzr/where_do_i_find_the_list_of_stdio_system_etc/ has some examples and links. Notably https://github.com/riscv/riscv-pk/blob/master/pk/syscall.h where we find #define SYS_write 64 as the call number (goes in a7) for a write system call.

            A write system-call takes args: write(int fd, const void *buf, size_t count).

            Formatting a binary integer into an ASCII string is something that library functions like printf will do. Toy systems don't have a library, so they just put a few useful functions as system calls. And if you want control over stuff like leading zeros or padding to a fixed width, you have to write it yourself. But on a system like Spike-pk, you only have simple Unix-like system calls and (perhaps?) no library at all, so you have to always do it yourself.

            With just Linux / Unix / Spike-pk system-calls, you'll want to do repeated division by 10 to get the decimal digits of a binary integer. like in How do I print an integer in Assembly Level Programming without printf from the c library? which shows C and x86-64 assembly for Linux:

            Source https://stackoverflow.com/questions/66941555

            QUESTION

            How do I get rid of '\n' in RISC-V?
            Asked 2021-Mar-31 at 17:55

            I've been given a task to create a program that would read the name of a file and then copy its insides to other file, name of which is also read from the input. I wrote the program itself, but it appeared to do nothing.

            Experimenting further, I've discovered that, whilst reading first string, the program also saves a '\n' character in it, which, obviously, resulted in some issues with searching the target file. I figured out one solution, that I'm not completely fond of, that's why I am here to ask for opinions on the code and overall further improvements, maybe?

            I've pinned only the part that is responsible for writing file name to buffer until '\n' appears.

            ...

            ANSWER

            Answered 2021-Mar-31 at 16:14

            This is pretty good in that it works!  Comments:

            • As it deals with the string in word sizes — chunks of 4 characters at a time — it is arguably more complicated than the other approach of doing it 1 byte at a time.

            • Working with 4 bytes at a time, it ignores whether the string in question starts on a word aligned boundary — while that it does in this program's case, there is no such guarantee for arbitrary strings in general.  Unaligned word-sized loads & stores are subject to certain hazards, and somewhat depends on the underlying processor, ranging from performance issues to access faults.  Fixing the algorithm to accommodating arbitrary alignment, while still working 4 bytes at a time, will add considerable complexity.

            • Working with 4 bytes at a time, it potentially reads past the end of the string, into another data structure.  While this is unlikely to cause any problems when a word aligned string is given, it is generally frowned upon reading past the end of a data structure, and if the processor supports unaligned loads, this have the undesired effect of reading into the next cache line or page not part of the string itself.

            Source https://stackoverflow.com/questions/66886934

            QUESTION

            Fibonacci Function in RISC V
            Asked 2021-Jan-20 at 01:05

            Implementing the fibonacci function using RISC - V, so that f(0) = 0 , f(1) = 1, ..., up to f(47). My output matches everything up to 46. But when i try to calculate f(47) i get: -1323752223.
            Here's the output:Output from Code below with n=47

            Is there some sort of Overflow because i get a negative Integer value? Where should i look into to try and fix the error?

            ...

            ANSWER

            Answered 2021-Jan-17 at 01:13

            Yes, you have found the boundary of what signed 32-bit integers can hold.

            • fib(47) = 2971215073 won't fit in 32-bit integers as signed, but will fit as unsigned — however, RARS does not have an "unsigned int" print function.

            • fib(48) = 4807526976 won't fit in 32-bit form, even as unsigned.

            List of fibonacci numbers: https://www.math.net/list-of-fibonacci-numbers

            If you want to represent larger numbers, you will need a strategy.

            • if precision is not important, you can switch to floating point, where the results with such large numbers will be inexact.

            • use two integers together for 64-bit arithmetic — you'll be good up to fib(92) = 7540113804746346429.

            • use variable length integers for precision limited only by computer memory and compute time

            • a complex combination of the above

            And finally, you can detect and issue an error on overflow of your chosen arithmetic data type.  Overflow detection on RISC V is somewhat simple but not really obvious.

            Technically, addition of 2 arbitrary 32-bit numbers results in a 33 bit answer — but no more than 33 bits, so we can use that knowledge of math in detecting overflow.

            First, in a 32-bit number the top bit is either the sign bit (when signed data type), or the magnitude bit (when unsigned data type).

            If you add two positive numbers (as is the case with fib) and the sign bit is set, you have signed overflow — but a proper bit pattern, if interpreted as unsigned.  However, you won't be able to print the number properly using the ecall #1, because it will print the number as signed and interpret as negative.  You can write your own unsigned number print; you can also look for this case and simply stop the program from printing and issue an error instead.

            Going beyond that you can check for overflow in 32-bit unsigned addition by seeing if the resulting value is less than one of the input operands.

            The last approach is also used in multiword addition to make a carry from the lower word(s) to higher word(s).

            Source https://stackoverflow.com/questions/65753763

            QUESTION

            Register Uses in RISC-V
            Asked 2020-Nov-25 at 03:01

            Am I loading the wrong register here!!!

            RISC-V Error Message is:

            ...

            ANSWER

            Answered 2020-Nov-25 at 03:01

            addi is used for adding a register and an immediate (thus the "i" at the end), a constant value; such as addi t2, t0, 5 (t2 = t0 + 5). Use add instead; add t2, t0, t1

            Source https://stackoverflow.com/questions/64997806

            QUESTION

            How to print the total of positive and negative numbers in RISC-V Assembly
            Asked 2020-Nov-09 at 18:19

            The program stores an array of 25 integers (words). Then calculate the sum of the positive numbers and the sum of the negative numbers, then print the total of both positive and negative numbers.

            Error Messages:

            ...

            ANSWER

            Answered 2020-Nov-09 at 18:19

            You are using v0 registers which are only available with vector extension. If you toolchain.

            The compiler and the "standard" binutils of the gnu toolchain don't seem supporting it yet. There is a dedicated binutils branch https://github.com/riscv/riscv-binutils-gdb/tree/rvv-1.0.x.

            LLVM also is not supporting it also. How do I use the RISC-V Vector (RVV) instructions in LLVM IR?

            Source https://stackoverflow.com/questions/64275663

            QUESTION

            How to print the total in RISC-V Assembly language?
            Asked 2020-Nov-08 at 16:31

            This code is supposed to store the numbers in an array, and then print the total of positive numbers, and total of negative numbers. I am not sure what I am doing wrong! It prints out the messages without the total. I am using RISC-V assembly language in RARS simulator

            This is my current outcome:

            ...

            ANSWER

            Answered 2020-Nov-08 at 16:31

            You are printing only posTotal and negTotal. You need to print also positiveSum and negativeSum after converting them to ascii format.

            I don't known how your ecall works , but you need to add two calls to ecall when you put the ascii from of your Sums in a0 (this solution will always work), or if the ecall can take more than one argument place the Sum as the second argument by using a1.

            You got Negative Integers Total: printed twice because you did not add \0 at the end of your strings, so the first time you print the first string but continue printing until you found an \0.

            I recommend you add an alignment directive between your strings like .balign 4.

            Source https://stackoverflow.com/questions/64734986

            QUESTION

            Explain what this assembly language program does in plain English
            Asked 2020-Nov-07 at 14:56
                .data
            array:  .word   1 2 3 4 5
            mfact:  .word   100
            dfact:  .word   20
            
                .text
            main:   lui s0, 0x10010     # U format  4 cycles
                lw  t0, 20(s0)      # I format  5 cycles
                lw  t1, 24(s0)      # I format  5 cycles
                or  s1, zero, zero  # R format  4 cycles
                ori s2, zero, 5     # I format  4 cycles
            
            loop:   slli    s3, s1, 2       # I format  4 cycles
                add s4, s3, s0      # R format  4 cycles
                lw  t2, 0(s4)       # I format  5 cycles
                mul t3, t2, t0      # R format  10 cycles
                div t4, t3, t1      # R format  40 cycles
                sw  t4, 0(s4)       # S format  4 cycles
                addi    s1, s1, 1       # I format  4 cycles
                blt s1, s2, loop    # B format  3 cycles
            
            exit:   ori a7, zero, 10    # I format  4 cycles
                ecall           # I format  3 cycles
                
            
            ...

            ANSWER

            Answered 2020-Nov-07 at 14:56

            This program is supposed to take each element of an array of 5 word and multiply it with the first word after the array, then divide the result with the second element after the array. However there is some problems:
            1- you need to add com between the words of the array.
            2- you need to declare main as a global function, so that the linker can find it. Otherwise you will have an undefined reference error.
            3- the lui s0, 0x10010 could be problematic. Are you sure the linker will put array at this address? Did you modified the linker script to force it? IF you are not sure of what the linker will do . It will be better to declare array as an object and use it directly with and lui + addi.

            The code will be:

            Source https://stackoverflow.com/questions/64625825

            QUESTION

            RISC-V Assembly Language Program to Convert Fahrenheit to Celsius
            Asked 2020-Nov-04 at 18:07

            An assembly language program to convert a temperature value given in Fahrenheit to Celsius. The formula to be implemented is 𝐶 = (𝐹 − 32) × 5⁄9. Data Segments Required:

            1. F_temp (word)
            2. C_temp (word)
            3. The value 32 (byte)
            4. The value 5 (byte)
            5. The value 9 (byte)
            6. Prompt for input (string)
            7. Message for output (string)

            The stack is to be used for passing the Fahrenheit value to the subroutine and for returning the calculated Celsius value back to the main program. Dynamic stack allocation is to be implemented for this. Both the Fahrenheit and the calculated Celsius values are to be stored in the allocated memory locations defined in the data segment.

            What I have so far is this code. When I run the program it says

            ...

            ANSWER

            Answered 2020-Nov-01 at 03:33

            x0 is hard-wired to 0. It never makes sense to li into it. https://en.wikichip.org/wiki/risc-v/registers.

            Whatever register the ecall handler looks in for a system-call number, it's not x0. Check the documentation for whatever you're using. (e.g. RARS system-calls use a7, the same way that MARS used the MIPS register $v0 (not MIPS $0, the zero register))

            Also generally a bad idea to mix x1 and t0 / s0 register names. Easy to accidentally use 2 different names for the same register and have your code overwrite its own data.

            In a previous version of the question you had:

            Note: RISC-V multiply and divide instructions do not support immediates (constants). Therefore, all numeric values are to be defined in and loaded from memory

            That's weird, the "therefore" doesn't really follow.

            li reg, constant is still cheaper than lw, especially for a small integer. But if your assignment said you had to do it the stupid way, with data memory instead of foo = 5 or .equ assemble-time symbolic constants, then you have to. You can define your constants in one place, but then still use them as immediates, if your assembler doesn't suck.

            Source https://stackoverflow.com/questions/64627951

            QUESTION

            Calculate nth Fibonacci number using RISC-V (RV32I) compiler without recursion
            Asked 2020-Sep-09 at 05:17

            I have written a code for calculating nth fibonacci number in RISC-V assembly language. It has two parts- fib.s and runtest.s, which loads the value of n into a0 and calls fib, which calculates the nth fibonacci number (without recursion), loads the result into a0 itself and returns. Here is my code:

            ...

            ANSWER

            Answered 2020-Sep-09 at 05:17

            I was able to get all of your testbench cases to pass in a RISC-V simulator with 3 changes:

            (1) Your second test case has the wrong expected result. I'm assuming you're using 0-indexed Fibonacci numbers, since that's what most of your test cases do (e.g. test case 1 says Fibonacci number 1 is 1, test case 3 says Fibonacci number 7 is 13). In that case, Fibonacci number 3 should be 2, not 3.

            (2) To get the correct number of iterations, in your loop, your "i" variable / register a4 should begin set to 1, not 2.

            (3) You generally don't use ECALL to return from a function in RISC-V. As per the RISC-V spec, "the ECALL instruction is used to make a service request to the execution environment." It causes a precise trap and is used (for example) when implementing syscalls. Instead, there is the pseudoinstruction ret to return from a function call (similar notation to x86). ret is equivalent to jalr x0 0(ra). (That being said, maybe you've defined ecall behavior such that when a7 is 93, the equivalent of a ret is executed.)

            Source https://stackoverflow.com/questions/63780807

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install ecal

            You can either download a pre-compiled package for Windows (win64) or Linux (amd64) [here](https://void.devt.de/pub/ecal) or clone the repository and build the ECAL executable with a simple make command. You need Go 1.14 or higher.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/krotik/ecal.git

          • CLI

            gh repo clone krotik/ecal

          • sshUrl

            git@github.com:krotik/ecal.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular Pub Sub Libraries

            EventBus

            by greenrobot

            kafka

            by apache

            celery

            by celery

            rocketmq

            by apache

            pulsar

            by apache

            Try Top Libraries by krotik

            eliasdb

            by krotikGo

            dudeldu

            by krotikGo

            gladiator_3d

            by krotikJavaScript

            rufs

            by krotikGo

            gv1z

            by krotikJavaScript