Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for include in datalog scanner #2270

Merged
merged 1 commit into from
May 14, 2022

Conversation

quentin
Copy link
Member

@quentin quentin commented May 5, 2022

Hi, this change is an attempt to liberate ourselves from the dependency on a C preprocessor to read datalog programs.

The C preprocessor provides the following capabilities that I want to have natively in the datalog grammar: #include, #pragma once, __FILE__ and __LINE__. I believe it is sane to avoid supporting any form of preprocessor-flavored macro natively.

This change introduces:

  • new souffle command-line option --no-preprocessor that instructs Soufflé to scan directly from the input file.
  • new directive .include "path".
  • new directive .once (scanner will skip the rest of the current file the next time it encounters this directive at the same location).
  • support of __FILE__ and __LINE__ (replaced respectively with current file and line).
  • scanner harvests comments (for future usage).

The new directives are always handled, regardless of --no-preprocessor.

Regardless of --no-preprocessor, the include stack is maintained at all time and all source locations now points to immutable objects of the IncludeStack (instead of copies of vector of files). This allows to provide more precise error messages in the future by showing precise include stack for any source location.

Regardless of --no-preprocessor, the support of C preprocessor output #line and # information is also updated to track the include stack.

Current limitation: if a C preprocessor is used, only the main source file is pre-processed, files that are included with .include will not be pre-processed.

@codecov
Copy link

codecov bot commented May 5, 2022

Codecov Report

Merging #2270 (473b66d) into master (0ebb75f) will decrease coverage by 0.04%.
The diff coverage is 64.68%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2270      +/-   ##
==========================================
- Coverage   76.94%   76.89%   -0.05%     
==========================================
  Files         455      455              
  Lines       28496    28652     +156     
==========================================
+ Hits        21926    22033     +107     
- Misses       6570     6619      +49     
Impacted Files Coverage Δ
src/parser/ParserDriver.h 100.00% <ø> (ø)
src/parser/parser.yy 95.14% <ø> (ø)
src/parser/scanner.ll 73.51% <56.25%> (-2.16%) ⬇️
src/parser/SrcLocation.cpp 84.41% <66.66%> (-5.73%) ⬇️
src/main.cpp 68.62% <67.04%> (+0.52%) ⬆️
src/parser/ParserDriver.cpp 89.24% <81.81%> (-1.34%) ⬇️
src/parser/SrcLocation.h 100.00% <100.00%> (ø)
...ouffle/datastructure/ConcurrentInsertOnlyHashMap.h 82.92% <0.00%> (-0.82%) ⬇️

- add option `--no-preprocessor`
- new directive `.include "path"`
- new directive `.once`
- scanner treats `__FILE__` and `__LINE__`.
- scanner harvests comments (for future usage)
Copy link
Member

@b-scholz b-scholz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

@b-scholz b-scholz merged commit a0869f9 into souffle-lang:master May 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants