rillig
abc3274d3a
indent: merge lexer symbols for type in/outside parentheses
2023-06-16 23:51:31 +00:00
rillig
7983032213
indent: fix indentation and linebreaks in typedef declarations
2023-06-16 12:30:45 +00:00
rillig
8535e877f0
indent: don't force a blank line between '}' and preprocessing line
2023-06-16 11:48:32 +00:00
rillig
37a177106a
indent: rename a field of the parser state
...
The previous name 'comment_in_first_line' was misleading, as it could
mean that there was a comment in the first line of the file.
No functional change.
2023-06-16 11:27:49 +00:00
rillig
5a6a9cd4c2
indent: rename state variable to be more accurate
...
No binary change.
2023-06-15 10:59:06 +00:00
rillig
940b85009c
indent: clean up the code, add a few tests
2023-06-14 20:46:08 +00:00
rillig
cdfe968337
indent: allow more than 128 brace levels
2023-06-14 19:05:40 +00:00
rillig
d0e2347d25
indent: clean up array indexing for parser symbols
...
With 'top' pointing to the actual top element, the array was indexed in
the closed range from 0 to top. All other arrays are indexed by the
usual half-open interval from 0 to len.
No functional change.
2023-06-14 16:14:30 +00:00
rillig
641fe74526
indent: allow more than 20 nested parentheses or brackets
2023-06-14 14:11:28 +00:00
rillig
b520fe89c4
indent: clean up debugging code
2023-06-14 09:57:02 +00:00
rillig
ed7b435925
indent: clean up handling of comments
...
One less moving part in the parser state.
No functional change.
2023-06-14 09:31:05 +00:00
rillig
bf8496de58
indent: remove another flag from parser state
...
When processing a comment, the flag ps.next_col_1 was not used for the
next token, but for a line within a comment. As its scope was limited
to a single comment, there is no need to store it any longer than that
No functional change.
2023-06-14 08:36:51 +00:00
rillig
61c5d6b6d0
indent: remove a redundant flag from the parser state
...
No functional change.
2023-06-14 08:25:15 +00:00
rillig
b2fe5a24a1
indent: merge parser symbols for stmt and stmt_list
...
They were handled in exactly the same way.
2023-06-14 07:20:54 +00:00
rillig
4e81574b54
indent: rename misleading variable
...
The name started with 'line_start', but the value is not always the
value from the beginning of the line.
No functional change.
2023-06-10 21:36:38 +00:00
rillig
b3bf029a38
indent: miscellaneous cleanups
2023-06-10 16:43:55 +00:00
rillig
9e1c17039c
indent: in debug mode, null-terminate buffers
2023-06-10 12:59:31 +00:00
rillig
645d5d2282
indent: clean up function and variable names
2023-06-10 07:42:41 +00:00
rillig
338e471fd4
indent: rename and sort variables in parser state
...
No functional change.
2023-06-10 06:38:20 +00:00
rillig
d3be4ec43d
indent: trim trailing blank lines
2023-06-09 22:01:26 +00:00
rillig
028546bebe
indent: group lexer symbols by topic, sort processing functions
...
No functional change.
2023-06-09 16:23:43 +00:00
rillig
ae40ebbc6b
indent: don't treat function call expressions as cast expressions
2023-06-09 10:24:55 +00:00
rillig
eace873087
indent: when an indentation is ambiguous, indent one level further
...
The '-eei' mode now applies whenever the indentation from a multi-line
expression could be confused with a following statement.
2023-06-09 08:10:58 +00:00
rillig
7171fe25bf
indent: remove fragile heuristic for detecting cast expressions
...
The assumption that in an expression of the form '(a * anything)', the
'*' marks a pointer type was too simple-minded.
For now, fix the obvious cases and leave the others for later. If
needed, they can be worked around using the '-T' option.
2023-06-08 21:18:54 +00:00
rillig
41e7f68d7c
indent: clean up and condense code
...
No functional change.
2023-06-08 06:47:13 +00:00
rillig
6c5bd11166
indent: extract the stack of parser symbols to a separate struct
...
No functional change.
2023-06-07 15:46:11 +00:00
rillig
6da4319099
indent: compute indentation of 'case' labels on-demand
...
One less moving part to keep track of.
No functional change.
2023-06-06 04:37:26 +00:00
rillig
2a46ceff01
indent: sync debug output with parser state
2023-06-05 14:22:26 +00:00
rillig
db0819f4a8
indent: format own source code
2023-06-05 12:05:01 +00:00
rillig
24133b796d
indent: do not report broken lines, report configuration on stderr
2023-06-05 10:12:21 +00:00
rillig
d38f57a8f4
indent: rename variables, clean up comments
...
No binary change.
2023-06-05 07:35:05 +00:00
rillig
c6e9afe1fe
indent: remove read pointer from buffers that don't need it
...
The only buffer that needs a read pointer is the current input line in
'inp'.
No functional change.
2023-06-04 20:51:19 +00:00
rillig
43575e856b
indent: track the kind of '{' on the parser stack
2023-06-04 17:54:11 +00:00
rillig
30b1a48b2e
indent: fix debug output of the parser symbol stack
...
Even though the stack always contains a stmt_list as first element,
print it nevertheless to avoid confusion about starting at index 1, and
to provide the full picture.
2023-06-04 17:02:06 +00:00
rillig
43aa4f997a
indent: rename struct field, for better symmetry
...
No binary change outside debug mode.
2023-06-04 14:20:00 +00:00
rillig
08090a1872
lint: use separate lexer symbols for 'case' and 'default'
...
It's not strictly necessary since these tokens behave in the same way,
still, the code is more straight-forward when there are separate tokens.
2023-06-04 12:46:57 +00:00
rillig
27051cd2e2
indent: classify 'inline' as a modifier rather than a word
2023-06-04 11:45:00 +00:00
rillig
3debcfbfeb
indent: use separate lexer symbols for the different kinds of ':'
2023-06-04 11:33:36 +00:00
rillig
7ce3890df1
indent: handle the indentation of 'case' in a simpler way
2023-06-04 11:09:18 +00:00
rillig
5f827f27db
indent: separate code for handling parentheses and brackets
...
Handling parentheses is more complicated than for brackets.
2023-06-04 10:23:36 +00:00
rillig
6fc430af5c
indent: improve heuristics of classifying '*' as pointer or operator
2023-06-02 14:21:55 +00:00
rillig
ef25c88e9b
indent: clean up
...
Only print the 'token' buffer in debug mode if it is interesting, group
the blocks in handling of '(' tokens by topic, remove obsolete comment
from test.
2023-06-02 13:59:33 +00:00
rillig
a565c86f6c
indent: fix formatting of declarations with preprocessing lines
2023-06-02 11:43:07 +00:00
rillig
fe5b389b2f
indent: split debug output into paragraphs
...
The paragraphs separate the different processing steps: getting a token
from the lexer, processing the token, updating the parser state, sending
a finished line to the output.
2023-05-23 12:12:29 +00:00
rillig
756425c686
indent: fix spacing in declarations in for loops
2023-05-23 06:35:01 +00:00
rillig
b95ee04d96
indent: implement suppressing optional blank lines
2023-05-22 10:28:59 +00:00
rillig
4fb425a29f
indent: extract the output state from the parser state
...
The parser state depends on the preprocessing lines, the output state
shouldn't.
2023-05-20 11:53:53 +00:00
rillig
5a9a628018
indent: implement blank line above block comment
2023-05-20 11:19:17 +00:00
rillig
1764a17f2c
indent: implement blank line after function body
2023-05-20 10:46:21 +00:00
rillig
4d19140d48
indent: implement blank lines around conditional compilation
2023-05-20 10:09:02 +00:00