Coder Social home page Coder Social logo

cfile's People

Contributors

cogu avatar sperly 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

cfile's Issues

An example to generate a structure initializer

Thanks for the work, probably the only one which would work for the my needs!
Is there a way to generate either of the following lines:

typedef struct mystruct {
    int            field_1;
    int            field_2;
} my_struct_t ;

my_struct_t instance = {
    .field_1= 0,
    .field_2= 1
};

or

typedef struct mystruct {
    int            field_1;
    int            field_2;
} my_struct_t ;

my_struct_t instance = { 0, 1 };

Thanks in advance

Mypy run reveals a bunch of type errors

Hi,

Cool project by the way.

I was messing around with my fork of your project (not many changes mostly just running black and a couple of tweaks), and the I ran mypy:

mypy src

and I got the following (I fixed a couple, so this list should be a little longer on your version). I definitely recommend checking this out since you need to have rigor in your type system and vs code doesn't pick up on these.

src/cfile/core.py:469: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
src/cfile/core.py:477: error: Item "Comment" of "Comment | Statement | Sequence" has no attribute "append"  [union-attr]
src/cfile/core.py:477: error: Item "Statement" of "Comment | Statement | Sequence" has no attribute "append"  [union-attr]
src/cfile/core.py:484: error: Item "Comment" of "Comment | Statement | Sequence" has no attribute "extend"  [union-attr]
src/cfile/core.py:484: error: Item "Statement" of "Comment | Statement | Sequence" has no attribute "extend"  [union-attr]
src/cfile/writer.py:34: error: Incompatible types in assignment (expression has type "None", variable has type "str")  [assignment]
src/cfile/writer.py:35: error: Incompatible types in assignment (expression has type "None", variable has type "TextIO")  [assignment]
src/cfile/writer.py:141: error: "TextIO" has no attribute "getvalue"  [attr-defined]
src/cfile/writer.py:148: error: "TextIO" has no attribute "getvalue"  [attr-defined]
src/cfile/writer.py:155: error: Cannot call function of unknown type  [operator]
src/cfile/writer.py:162: error: Item "Comment" of "Comment | Statement | Sequence" has no attribute "__iter__" (not iterable)  [union-attr]
src/cfile/writer.py:162: error: Item "Statement" of "Comment | Statement | Sequence" has no attribute "__iter__" (not iterable)  [union-attr]
src/cfile/writer.py:162: error: Item "Sequence" of "Comment | Statement | Sequence" has no attribute "__iter__" (not iterable)  [union-attr]
src/cfile/writer.py:189: error: Cannot call function of unknown type  [operator]
src/cfile/writer.py:212: error: Cannot call function of unknown type  [operator]
src/cfile/writer.py:317: error: Argument 1 to "_write_type" of "Writer" has incompatible type "Type | Struct"; expected "Type | StructRef"  [arg-type]
src/cfile/writer.py:341: error: Item "Struct" of "Type | Struct" has no attribute "pointer"  [union-attr]
src/cfile/writer.py:351: error: Item "Struct" of "Type | Struct" has no attribute "pointer"  [union-attr]
src/cfile/writer.py:437: error: Argument 1 to "len" has incompatible type "Comment | Statement | Sequence"; expected "Sized"  [arg-type]
src/cfile/factory.py:34: error: Incompatible return value type (got "Line", expected "Blank")  [return-value]
src/cfile/factory.py:99: error: Invalid type comment or annotation  [valid-type]
src/cfile/factory.py:99: note: Suggestion: use core.Block[...] instead of core.Block(...)
src/cfile/factory.py:114: error: Argument 2 to "Function" has incompatible type "str | Type | Struct | None"; expected "str | Type | None"  [arg-type]
src/cfile/factory.py:126: error: Argument 1 to "Type" has incompatible type "str | Type | Struct"; expected "str | Type"  [arg-type]
Found 22 errors in 3 files (checked 5 source files)

Redundant boolean operations

In several places I have found highly redundant boolean opertions. For example:

self.sys=True if sys==True else False
can be rewritten as self.sys=sys, or self.sys=bool(sys) if you're paranoid about imprecise types. Also, in general, x == True is eqivalent to x, and x == False - to not x. I think refactoring this would make your code a lot clearer

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.