Giter Club home page Giter Club logo

gurzgri / red Goto Github PK

View Code? Open in Web Editor NEW

This project forked from red/red

1.0 0.0 1.0 37.41 MB

Red is a next-generation programming language strongly inspired by Rebol, but with a broader field of usage thanks to its native-code compiler, from system programming to high-level scripting and cross-platform reactive GUI, while providing modern support for concurrency, all in a zero-install, zero-config, single 1MB file!

Home Page: http://red-lang.org

License: Boost Software License 1.0

Red 86.34% Rebol 13.31% Java 0.05% Shell 0.02% R 0.01% C 0.16% Dockerfile 0.01% Visual Basic 6.0 0.12%

red's Introduction

Join the chat at https://gitter.im/red/red Windows build 2 Linux build 2 ARMhf build 2 macOS build 2

Red Programming Language

Red is a programming language strongly inspired by Rebol, but with a broader field of usage thanks to its native-code compiler, from system programming to high-level scripting, while providing modern support for concurrency and multi-core CPUs.

Red tackles the software building complexity using a DSL-oriented approach (we call them dialects) . The following dialects are built-in:

  • Red/System: a C-level system programming language compiled to native code
  • Parse: a powerful PEG parser
  • VID: a simple GUI layout creation dialect
  • Draw: a vector 2D drawing dialect
  • Rich-text: a rich-text description dialect

Red has its own complete cross-platform toolchain, featuring an encapper, a native compiler, an interpreter, and a linker, not depending on any third-party library, except for a Rebol2 interpreter, required during the alpha stage. Once 1.0 is reached, Red will be self-hosted. Currently, Red is still at alpha stage and 32-bit only.

Red's main features are:

  • Human-friendly syntax
  • Homoiconic (Red is its own meta-language and own data-format)
  • Functional, imperative, reactive and symbolic programming
  • Prototype-based object support
  • Multi-typing
  • Powerful pattern-matching Macros system
  • Rich set of built-in datatypes (50+)
  • Both statically and JIT-compiled(*) to native code
  • Cross-compilation done right
  • Produces executables of less than 1MB, with no dependencies
  • Concurrency and parallelism strong support (actors, parallel collections)(*)
  • Low-level system programming abilities through the built-in Red/System DSL
  • Powerful PEG parser DSL built-in
  • Fast and compacting Garbage Collector
  • Instrumentation built-in for the interpreter, lexer and parser.
  • Cross-platform native GUI system, with a UI layout DSL and a drawing DSL
  • Bridging to the JVM
  • High-level scripting and REPL GUI and CLI consoles included
  • Visual Studio Code plugin, with many helpful features
  • Highly embeddable
  • Low memory footprint
  • Single-file (~1MB) contains whole toolchain, full standard library and REPL (**)
  • No install, no setup
  • Fun guaranteed!

(*) Not implemented yet. (**) Temporarily split in two binaries

More information at red-lang.org.

Running the Red REPL

Download a GUI or CLI console binary suitable for your operating system, rename it at your convenience, then run it from shell or by double-clicking on it (Windows). You should see the following output:

    ---== Red 0.6.5 ==--
    Type HELP for starting information.

    >>

A simple Hello World would look like:

    >> print "Hello World!"
    Hello World!

If you are on the GUI console, a GUI Hello World (prompt omitted):

    view [text "Hello World!"]

A more sophisticated example that retrieves the last commits from this repo and displays their log messages in a scrollable list:

    view [
        text-list data collect [
            foreach event load https://api.github.com/repos/red/red/commits [
                keep event/commit/message
            ]
        ]
    ]

Note: check also the following improved version allowing you to click on a given commit log and open the commit page on github.

You can now head to see and try some showcasing scripts here and there. You can run those examples from the console directly using Github's "raw" link. E.g.:

    >> do https://raw.githubusercontent.com/red/code/master/Showcase/calculator.red

Note: If you are using the Wine emulator, it has some issues with the GUI-Console. Install the Consolas font to fix the problem.

Generating a standalone executable

