Giter VIP home page Giter VIP logo

egel's People

Contributors

dennismitchell avatar egel-lang 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

Watchers

 avatar  avatar

egel's Issues

Can't build on MacOS

Hi,

I can't seem to build on MacOS. I've installed libicu4c with Homebrew, but get the following errors when running build.sh:

emacs-mbp% ./build.sh
c++ --std=c++17 -Werror -c -Wall -pedantic -fPIC -O3 utils.cpp -o utils.o
In file included from utils.cpp:3:
./utils.hpp:9:10: fatal error: 'unicode/ustdio.h' file not found
#include "unicode/ustdio.h"
         ^~~~~~~~~~~~~~~~~~
1 error generated.
gmake: *** [Makefile:69: utils.o] Error 1
c++ --std=c++17 -Werror -c -Wall -pedantic -O3 -fPIC utils.cpp -o utils.o
In file included from utils.cpp:3:
./utils.hpp:9:10: fatal error: 'unicode/ustdio.h' file not found
#include "unicode/ustdio.h"
         ^~~~~~~~~~~~~~~~~~
1 error generated.
gmake: *** [Makefile:69: utils.o] Error 1
c++ --std=c++17 -Werror -c -Wall -pedantic -O3 utils.cpp -o utils.o
In file included from utils.cpp:3:
./utils.hpp:9:10: fatal error: 'unicode/ustdio.h' file not found
#include "unicode/ustdio.h"
         ^~~~~~~~~~~~~~~~~~
1 error generated.
gmake: *** [Makefile:69: utils.o] Error 1
c++ --std=c++17 -Werror -fPIC -c -Wall -pedantic -O3 io.cpp -o io.o
^Cgmake: *** [Makefile:34: io.o] Interrupt: 2

emacs-mbp%

The folder unicode and the file ustdio.h both exist, though...

Build errors with gcc 8.1.1

Egel fails to build with gcc 8.1.1. This appears to be due to new warnings introduced in gcc 8, which the build script treats as errors.

Running build.sh produces the following output.

