Giter Site home page Giter Site logo

cognate-lang / cognate Goto Github PK

View Code? Open in Web Editor NEW
204.0 7.0 9.0 3.93 MB

A human readable quasi-concatenative programming language

License: BSD 2-Clause "Simplified" License

C 97.01% Lex 1.24% Yacc 0.87% Makefile 0.89%
programming-language functional-programming stack-language natural-language closures compiler forth prefix-notation language interpreter

cognate's People

Contributors

crabbo-rave avatar dragoncoder047 avatar fennecdjay avatar jake-87 avatar stavromulabeta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

cognate's Issues

Actual interpreter for microcontroller?

From the readme:

CognaC (the Cognate Compiler) compiles Cognate sources directly into C. This produces very small and rather fast binaries, allowing Cognate to outperform most dynamic languages. This also makes Cognate a candidate for scripting in embedded environments, such as microcontrollers.

... but microcontrollers can't compile and run C. Is there a "pure interpreter" for a microcontroller somewhere that actually executes the code instead of transpiling it to C? If there isn't, how do I make one out of this code here?

Speed of restrict_chars

Due to potentially being called a lot in large programs, the speed of restrict_chars could be extremely important. Is there a reason for the replacement words, here:

	char* with[]	 = {"DASH", "XMARK", "QMARK", "EQ", "LT", "GT", "PLUS", "STAR", "SLASH"};

to be full strings, instead of say, 'D', 'X', 'Q', 'E', 'L', 'G', 'P', 'S', 'H'?
The only thing I can think of is debugging.
If these were to be replaced with single char versions, you'd be able to much more quickly remove them.

Note this will not affect other variables, due to the sanitation process - I can provide examples if needed.

We could always provide two versions, using a flag like DEBUG to enable the slower version.

Documentation for Cognate words??

There isn't any documentation on each builtin word, and so for the ones that take and/or return blocks, the semantics are very confusing. Case in particular. What are the semantics of that, and everything else? Writing it as Forth stack-effect diagrams or just some example code would help.

Word synonyms for binary operators

Cognate looks really cool. The one place I think the literate aspect can be improved is with the binary operators, which are hard to read in a sentence as prefix symbols.

Print * 3 by - 7 2;  

If the following looks nice, I will make a pull request to add synonyms like this:

Print Multiply 3 by Subtract 7 from 2;

and so on, + would be Add, Inequal? and Equal? for != and ==, because of the same for While (!= "done" Twin Input)

Creating C file for non-existent file

Something that is most likely a bug, is that when you try to compile a nonexistant cognate file, it creates a C file for it, which is both annoying and wrong. Evidence:
image

Weird Segfault.

I noticed a weird segfault that appeared in my code. Here is a small reproduction:
This segfaults when ran, yet

Def Push-op as (Let Op; Push Op);
Let Commands be List ("+" "-" "%" "*")
Let Error be False;
List ();
For command in Commands
    Case "+" (Push-op)
    Case "-" (Push-op)
    Case "*" (Push-op)
    else (Set Bad-command; Set Error to True; Prints ("Error: Unknown Command " Bad-command "\n"));
Do If Not Error
    (Set Commands; For command in Commands Print)
    (Print "");
Clear;

This code works,

Def Push-op as (Let Op; Push Op);
Let Commands be List ("+" "-" "%" "*");
Let Error be False;
List ();
For command in Commands
    Case "+" (Push-op)
    Case "-" (Push-op)
    Case "*" (Push-op)
    else (Set Error to True; Put "Error: Unknown Command "; Print);
If Not Error
    (Set Commands; For command in Commands Print)
    (Print "");
Clear;

and the only difference seems to be this code which causes the segfault

else (Set Bad-command; Set Error to True; Prints ("Error: Unknown Command " Bad-command "\n"));

as opposed to this code which works.

else (Set Error to True; Put "Error: Unknown Command "; Print);

Further information: Prints doesn't segfault by itself, based on this reproduction I made that works,

Let Bar be  "Bar"; Prints ("hielo " Bar "\n");

Build fails in clang 15.x

In the C23 standard, functions without prototypes (int func() instead of int func(void)) are removed. Clang has deprecated the feature all versions of C as a result. When I try to compile the hello world example with cognac, I get the following error log:

hello.c:41:21: error: a block declaration without a prototype is deprecated  [-Werror,-Wstrict-prototypes]
typedef void(^BLOCK)();
                    ^
                     void
hello.c:323:26: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
static void assert_impure();
                         ^
                          void
hello.c:409:26: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
static void debugger_step()
                         ^
                          void
hello.c:605:26: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
static void assert_impure()
                         ^
                          void
hello.c:1971:23: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
static void VAR(debug)()
                      ^
                       void
5 errors generated.

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.