The Red toolchain comes as a single executable file that you can download for the big-3 platforms (32-bit only for now). Rename the file to redc (or redc.exe under Windows).

  1. Put the downloaded redc binary in the working folder.

  2. In a code or text editor, write the following Hello World program:

     Red [
         Title: "Simple hello world script"
     ]
    
     print "Hello World!"
    
  3. Save it under the name: hello.red

  4. Generate a compiled executable from that program: (first run will pre-compile libRedRT library)

     $ redc -c hello.red
     $ ./hello
    
  5. Want to generate a compiled executable from that program with no dependencies?

     $ redc -r hello.red
     $ ./hello
    
  6. Want to cross-compile to another supported platform?

     $ redc -t Windows hello.red
     $ redc -t Darwin hello.red
     $ redc -t Linux-ARM hello.red
    

The full command-line syntax is:

redc [command] [options] [file]

[file] any Red or Red/System source file.

  • The -c, -r and -u options are mutually exclusive.

[options]

-c, --compile                  : Generate an executable in the working
                                 folder, using libRedRT. (development mode)

-d, --debug, --debug-stabs     : Compile source file in debug mode. STABS
                                 is supported for Linux targets.

-dlib, --dynamic-lib           : Generate a shared library from the source
                                 file.

-e, --encap                    : Compile in encap mode, so code is interpreted
                                 at runtime. Avoids compiler issues. Required
                                 for some dynamic code.

-h, --help                     : Output this help text.

-o <file>, --output <file>     : Specify a non-default [path/][name] for
                                 the generated binary file.

-r, --release                  : Compile in release mode, linking everything
                                 together (default: development mode).

-s, --show-expanded            : Output result of Red source code expansion by
                                 the preprocessor.

-t <ID>, --target <ID>         : Cross-compile to a different platform
                                 target than the current one (see targets
                                 table below).

-u, --update-libRedRT          : Rebuild libRedRT and compile the input script
                                  (only for Red scripts with R/S code).

-v <level>, --verbose <level>  : Set compilation verbosity level, 1-3 for
                                 Red, 4-11 for Red/System.

-V, --version                  : Output Red's executable version in x.y.z
                                 format.

--config [...]                 : Provides compilation settings as a block
                                 of `name: value` pairs.

--no-compress                  : Omit Redbin format compression.

--no-runtime                   : Do not include runtime during Red/System
                                 source compilation.

--no-view                      : Do not include VIEW module in the CLI console
                                 and the libRedRT.

--red-only                     : Stop just after Red-level compilation.
                                 Use higher verbose level to see compiler
                                 output. (internal debugging purpose)

--show-func-map                : Output an address/name map of Red/System
                                 functions, for debugging purposes.

[command]

build libRed [stdcall]         : Builds libRed library and unpacks the
                                 libRed/ folder locally.

clear [<path>]                 : Delete all temporary files from current
                                 or target <path> folder.

Cross-compilation targets:

MSDOS        : Windows, x86, console (+ GUI) applications
Windows      : Windows, x86, GUI applications
WindowsXP    : Windows, x86, GUI applications, no touch API
Linux        : GNU/Linux, x86, console (+ GUI) applications
Linux-GTK    : GNU/Linux, x86, GUI only applications
Linux-musl   : GNU/Linux, x86, musl libc
Linux-ARM    : GNU/Linux, ARMv5, armel (soft-float)
RPi          : GNU/Linux, ARMv7, armhf (hard-float)
RPi-GTK      : GNU/Linux, ARMv7, armhf (hard-float), GUI only applications
Pico         : GNU/Linux, ARMv7, armhf (hard-float), uClibc
Darwin       : macOS Intel, console-only applications
macOS        : macOS Intel, applications bundles
Syllable     : Syllable OS, x86
FreeBSD      : FreeBSD, x86
NetBSD       : NetBSD, x86
Android      : Android, ARMv5
Android-x86  : Android, x86

Note: The toolchain executable (redc.exe) relies on Rebol encapper which does not support being run from a location specified in PATH environment variable and you get PROGRAM ERROR: Invalid encapsulated data error. If you are on Windows try using PowerShell instead of CMD. You can also provide the full path to the executable, put a copy of it in your working folder or wrap a shell script (see relevant tickets: #543 and #1547).

Running Red from the sources (for contributors)

The compiler and linker are currently written in Rebol. Please follow the instructions for installing the compiler toolchain in order to run it from sources:

  1. Clone this git repository or download an archive (ZIP button above or from tagged packages).

  2. Download a Rebol interpreter suitable for your OS: Windows, Linux (or Linux), Mac OS X, FreeBSD, OpenBSD, Solaris.

  3. Extract the rebol binary, put it in the root folder, that's all!

  4. Let's test it: run ./rebol, you'll see a >> prompt appear. Windows users need to double-click on the rebol.exe file to run it.

  5. From the REBOL console type:

     >> do/args %red.r "%tests/hello.red"
    

The compilation process should finish with a ...output file size message. The resulting binary is in the working folder. Windows users need to open a DOS console and run hello.exe from there.

You can compile the Red console from source:

    >> do/args %red.r "-r %environment/console/CLI/console.red"

To compile the Windows GUI console from source:

    >> do/args %red.r "-r -t Windows %environment/console/GUI/gui-console.red"

Note: the -c argument is not necessary when launching the Red toolchain from sources, as the default action is to compile the input script (the toolchain in binary form default action is to run the input script through the interpreter). The -r argument is needed when compiling the Red console to make additional runtime functions available.

Note: The red git repository does not include a .gitignore file. If you run the automated tests, several files will be created that are not stored in the repository. Installing and renaming a copy of .git/.gitignore-sample file will ignore these generated files.

Contributing

If you want to contribute code to the Red project be sure to read the guidelines first.

It is usually a good idea to inform the Red team about what changes you are going to make in order to ensure that someone is not already working on the same thing. You can reach us through our chat room.

Satisfied with the results of your change and want to issue a pull request on Github?

Make sure the changes pass all the existing tests, add relevant tests to the test-suite, and please test on as many platforms as you can. You can run all the tests using (from Rebol console, at repository root):

    >> do %run-all-tests.r

Git integration with console built from sources

If you want git version included in your Red console built from sources, use this command:

call/show ""                                              ;-- patch call bug on Windows
save %build/git.r do %build/git-version.r                 ;-- lookup git version if available
do/args %red.r "-r %environment/console/CLI/console.red"  ;-- build Console
write %build/git.r "none^/"                               ;-- restore git repo status

Anti-virus false positive

Some anti-virus programs are a bit too sensitive and can wrongly report an alert on some binaries generated by Red (see here for the details). If that happens to you, please report it to your anti-virus vendor as a false positive.

License

Both Red and Red/System are published under BSD license, runtime is under BSL license. BSL is a bit more permissive license than BSD, more suitable for the runtime parts.

red's People

Stargazers

 avatar

Forkers

bubnenkoff

red's Issues

Error connection

I have tried to connect to an ODBC data source called RD32, based on "SQL Server" driver.

c: open ODBC://RD32

I receive the error: .... access failed for user '' then the consolle closes

EDIT: Here is the output from RED console.exe

>> c: open odbc://rd32
28000 18456 [Microsoft][ODBC SQL Server Driver][SQL Server]Accesso non riuscito
per l'utente ''.
*** Script Error: ODBC error: ["28000" 18456 {[Microsoft][ODBC SQL Server Driver
][SQL Server]Accesso non riusc
*** Where: ctx||440~open-connection
*** Near : entity/spec/host
*** Stack:

Note that the USER DNS Origin has configured user and password inside

Also, I have tried the following:

connection: open make port! [
    scheme: 'odbc
    target: "driver={SQL Server};server=192.168.x.x;port=1433;database=ADB_RD32;uid=myuser;pwd=mypass"
]

(Server IP has been blanked)

The console hangs and I have to force close it.

SQL Server 2014 on Windows Server 2012 here

NOTE: One of the message I receive is "Invalid String Attribute" from the ODBC Driver. Removing the port=1433 has solved the problem

Error on insert

What I am doing wrong here?

the-query: {insert into xeventslog (type) values ('Record')}
;the-query: {select * from xeventslog}

st: open cn: switch 'rd con 
insert st the-query
x: copy st

probe x

Here is the table creation script in SQL Server

CREATE TABLE XEventsLog (
    IDEvent int IDENTITY(1,1) NOT NULL PRIMARY KEY  ,
	Type char(30),
	Sender  char(30),
	Domain char(30),
	RemoteAction char(30),
	RemoteActionVersion char(30),
	RemoteValue ntext,
	Command char(30),
	Version char(10),
	Value1 ntext,
	Value2 ntext,
	Value3 ntext,
	Value4 ntext,
	Extra ntext,
	ActionTime datetime,
	Processed bit default 0



);

Here is the gist with the log:

https://gist.github.com/GiuseppeChillemi/043c9c262b0d92e109df846b7db083f9

Crash with invalid column name

the-query: {insert into xeventslog (type) values ("Record")} ;<<<< Note, doble quotes used here but it crashes also with $$record$$

actor/open: connection
init-odbc
OPEN-ENVIRONMENT [
        SQLAllocHandle 0
        henv/value = 3141416
        SQLSetEnvAttr 0
]
        init-odbc: 0
OPEN-CONNECTION [
        SQLAllocHandle 0
        hcon/value = 61431904
        SQLDriverConnect 1
DIAGNOSE-ERROR [
        allocate state, 12 bytes @ 03A96578 ok.
        allocate msg-buf, 4096 bytes @ 03A9A4A8 ok.
        SQLGetDiagRec 0
01000
--------------------------------------------------------------------------------
---------------------------------------------------
03A9A4A8:  5b00 4d00 6900 6300  7200 6f00 7300 6f00  6600 7400 5d00 5b00  4f00 4
400 4200 4300      [.M.i.c.r.o.s.o.f.t.].[.O.D.B.C.
03A9A4C8:  2000 5300 5100 4c00  2000 5300 6500 7200  7600 6500 7200 2000  4400 7
200 6900 7600       .S.Q.L. .S.e.r.v.e.r. .D.r.i.v.
03A9A4E8:  6500 7200 5d00 5b00  5300 5100 4c00 2000  5300 6500 7200 7600  6500 7
200 5d00 4900      e.r.].[.S.Q.L. .S.e.r.v.e.r.].I.
03A9A508:  6c00 2000 6300 6f00  6e00 7400 6500 7300  7400 6f00 2000 6400  6900 2
000 6400 6100      l. .c.o.n.t.e.s.t.o. .d.i. .d.a.
03A9A528:  7400 6100 6200 6100  7300 6500 2000 e800  2000 7300 7400 6100  7400 6
f00 2000 7300      t.a.b.a.s.e. .è. .s.t.a.t.o. .s.
03A9A548:  6f00 7300 7400 6900  7400 7500 6900 7400  6f00 2000 6300 6f00  6e00 2
000 2700 4100      o.s.t.i.t.u.i.t.o. .c.o.n. .'.A.
03A9A568:  4400 4200 5f00 5200  4100 5600 4900 4f00  4c00 5f00 4400 4f00  5200 4
f00 2700 2e00      D.B._.*.*.*.*.*.*._.*.*.*.*.'...
--------------------------------------------------------------------------------
---------------------------------------------------
 5701 [Microsoft][ODBC SQL Server Driver][SQL Server]Il contesto di database è s
tato sostituito con 'ADB_******_****'.
        SQLGetDiagRec 0
01000
--------------------------------------------------------------------------------
---------------------------------------------------
03A9A4A8:  5b00 4d00 6900 6300  7200 6f00 7300 6f00  6600 7400 5d00 5b00  4f00 4
400 4200 4300      [.M.i.c.r.o.s.o.f.t.].[.O.D.B.C.
03A9A4C8:  2000 5300 5100 4c00  2000 5300 6500 7200  7600 6500 7200 2000  4400 7
200 6900 7600       .S.Q.L. .S.e.r.v.e.r. .D.r.i.v.
03A9A4E8:  6500 7200 5d00 5b00  5300 5100 4c00 2000  5300 6500 7200 7600  6500 7
200 5d00 4c00      e.r.].[.S.Q.L. .S.e.r.v.e.r.].L.
03A9A508:  2700 6900 6d00 7000  6f00 7300 7400 6100  7a00 6900 6f00 6e00  6500 2
000 6400 6500      '.i.m.p.o.s.t.a.z.i.o.n.e. .d.e.
03A9A528:  6c00 6c00 6100 2000  6c00 6900 6e00 6700  7500 6100 2000 e800  2000 7
300 7400 6100      l.l.a. .l.i.n.g.u.a. .è. .s.t.a.
03A9A548:  7400 6100 2000 7300  6f00 7300 7400 6900  7400 7500 6900 7400  6100 2
000 6300 6f00      t.a. .s.o.s.t.i.t.u.i.t.a. .c.o.
03A9A568:  6e00 2000 4900 7400  6100 6c00 6900 6100  6e00 6f00 2e00
                   n. .I.t.a.l.i.a.n.o...
--------------------------------------------------------------------------------
---------------------------------------------------
 5703 [Microsoft][ODBC SQL Server Driver][SQL Server]L'impostazione della lingua
 è stata sostituita con Italiano.
        SQLGetDiagRec 0
01S00
--------------------------------------------------------------------------------
---------------------------------------------------
03A9A4A8:  5b00 4d00 6900 6300  7200 6f00 7300 6f00  6600 7400 5d00 5b00  4f00 4
400 4200 4300      [.M.i.c.r.o.s.o.f.t.].[.O.D.B.C.
03A9A4C8:  2000 5300 5100 4c00  2000 5300 6500 7200  7600 6500 7200 2000  4400 7
200 6900 7600       .S.Q.L. .S.e.r.v.e.r. .D.r.i.v.
03A9A4E8:  6500 7200 5d00 4100  7400 7400 7200 6900  6200 7500 7400 6f00  2000 6
400 6900 2000      e.r.].A.t.t.r.i.b.u.t.o. .d.i. .
03A9A508:  7300 7400 7200 6900  6e00 6700 6100 2000  6400 6900 2000 6300  6f00 6
e00 6e00 6500      s.t.r.i.n.g.a. .d.i. .c.o.n.n.e.
03A9A528:  7300 7300 6900 6f00  6e00 6500 2000 6e00  6f00 6e00 2000 7600  6100 6
c00 6900 6400      s.s.i.o.n.e. .n.o.n. .v.a.l.i.d.
03A9A548:  6f00 2e00
                   o...
--------------------------------------------------------------------------------
---------------------------------------------------
 0 [Microsoft][ODBC SQL Server Driver]Attributo di stringa di connessione non va
lido.
        SQLGetDiagRec 100
        free state @ 03A96578 ok.
        free msg-buf @ 03A9A4A8 ok.
]
]
actor/open: statement
OPEN-STATEMENT [
        allocate fetched, 4 bytes @ 03A96578 ok.
        SQLAllocHandle 0
        hstm/value = 61433224
]
INSERT actor
OPEN? actor
FREE-PARAMETERS [
]
FREE-COLUMNS [
]
FREE-STATEMENT [
        SQLFreeStmt 0
        SQLFreeStmt 0
        SQLFreeStmt 0
]
PREPARE-STATEMENT [
        SQLPrepare 0
]
EXECUTE-STATEMENT [
        SQLExecute 65535
DIAGNOSE-ERROR [
        allocate state, 12 bytes @ 03A96558 ok.
        allocate msg-buf, 4096 bytes @ 03A99F80 ok.
        SQLGetDiagRec 0
42S22
--------------------------------------------------------------------------------
---------------------------------------------------
03A99F80:  5b00 4d00 6900 6300  7200 6f00 7300 6f00  6600 7400 5d00 5b00  4f00 4
400 4200 4300      [.M.i.c.r.o.s.o.f.t.].[.O.D.B.C.
03A99FA0:  2000 5300 5100 4c00  2000 5300 6500 7200  7600 6500 7200 2000  4400 7
200 6900 7600       .S.Q.L. .S.e.r.v.e.r. .D.r.i.v.
03A99FC0:  6500 7200 5d00 5b00  5300 5100 4c00 2000  5300 6500 7200 7600  6500 7
200 5d00 4900      e.r.].[.S.Q.L. .S.e.r.v.e.r.].I.
03A99FE0:  6c00 2000 6e00 6f00  6d00 6500 2000 6400  6900 2000 6300 6f00  6c00 6
f00 6e00 6e00      l. .n.o.m.e. .d.i. .c.o.l.o.n.n.
03A9A000:  6100 2000 2700 5200  6500 6300 6f00 7200  6400 2700 2000 6e00  6f00 6
e00 2000 e800      a. .'.R.e.c.o.r.d.'. .n.o.n. .è.
03A9A020:  2000 7600 6100 6c00  6900 6400 6f00 2e00
                    .v.a.l.i.d.o...
--------------------------------------------------------------------------------
---------------------------------------------------
 207 [Microsoft][ODBC SQL Server Driver][SQL Server]Il nome di colonna 'Record'
non è valido.
        SQLGetDiagRec 100
        free state @ 03A96558 ok.
        free msg-buf @ 03A99F80 ok.
]
*** Script Error: ODBC error: ["42S22" 207 {[Microsoft][ODBC SQL Server Driver][
SQL Server]Il nome di colonna
*** Where: execute-statement
*** Near : port/state describe-result port/state
*** Stack: do-file

Text Strings like typewriter

When trying connection, the RED Gui-Console, outputs the connection messages at very slow speed, like a typewrite.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.