Commit Graph

69 Commits

Author SHA1 Message Date
acqn 0063f73f8a Fixed __FILE__ and __LINE__ macros for preprocessor. 2022-07-24 23:19:05 +08:00
acqn 624e5025b0 Fixed parsing wide char constants. 2022-08-17 22:28:00 +08:00
acqn 5cca1e8b1d Fixed parsing numeric constants. 2022-08-11 10:55:16 +08:00
acqn 4bb4f033ea Fixed the bug that C keywords were not simply recognized as identifiers in preprocessing. 2022-08-07 16:14:45 +08:00
acqn 7a139a800e Added # and ## as punctuators recognized by the tokenizer.
Reorganized the token enum.
2022-08-06 18:45:49 +08:00
acqn 251e984ba8 Fixed error recovery with preprocessing directives failures. 2022-08-05 14:03:51 +08:00
acqn 60c1290468 Fixed the bug that preprocessor could run past the end of included files.
Fixed the wrong filename and 0 line number in disgnostics when a preprocessor error occurred at the end of a file.
Fixed diagnostics for missing #endif.
2022-07-26 21:10:26 +08:00
Jesse Rosenstock 3df6c383c0 Add support for static_assert
Add C11's _Static_assert and static_assert macro.

This is like #error, but is handled at a later stage
of translation, so it is possible to check sizes of
types, values of enums, etc.

https://en.cppreference.com/w/c/language/_Static_assert
https://port70.net/~nsz/c/c11/n1570.html#6.7.10
2020-07-30 19:17:11 +02:00
acqn 727040d1ac Comment fix. 2020-07-12 12:35:42 +02:00
acqn 7d652d42dc Added a warning on promoting a decimal constant without a 'u'/'U' suffix to unsigned long. 2020-07-12 12:35:42 +02:00
Lauri Kasanen 925ea9d544 cc65: Add support for binary literals
Binary literals, 0b001, are a GCC extension in C and a C++14 feature.
2019-07-20 17:21:42 +02:00
Greg King a6b04f6e97 Changed most "backticks" (grave accents) into apostrophes.
Quotations that are embraced by tick marks now look better, in most fonts.
2019-01-05 14:57:12 -05:00
Greg King 31461aaf02 Made cc65's "Illegal escaped character" diagnostic show which code was escaped. 2018-08-21 08:58:21 -04:00
Greg King a76dcdc419 Removed the compiler's recovery code for illegal escaped characters.
It caused the error cascade that it was supposed to prevent.
2018-08-20 17:51:22 -04:00
Alan Cox e4aee2ba34 cc65: remove un-needed logic from octal parsing
We no longer need the extra error handling logic for octal parsing so simplify
it as requested by Greg King.

Signed-off-by: Alan Cox <etchedpixels@gmail.com>
2016-11-20 18:02:45 +00:00
Alan Cox 6ee1fd2a67 scanner: Correct handling of \0101
The C language has this oddity that octal constants are 3 bytes so the sequence
"\0101" is two bytes and well defined by the langage. cc65 currently misparses
this as a 1 byte octal code. Add a count to fix this.

Signed-off-by: Alan Cox <etchedpixels@gmail.com>
2016-11-19 13:02:19 +00:00
Greg King 0390c34e88 Changed multi-line C comments into another style.
The left side doesn't look unbalanced.
2014-06-30 16:51:07 -04:00
Oliver Schmidt 4185caf855 Normalized code. 2014-03-04 01:11:19 +01:00
Oliver Schmidt 85885001b1 Removed (pretty inconsistently used) tab chars from source code base. 2013-05-09 13:57:12 +02:00
Oliver Schmidt f8ffe4c605 Removed unused variable. 2013-05-02 14:55:17 +03:00
uz 54740da820 More preparations for an extension of the calling conventions.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4650 b7a2c559-68d2-44c3-8de9-860c34a00d81
2010-04-29 20:30:49 +00:00
uz 4299e2db05 Added the cdecl keyword
git-svn-id: svn://svn.cc65.org/cc65/trunk@4639 b7a2c559-68d2-44c3-8de9-860c34a00d81
2010-04-09 19:47:33 +00:00
uz 3976746735 Rewrote literal handling. Literals are now saved together with other function
data, and at the end of compilation merged if possible. Literals for unused
functions are removed together with the function.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4501 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-12-05 22:39:45 +00:00
uz 9b7c16ec4c Fixed problem with last change. Wide string constants were not handled
correctly.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4500 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-12-05 15:14:11 +00:00
uz 50ff6d0768 Create one literal pool per function, so that literal pool data is removed
together with a function, if it is not used. Literal storage can now be
controlled by #pragma writable-strings on a per function basis.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4499 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-12-04 14:12:25 +00:00
uz 85f96a7d6f Fixed warnings generated by clang (run by Per Olofsson).
git-svn-id: svn://svn.cc65.org/cc65/trunk@4255 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-09-28 15:59:18 +00:00
uz b5db4cd5fa Added wide char literals, but treat them identical as normal strings.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4185 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-09-18 14:28:52 +00:00
uz 0b4f6426e2 Some more floating point support.
git-svn-id: svn://svn.cc65.org/cc65/trunk@3886 b7a2c559-68d2-44c3-8de9-860c34a00d81
2008-08-11 17:51:00 +00:00
cuz e5782fdc20 Allow an optional '+' sign before an exponent of a floating point constant.
git-svn-id: svn://svn.cc65.org/cc65/trunk@3827 b7a2c559-68d2-44c3-8de9-860c34a00d81
2008-03-31 21:17:27 +00:00
cuz 9174f65e54 Make much more usage of dynamic strings (StrBufs) instead of char* and
friends. Since names and other strings are now StrBufs in many places, code
for output had to be changed.
Added support for string literals to StrBuf.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3825 b7a2c559-68d2-44c3-8de9-860c34a00d81
2008-03-31 20:54:45 +00:00
cuz f196e7c5c9 Cleanup. Added a few general purpose functions.
git-svn-id: svn://svn.cc65.org/cc65/trunk@3710 b7a2c559-68d2-44c3-8de9-860c34a00d81
2006-02-19 15:53:11 +00:00
cuz 31d99b4a9f Added the inline keyword
git-svn-id: svn://svn.cc65.org/cc65/trunk@3707 b7a2c559-68d2-44c3-8de9-860c34a00d81
2006-02-17 20:27:51 +00:00
cuz 0e0183020d Fixed a escape char const problem
git-svn-id: svn://svn.cc65.org/cc65/trunk@3235 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-10-09 14:32:27 +00:00
cuz 06b57e6e7e Introduce a -E flag that activates just the preprocessor.
Use variable sized string buffers for input and macro processing instead
of the fixed buffers used before.
Many changes in the preprocessor to make it more standards compliant (which
it is still not).


