220 Commits

Author SHA1 Message Date
sortA a0691e6172 Correct the username in the copyright notice 2026-05-06 12:28:40 -07:00
Rac 96e5788a45 fix: avoid accepting directories as include files 2026-05-06 12:28:40 -07:00
Rac b5af804078 fix: revise copyright notice 2026-05-06 12:28:40 -07:00
Rac 87ae95cbb2 fix(macromap): correct return value in expand_predefined_macro 2026-05-06 12:28:40 -07:00
Jeff Trull ec47ccf100 Implement support for digit separators in preprocessor expressions
Integers with digit separators are already recognized as literal
tokens. This commit adds proper interpretation of them as integers for
use in expressions e.g. with #if
2026-05-06 12:28:40 -07:00
Jeff Trull 147b685795 Introduce c++23 feature flag and condition size_t literals with it 2026-05-06 12:28:40 -07:00
Jeff Trull 453493e640 Tweak PR #241 for correctness and tidy code
- Fix RE2C code for numbers (binary and digit separators)
- Revert to RE2C version 1.0.2, for now
- Revamp token ids to minimize changes
- Restore existing and more accurate name OPTSIGN in slex
- Add binary literal support to lexertl
- Fix xlex support for size_t literals
- Add test tokens for octal, binary, and hex literals
2026-05-06 12:28:40 -07:00
Andreas Pokorny f776d2ed40 fix(lexer): support size_t literal, separator chars, 'module'
The integer parsing grammars still have to be updated.
2026-05-06 12:28:40 -07:00
njnobles ffdc3419a3 Emit line directives for includes with directive on first line (#223)
* Emit line directives for includes with directive on first line
* Add nested include tests

Thanks to Nick Nobles for this bug report and fix
2024-10-03 12:49:37 -07:00
jwnhy ef14767aec Fix empty stringify under C++20 (#221)
* fix segment fault of empty stringify under C++20
* Add tests for optional comma in variadic macro call

---------

Co-authored-by: Jeff Trull <edaskel@att.net>
2024-09-15 14:42:33 +10:00
René Ferdinand Rivera Morell 7ce8b53d9d Add support for modular build structure. (#214)
* Make the library modular usable.

* Switch to library requirements instead of source. As source puts extra source in install targets.

* Add wave tool build to all target.

* Add missing NO_LIB usage requirements.

* Add requires-b2 check to top-level build file.

* Bump B2 require to 5.2

* Change all <source> references to <library>.

* Move inter-lib dependencies to a project variable and into the build targets.

* Update build deps.
2024-08-26 22:01:03 -07:00
Jeff Trull df2125a1bd Repair Overflow Checks
The previous code checked for signed overflow on +, -, and * by doing
the operation and checking the result, which can invoke undefined
behavior. This replaces that code with initial tests on the operands.

In addition, a test for the sole integer division overflow case (that
is not division by zero) was missing: INT_MIN / -1
It has now been added, along with a test case.
2024-06-25 15:00:02 -07:00
chisolm 737c1e07ee Update marker before and after fill() operation in cpplexer (#203)
* Update marker before and after fill() operation in cpplexer

* A basic test case for trigraph "pound" (octothorpe) on fill boundary (detects the marker issue)

This change resolves #202 

---------

Co-authored-by: Chris Chisolm <chris_chisolm@intuit.com>
Co-authored-by: Jeff Trull <edaskel@att.net>
2024-01-30 10:16:07 -08:00
Jeff Trull 543a0e9e1d Restore previous newline output after pragma (#201)
This line was inadvertently removed in 1.84 as part of another bug
fix. This change restores it and improves the associated unit test.
2024-01-17 19:09:53 -08:00
Jeff Trull 28ff870cc5 Support a single #pragma without body
The existing code assumed there was at least one space following
 #pragma, but that is not required.
2023-10-23 20:07:47 -07:00
Jeff Trull f10ee1fc3d Add test for \e \E feature overlooked in prior commit 2022-11-08 18:13:32 -08:00
Jeff Trull 3586cf3706 Support \e and \E in character and string literals
Updates the non-strict lexer to support e and E, both with value 27
(ASCII ESC). Also adds tests for lexing these literals, and checks
that they are usable in conditional preprocessor expressions.
2022-11-07 22:44:24 -08:00
Jeff Trull 68b8e26625 Fix line directives after endif following else (#170)
* Fix line directives after endif when else clause is present

The initial part of a conditional block (the if/ifdef/ifndef) takes
the "slow" path through the code in cpp_iterator.hpp using the C++
expression grammar, while else and endif directives take the "fast"
path. The slow path sets must_emit_line_directive, and it will be
cleared after either else or endif is processed. Unfortunately when
an else precedes the endif, must_emit_line_directive is cleared and is
never set, as only the slow path sets it. The result is proper line
directives are issued for the else clause, but not for the subsequent
endif.

This changes adds setting of must_emit_line_directive in the "fast"
path for endif so line directives are considered after an intervening else.
2022-06-25 07:09:56 -07:00
Jeff Trull 44e3f30ff9 Let long integer literals participate in conditional expressions (#165)
Also add a test case for this situation
2022-06-22 11:23:06 -07:00
Jeff Trull 977b67a1d0 Fix missing (uncalled) exception hooks (#166)
* Check hooks after expected errors, not just when there are none

Some unit tests had intentional errors, and code to verify that the
appropriate hooks were called, but we never checked.

* Update unit tests to match hooks, now that we are checking

* Fix bug revealed by checking the hooks

Or in other words, bug #161 (thanks abakhirkin for the fix)

* Fix link in documentation
2022-06-22 11:22:27 -07:00
Alexander Grund 0a551b3d15 Add the C++11 requirements also to the test project (#156)
* Add the C++11 requirements also to the test project

* Add missing import
2022-03-09 10:08:50 -08:00
Jeff Trull 59610d6f79 Extend __has_include() grammar for arbitrary conditional expressions (#144)
* Extend __has_include grammar for complex conditional expressions

The logic handling __has_include erroneously assumed it would always
be the last expression on a line. This code fixes that by extending
the grammar to only consume the __has_include() itself, and count
parentheses as necessary to find the correct input range.

Also add some unit tests to cover the error in the future.

* While I'm at it, a couple of small cleanups

1) Remove unneeded header
2) The wrong BOOST_SPIRIT_DEBUG_TRACE_RULE was commented out
2022-01-18 10:46:16 -08:00
Jeff Trull 467afcc46e Qualify "newline at EOF not required" with actually being there (#141)
In C++11 and later modes Wave by default does not require newline prior to EOF. This works
fine but there is one place where the test for this feature was used but Wave is not necessarily
looking at the end of the file: pp_is_last_on_line. One observable (and surprising)
result is that unknown directives are not getting flagged - there may be others. The unit tests
did not discover this problem because they generally do not set c++11 mode.

The necessary qualification is added, along with unit test to cover this issue.
2022-01-02 14:24:39 -08:00
Jeff Trull f2957045b5 Fix line directives for ifdef and ifndef when default hooks are used (#140)
At some point in the past the handling for #if and #ifdef diverged. The code that handles emitting a line directive when a conditional section is skipped worked for #if but not ifdef/ifndef.

This problem was not observable when the eat_whitespace hooks were used instead of the default_preprocessing hooks, because the former
signals skipped newlines through the may_skip_whitespace hook, hiding the problem. Furthermore, the majority of Wave tests use the eat_whitespace hooks, so it wasn't visible there.

This change restores ifdef/ifndef to the same section as #if, so any changes to conditional handling will happen uniformly. Also, a test case is added to cover the default hooks and this particular case.
2022-01-02 07:09:32 -08:00
Jeff Trull 88369abfd5 Remove long-deprecated hooks API
Removal in 1.76 was noted in the docs and warned about since 1.74.
2020-12-13 15:53:32 -08:00
Jeff Trull 0ff9eafa04 Add the spaceship <=> operator to the C++20 tokens 2020-10-24 22:01:43 -07:00
Jeff Trull f1ec8fd22c Make indentation consistent with code nesting
These changes, a subset of what clang-format generates, ensure code
and comments are aligned properly for the level of the code. There
were a number of places where comments (many) and code (some) were
four spaces to the left of where they should be. This will make the
code easier to read.

One advantage of separating out these changes is they can be verified
to be whitespace-only with a simple diff.
2020-10-23 15:05:00 -07:00
Jeff Trull 465fe2291f Merge pull request #109 from jefftrull/feature/cpp20-tokens
Introduce C++20 tokens
2020-08-16 11:55:39 -07:00
Jeff Trull 200f91e71d Introduce C++20 tokens 2020-08-11 13:17:01 -07:00
Jeff Trull add63677b0 C++11 tokens should be conditionally compiled 2020-08-10 05:10:07 -07:00
Jeff Trull 35fc5aa381 Add C++11 token support to all lexers
Support was already in slex, though it wasn't covered by the token
test. This updates the tests while adding virtually identical code
to lexertl and xlex.
2020-08-10 04:47:04 -07:00
Jeff Trull 9d68ca319a Track the location tokens were expanded from, for __LINE__ and __FILE__
An (optional) extra position field is added to token_data and set for
any identifier token created from a macro expansion. This information
is used to correctly calculate the filename and line number.
2020-07-20 20:51:14 -07:00
Jeff Trull ee0a7c14c5 Implement __has_include() (#102)
Resolve #96 by introducing C++17 feature (and frequent vendor extension) __has_include(), along with appropriate unit tests and documentation updates
2020-06-27 07:22:52 -07:00
Jeff Trull 895ea836e9 Remove unused headers
Reduce build time by:
- using iosfwd instead of iostream, where possible
- where iostream is necessary but only used for debugging,
  making its inclusion conditional
- removing old C-style headers

I used IWYU to guide this work
2020-05-19 10:41:22 -07:00
Jeff Trull 3b6df8adb1 Include __LINE__, __FILE__, __INCLUDE_LEVEL__, and __VA_OPT__ in hooks (#87)
* Run hooks for certain predefined object-like macros

These are the "dynamic" macros with their own special execution path.
Most predefined macros can be computed at startup time; those were
already covered by the normal expansion code.

*  __VA_OPT__ is supported as a function-like macro

It is referred to as such in the proposal. __VA_ARGS__ is not supported, under the theory that it represents a parameter or set of parameters, and no hooks are called for parameter substitutions.
2020-04-12 12:40:03 -07:00
Jeff Trull b68940a83b Disallow mixed-case long long integer literals (#80)
- Update all four lexers to allow ll/LL but not lL/Ll
- Add unit tests for checking
- Remove invalid token from test
2020-03-15 22:54:01 -07:00
Jeff Trull 849da9fb6a Remove linking to newly header-only date_time (#81)
Boost develop branch has an updated date_time that is header-only so
Wave's builds will now fail unless this dependency is removed.
2020-03-15 17:37:19 -07:00
Jeff Trull 750e0cb68c Repair lexertl lexer and add to test suite (#78)
- Update DFA index code to reflect newer Spirit versions
- Update corresponding static lexer, adding explanatory comments
- Incorporate lexertl into test framework
2020-03-13 12:24:49 -07:00
Jeff Trull 940071ed55 Repair xlex and add to test suite (#79)
* Pass tests by matching lexertl blank handling
* Remedial improvement to position tracking to avoid exception
* Fix token statistics sample's count map index calculation
* Add xlex to test suite

Also, prune includes somewhat.
2020-03-12 22:37:46 -07:00
Jeff Trull ec0c8c8603 Implement C++20 features (#75)
* Introduce support for C++20 preprocessor features

- add __VA_OPT__ feature to variadic macros
- allow supplying 0 variadic arguments in more cases
- add related unit tests
2020-03-06 11:48:50 -08:00
Peter Dimov 5891614e84 Add quick.cpp test 2018-10-24 17:16:41 +03:00
Robert Lenhardt e3680846ce fix utf8 testcases on non-windows systems 2018-10-06 12:41:23 +02:00
Robert Lenhardt 231aad085f add tests for utf-8 paths 2018-10-04 17:40:21 +02:00
Peter Dimov 4386cce02e Add test/Jamfile 2017-11-28 23:40:30 +02:00
Jeff Trull c74492a208 Remove inadvertent newline from end of test file
Also tweak generated file to reflect source and avoid future speed bumps
2017-11-28 05:37:16 -08:00
Jeff Trull 1fde04d215 Repair C++11 raw string literal lexing, support custom delimiters, add tests 2017-11-27 19:26:11 -08:00
Hartmut Kaiser 10110a16b9 Fixing failing test on systems where BOOST_WAVE_SUPPORT_MS_EXTENSIONS is not defined 2017-10-19 16:23:19 -05:00
Abel Sinkovics 358a0e9668 Fix including header file without newline at the end 2017-09-18 22:25:52 +02:00
Abel Sinkovics 972461234d Fix reporting missing #endif when there is no new line after #if or #else 2017-09-18 22:02:57 +02:00
Abel Sinkovics a53b51e440 Fix #line directive without new line at the end of a file 2017-09-17 15:35:37 +02:00