Coder Social home page Coder Social logo

yan's Introduction

Deprecated ๐Ÿ™ƒ

The EPITECH style guide got a major update promoting more modern practices as of October 2017. Feel free to contact me or to open an issue if you are interested in updating or reusing this project.


Build Status

Work in progress

Yan stands for "Yet another norminette". This is a C brace style checker written in Python designed for the EPITECH style.

But unlike the "official" one, this style checker is not a bunch of crappy regex getting so easily confused. Yan is based on a carefully designed tokenizer and an authentic hand-written recursive descent parser.

However, Yan does not handle macros and preprocessor directives (except #include).

What does it check?

A lot of rules of the EPITECH style are checked. I don't want to list all the checks here, it's a pain to describe and to read. Here is a short summary.

A few rules are not implemented yet, and a few rules are not implementable (they must be checked by a human).

A notable feature of this program is its ability to check the most of the rules relative to the indentation.

Forbiden statements like for and switch are not implemented in the parser. If you use one, it leads to a syntax error.

Other features

<stdarg.h> and va_arg() are supported. ยซ Calls ยป to function-like macros with a type as argument are supported, ellipsis (...) is supported.

typedef is (partially) supported. If Yan fails to analyze a header containing a type important in your program (say t_my_type), you can add this comment before your first use of t_my_type:

/*
** yan typedef t_my_type
*/

If Yan crashes on a part of your code, you can indicate it to ignore the problematic part:

/*
** yan parser off
*/

...some C++ stuff to skip...

/*
** yan parser on
*/

Some features of C99 are implemented (e.g. designated initializers).

Download

Clone the whole repository or fetch yan.py only:

wget https://raw.githubusercontent.com/motet-a/yan/master/yan.py
chmod +x yan.py

Check

If PSU_2015_my_printf/ is the directory of your repository, simply run yan PSU_2015_my_printf/.

If you have header files in a separate directory and the paths in your #include statements are not relative, Yan can't find the headers. You have to specify manually which directories contains headers with the -I option.

If you have a Makefile, Yan can automatically find which directory contains headers in some cases.

Run the tests

To run all the tests, use ./test.sh.

You can run the unit tests with ./test.py or python3 -m unittest test.py.

The script test_on_real_projects.sh fetches a few Git repositories of EPITECH projects and checks their sources with Yan.

TODO

Not so much work.

Macros are not implemented, #defines are ignored. If you use a macro, it should look like a function call or an identifier, otherwise it leads to a syntax error.

Structure and unions are not entirely implemented. Bit fields are not implemented.

yan's People

Contributors

7felf avatar motet-a avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

7felf

yan's Issues

Option to exclude files/directories

There should be an option to exclude directories or files during analysis. Something like --exclude tests/ or maybe a .yanignore file listing all files & directories to ignore in a given directory.

For example: I don't want to analyse my tests directory when I type yan.py ..

Norm for headers

Currently Yan checks for too long lines & trailing white-spaces in Headers. As far as I know, the official norminette is not checking those rules for the headers.

I think there should be an option like --no-header-check to ignore norm rules on headers, or yan should definitely ignore norm on headers.

Or maybe, yan could check if headers are valid & respecting the header spec :

/*
** {{file}} for {{project}} in {{path}}
** 
** Made by {{user}}
** Login   <{{login}}@epitech.net>
** 
** Started on  {{day}} {{month}} {{day}} {{hour}}:{{minute}}:{{second}} {{year}} {{user}}
** Last update {{day}} {{month}} {{day}} {{hour}}:{{minute}}:{{second}} {{year}} {{user}}
*/

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.