git-svn-id: svn://svn.cc65.org/cc65/trunk@3182 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-09-16 12:42:41 +00:00
cuz 31f85bc23e Renaming and cleanup
git-svn-id: svn://svn.cc65.org/cc65/trunk@3137 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-06-29 20:37:18 +00:00
cuz b2b7006939 Fixed a problem
git-svn-id: svn://svn.cc65.org/cc65/trunk@3134 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-06-21 22:30:07 +00:00
cuz 13a2927e17 The -A and --ansi switches are gone, together with the __STRICT_ANSI__
predefined macro. Instead there is now a command line option --standard that
allows to set c89, c99 or cc65 as language standard. The compiler defines a
macro __CC65_STD__ that is one of __CC65_STD_C89__, __CC65_STD_C99__ or
__CC65_STD_CC65__ depending on the command line option. Default is cc65 (all
extensions) as before.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3133 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-06-21 22:22:11 +00:00
cuz 71ed8810c3 Minor change
git-svn-id: svn://svn.cc65.org/cc65/trunk@3109 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-06-06 18:36:08 +00:00
cuz f500a641c5 Added support for floating point constants in the scanner and Primary()
git-svn-id: svn://svn.cc65.org/cc65/trunk@3108 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-06-06 15:59:44 +00:00
cuz 04ccfdd660 Added missing 'simple escape sequences'
git-svn-id: svn://svn.cc65.org/cc65/trunk@2894 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-03-02 19:42:19 +00:00
cuz e6568c9763 Some octal character constants were not working.
The vertical tab '\v' character constant was not accepted.
Added some error recovery in case of illegal character constants.


git-svn-id: svn://svn.cc65.org/cc65/trunk@2425 b7a2c559-68d2-44c3-8de9-860c34a00d81
2003-08-29 09:16:05 +00:00
cuz 7596da75f0 Fixed an internal compiler error when the first token of a source file
caused an error message. In this case, the line info was not available
leading to a PRECONDITION VIOLATED.


git-svn-id: svn://svn.cc65.org/cc65/trunk@2370 b7a2c559-68d2-44c3-8de9-860c34a00d81
2003-08-19 20:30:55 +00:00
cuz 92dfde6c4e Order of keywords on the keyword table was wrong
git-svn-id: svn://svn.cc65.org/cc65/trunk@2240 b7a2c559-68d2-44c3-8de9-860c34a00d81
2003-08-02 10:07:00 +00:00
cuz f7dfcbcc3d Fixed a bug
git-svn-id: svn://svn.cc65.org/cc65/trunk@2239 b7a2c559-68d2-44c3-8de9-860c34a00d81
2003-08-02 09:55:54 +00:00
cuz f08179d6af Added the near keyword
git-svn-id: svn://svn.cc65.org/cc65/trunk@2237 b7a2c559-68d2-44c3-8de9-860c34a00d81
2003-08-01 21:38:54 +00:00
cuz 6766f4a2c1 Octal character constants starting with '2' or '3' did not work.
git-svn-id: svn://svn.cc65.org/cc65/trunk@2225 b7a2c559-68d2-44c3-8de9-860c34a00d81
2003-06-27 08:10:08 +00:00
cuz 0a1266e59b Added the restrict keyword just to have it reserved
git-svn-id: svn://svn.cc65.org/cc65/trunk@2153 b7a2c559-68d2-44c3-8de9-860c34a00d81
2003-05-07 21:06:42 +00:00
cuz d92676ef60 Add SB_GetNumber to scanstrbuf.c.
Rewrite of CharMapPragma in pragma.c
Fixed bug in scanner.c: Invalid octal constants containing the numbers 8
and 9 were accepted by the compiler.
Moved SignExtendChar from scanner.c to datatype.c.


git-svn-id: svn://svn.cc65.org/cc65/trunk@1416 b7a2c559-68d2-44c3-8de9-860c34a00d81
2002-09-30 18:46:08 +00:00
cuz ea50befaac Redoing the pragma stuff
git-svn-id: svn://svn.cc65.org/cc65/trunk@1413 b7a2c559-68d2-44c3-8de9-860c34a00d81
2002-09-29 21:09:47 +00:00
cuz 6676e27032 Cosmetic changes
git-svn-id: svn://svn.cc65.org/cc65/trunk@1402 b7a2c559-68d2-44c3-8de9-860c34a00d81
2002-09-23 21:37:01 +00:00