Coder Social home page Coder Social logo

mori0091 / cparsec3 Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 819 KB

CPARSEC3 - a parser-combinator library for C11, 3rd generation.

License: MIT License

Makefile 1.08% Shell 0.28% C 98.64%
c11 generic-programming generic-types generics meta-programming parsec parser-combinators preprocessor-macros trait type-class

cparsec3's People

Contributors

mori0091 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

cparsec3's Issues

[pug-lang] '!' (complement / not) operator causes "Type mismatch" error

Describe the bug
! x causes "Type mismatch" error in some case even if type of x was bool or int.

To Reproduce
Both of the following code causes "Type mismatch" error:

// case (1)
(|x| !x) 1 ;
// case (2)
(|x| !x) true;

Expected behavior
In case (1), it shall be -2 of type int.
In case (2), it shall be false of type bool.

Development environment (please complete the following information):

  • OS and version: Ubuntu 20.04 on WSL
  • Compiler and version: gcc 9.3.0

Additional context
None.

The scoping feature added at #120 is "dynamic scoping".

What's happen? Please describe the problem you met.
The scoping feature was added at #120 ("added 'lexical scope' feature").
But, in fact, it is dynamic scoping because a new scope (block scope) is established in run-time when evaluating a block.

Describe the solution you'd like
Lexical scoping is better for performance and safe/secure programming.
Though needs much work to implement it...

Describe alternatives you've considered

  • lambda abstraction / function application shall be added.
  • free variable (unbound variable in a lambda) shall be available.
  • Variables defined in outer scope (before or after of block/lambda):
    Shall it be accessible from inside of block/lambda? (even if a variable was defined later?)

Additional context

[pug-lang] Nullary type-constructor causes type error.

Describe the bug
Pug language interpreter causes type error, if a function or a constructor takes two or more arguments of nullary type constructor.

To Reproduce
The below code causes type error:

type Tree
    = Leaf int
    | Node Tree Tree
    ;

let t0 = Leaf 0;
let t1 = Leaf 1;
let t2 = Node t0 t1;

also the below code causes type error:

type Nat = Z | S Nat;
var plus : |Nat Nat| Nat;
let plus = |x y| match x {
    Z   => y;
    S n => S (plus n y);
};
let x = plus (S (S Z)) (S Z);

Expected behavior
Both of the above two codes are well formed, and should not cause an error.

Development environment (please complete the following information):

  • OS and version: Ubuntu 20.04 on WSL
  • Compiler and version: gcc 9.3.0

Additional context
(None)

`Parsec(S, Maybe(None))` shall be supported in default.

What's happen? Please describe the problem you met.
Parsec(S, None) is supported in default, but Parsec(S, Maybe(None)) is not.
This causes a problem to implement optional(p) parser that constructs Parsec(S, Maybe(T)).

Describe the solution you'd like
Both of the Parsec(S, None) and Parsec(S, Maybe(None)) are supported in default.
(move None from PARSER_RETURN_TYPES(S) to PARSER_RETURN_TYPES_0(S))

Describe alternatives you've considered

Additional context

[pug-lang] wrong variable binding in recursive function

Describe the bug
In case of some recursive functions, wrong value is bound to the function's argument.

To Reproduce
Here is two implementations of factorial function; fact and fact2.
fact 4 results 24, it's okay. But fact2 4 results 6 incorrectly.

let fact = |x|
  if x <=1 {
    1
  } else {
    x * fact (x - 1)
  }
;

let fact2 = |x| f x 1;
let f = |x a|
  if x <= 1 {
    a
  } else {
    f (x-1) (x*a)  // this is wrongly evaluated as `x = x - 1; a = x * a; f x a`
  }
;

Expected behavior
fact2 n shall be equals to fact n.

Development environment (please complete the following information):

  • OS and version: Ubuntu 18.04 on WSL
  • Compiler and version: gcc 7.5.0

Additional context

[base] trait(Ord(Array(T))).cmp(xs, ys) returns non-zero when xs has same contents of ys.

Describe the bug
trait(Ord(Array(T))).cmp(xs, xs) returns 0, but trait(Ord(Array(T))).cmp(xs, ys) returns non-zero even if xs has same contents of ys.

To Reproduce

Array(char) xs = g_array(char, 'a', 'b', 'c');
Array(char) ys = g_array(char, 'a', 'b', 'c');
assert(g_cmp(xs, xs) == 0);  // OK
assert(g_cmp(ys, ys) == 0);  // OK
assert(g_cmp(xs, ys) == 0);  // assertion fails! (it must be OK)

Expected behavior
In the above case:

  • g_cmp(xs, ys) shall be 0
  • g_le(xs, ys) shall be true
  • g_lt(xs, ys) shall be false
  • g_ge(xs, ys) shall be true
  • g_gt(xs, ys) shall be false
  • g_eq(xs, ys) shall be true
  • g_neq(xs, ys) shall be false

Development environment (please complete the following information):

  • OS and version: Ubuntu 20.04 on WSL
  • Compiler and version: gcc 9.3.0

Additional context
None.

[Pug-lang] leading white-spaces shall be ignored

Describe the bug
The pug language interpreter results syntax error if the source code starts with white space(s).

To Reproduce
pug -e '1' result 1, it's okay.
pug -e ' 1' causes syntax error.

Expected behavior
Leading white-spaces shall be ignored.
i.e for example pug -e ' 1' shall results 1.

Development environment (please complete the following information):

  • OS and version: Ubuntu 18.04 on WSL
  • Compiler and version: gcc 7.5.0

Additional context
nothing.

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.