c++ --std=c++17 -Werror -c -Wall -pedantic -fPIC -O3 utils.cpp -o utils.o
c++ --std=c++17 -Werror -c -Wall -pedantic -fPIC -O3 lexical.cpp -o lexical.o
c++ --std=c++17 -Werror -c -Wall -pedantic -fPIC -O3 operators.cpp -o operators.o
c++ --std=c++17 -Werror -c -Wall -pedantic -fPIC -O3 syntactical.cpp -o syntactical.o
c++ --std=c++17 -Werror -c -Wall -pedantic -fPIC -O3 ast.cpp -o ast.o
c++ --std=c++17 -Werror -c -Wall -pedantic -fPIC -O3 transform.cpp -o transform.o
c++ --std=c++17 -Werror -c -Wall -pedantic -fPIC -O3 semantical.cpp -o semantical.o
semantical.cpp: In member function ‘virtual void VisitDeclare::visit_expr_combinator(const Position&, const UnicodeStrings&, const icu_60::UnicodeString&)’:
semantical.cpp:76:38: error: catching polymorphic type ‘class ErrorSemantical’ by value [-Werror=catch-value=]
             } catch (ErrorSemantical e) {
                                      ^
semantical.cpp:86:38: error: catching polymorphic type ‘class ErrorSemantical’ by value [-Werror=catch-value=]
             } catch (ErrorSemantical e) {
                                      ^
semantical.cpp: In member function ‘void RewriteIdentify::declare(const Position&, const icu_60::UnicodeString&, const icu_60::UnicodeString&)’:
semantical.cpp:172:34: error: catching polymorphic type ‘class ErrorSemantical’ by value [-Werror=catch-value=]
         } catch (ErrorSemantical e) {
                                  ^
cc1plus: all warnings being treated as errors
gmake: *** [Makefile:69: semantical.o] Error 1
c++ --std=c++17 -Werror -c -Wall -pedantic -O3 -fPIC semantical.cpp -o semantical.o
semantical.cpp: In member function ‘virtual void VisitDeclare::visit_expr_combinator(const Position&, const UnicodeStrings&, const icu_60::UnicodeString&)’:
semantical.cpp:76:38: error: catching polymorphic type ‘class ErrorSemantical’ by value [-Werror=catch-value=]
             } catch (ErrorSemantical e) {
                                      ^
semantical.cpp:86:38: error: catching polymorphic type ‘class ErrorSemantical’ by value [-Werror=catch-value=]
             } catch (ErrorSemantical e) {
                                      ^
semantical.cpp: In member function ‘void RewriteIdentify::declare(const Position&, const icu_60::UnicodeString&, const icu_60::UnicodeString&)’:
semantical.cpp:172:34: error: catching polymorphic type ‘class ErrorSemantical’ by value [-Werror=catch-value=]
         } catch (ErrorSemantical e) {
                                  ^
cc1plus: all warnings being treated as errors
gmake: *** [Makefile:69: semantical.o] Error 1
c++ --std=c++17 -Werror -c -Wall -pedantic -O3 semantical.cpp -o semantical.o
semantical.cpp: In member function ‘virtual void VisitDeclare::visit_expr_combinator(const Position&, const UnicodeStrings&, const icu_60::UnicodeString&)’:
semantical.cpp:76:38: error: catching polymorphic type ‘class ErrorSemantical’ by value [-Werror=catch-value=]
             } catch (ErrorSemantical e) {
                                      ^
semantical.cpp:86:38: error: catching polymorphic type ‘class ErrorSemantical’ by value [-Werror=catch-value=]
             } catch (ErrorSemantical e) {
                                      ^
semantical.cpp: In member function ‘void RewriteIdentify::declare(const Position&, const icu_60::UnicodeString&, const icu_60::UnicodeString&)’:
semantical.cpp:172:34: error: catching polymorphic type ‘class ErrorSemantical’ by value [-Werror=catch-value=]
         } catch (ErrorSemantical e) {
                                  ^
cc1plus: all warnings being treated as errors
gmake: *** [Makefile:69: semantical.o] Error 1
c++ --std=c++17 -Werror -fPIC -c -Wall -pedantic -O3 io.cpp -o io.o
io.cpp: In member function ‘virtual VMObjectPtr Readline::apply(const VMObjectPtr&) const’:
io.cpp:410:37: error: catching polymorphic type ‘class std::exception’ by value [-Werror=catch-value=]
             } catch (std::exception e) {
                                     ^
cc1plus: all warnings being treated as errors
gmake: *** [Makefile:34: io.o] Error 1
c++ --std=c++17 -Werror -fPIC -c -Wall -pedantic -O3 random.cpp -o random.o
c++ --std=c++17 -Werror -shared -licuio -licui18n -licuuc -licudata  random.o -o ../random.ego
c++ --std=c++17 -Werror -fPIC -c -Wall -pedantic -O3 regex.cpp -o regex.o
c++ --std=c++17 -Werror -shared -licuio -licui18n -licuuc -licudata  regex.o -o ../regex.ego
c++ --std=c++17 -Werror -fPIC -c -Wall -pedantic -O3 fs.cpp -o fs.o
c++ --std=c++17 -Werror -shared -licuio -licui18n -licuuc -licudata  fs.o -lstdc++fs -o ../fs.ego

Code Review

notes about egel:

use using instead of typedef, it's identical except that using also works with templates - see https://stackoverflow.com/questions/10747810/what-is-the-difference-between-typedef-and-using-in-c11

use enum classes instead of raw enums to prevent accidental type conversions where possible & feasible. Exported headers may still use raw enums for C compatibility - see https://stackoverflow.com/questions/18335861/why-is-enum-class-preferred-over-plain-enum

maybe just use "#pragma once" instead of #ifdef header guards? It's personal preference, but absolutely every compiler supports #pragma once, and it doesn't have you scrolling back up to find the matching #ifdef when you encounter a #endif

why is AstPtr (and probably other typedefs elsewhere) a shared_ptr and not raw pointer? In every function that does not modify the underlying object, you can just use a raw pointer for more flexibility further down. smart pointers should only be used in a function signature if the function affects or depends upon the lifetime in some way - the cppcoreguidelines recommend passing smart pointers only in these scenarios https://www.modernescpp.com/index.php/c-core-guidelines-passing-smart-pointer

what's the point of struct EqualAstPtr & LessAstPtr? Shouldn't this just be an operator overload of operator<=> of the Ast class?

Mark every class that inherits from a class with virtual functions as final (assuming you don't intend to inherit from it further on, of course) - this is both for code hygiene and helps the compiler devirtualize virtual function calls

Way too many function macros - maybe look into structured bindings for the various SPLIT macros? https://en.cppreference.com/w/cpp/language/structured_binding
On that note, prefer templates over macros as they are type safe & have clear deduction rules

In https://github.com/egel-lang/egel/blob/master/src/ast.hpp#L291 : first of all use std::make_shared. second, you can use braced returns when you want to construct the return type in the return statement.

Don't use C-style casts. They are WAY too powerful and have multiple meanings that'll slide past you - see https://en.cppreference.com/w/cpp/language/explicit_cast

Use range based for loops when iterating through a container and you don't need the specific index - see https://en.cppreference.com/w/cpp/language/range-for

Typenames ending in _t are generally reserved, avoid using them - see https://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html

You seem to have some tests, but how do I run them? Perhaps use cmakes test tool, ctest?

auto buffer = new char[len+1];
don't ever use new[] / delete[] unless you really really need to for some reason

char* to_char() {
related, also why not return a std::unique_ptr?

for (size_t n = 0; n < sz ; n++) {
missing assert to prevent out of bounds

`[ (X Y) -> X ] (T b)` should reduce to `T` for any term `T`.

Context: [ (X Y) -> Y ] (a T) reduces to T for any term T. This is expected behavior.

Expected behavior: Similarly, [ (X Y) -> X ] (T b) should reduce to T for any term T.

Actual behavior: [ (X Y) -> X ] ((a b) c) does not reduce at all, because ((a b) c) expands to (a b c) and we can't match against a 3-application term with a 2-application pattern.

We can write the pattern [ ((X Y) Z -> (X Y) ], but as far as I know, it isn't possible to match against an arbitrary n-application. In my opinion, the current behavior is unexpected and unhelpful.

Use case: I'm trying to implement delimited continuations, and I need to be able to match against terms which look like (shift E) X..., but this expands to (shift E X...), so the pattern match fails. I can implement ((X Y) Z) patterns as a special case, but this results in code duplication and prevents shift from returning variadic functions.

using System
def double = \X -> 2 * X

data shift
def reset = resetK (\X -> X)
# accumulates the continuation in an extra argument K
def resetK = \K -> [ (shift E) -> E (\X -> reset (K X))
                   | (X Y) -> resetK (\Y2 -> resetK (\X2 -> K (X2 Y2)) X) Y
                   # | ((X Y) Z) -> resetK (\Z2 -> resetK (\XY2 -> K (XY2 Z2)) (X Y)) Z
                   | X -> K X ]

# works
def test1 = reset (double (shift (\K -> K (K 2))))
# requires the extra `((X Y) Z)` pattern
def test2 = reset ((shift (\K -> K (\X -> X + 2))) 6)
# doesn't work without adding yet another `(((W X) Y) Z)` pattern
def test3 = reset ((shift (\K -> K (\X Y -> X + Y)) 3 4))

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.