Showing preview only (1,338K chars total). Download the full file or copy to clipboard to get everything.
Repository: vickenty/lang-c
Branch: master
Commit: d5eb149612a4
Files: 164
Total size: 1.2 MB
Directory structure:
gitextract_k8z0_aj5/
├── .github/
│ └── workflows/
│ └── ci.yml
├── .gitignore
├── Cargo.toml
├── LICENSE-APACHE
├── LICENSE-MIT
├── Makefile
├── README.md
├── grammar.header
├── grammar.rustfmt
├── grammar.rustpeg
├── reftests/
│ ├── constant-322.c
│ ├── constant-323.c
│ ├── constant-324.c
│ ├── constant-328.c
│ ├── constant-332.c
│ ├── constant-336.c
│ ├── constant-340.c
│ ├── constant-341.c
│ ├── constant-342.c
│ ├── constant-344.c
│ ├── constant-345.c
│ ├── constant-346.c
│ ├── constant-347.c
│ ├── constant-348.c
│ ├── constant-349.c
│ ├── constant-370.c
│ ├── constant-371.c
│ ├── constant-375.c
│ ├── constant-376.c
│ ├── constant-380.c
│ ├── constant-381.c
│ ├── constant-383.c
│ ├── constant-387.c
│ ├── constant-391.c
│ ├── constant-395.c
│ ├── constant-400.c
│ ├── constant-404.c
│ ├── constant-408.c
│ ├── constant-412.c
│ ├── constant-442.c
│ ├── constant-446.c
│ ├── constant-458.c
│ ├── constant-459.c
│ ├── constant-460.c
│ ├── constant-461.c
│ ├── constant-462.c
│ ├── constant-463.c
│ ├── constant-464.c
│ ├── constant-465.c
│ ├── constant-466.c
│ ├── declaration-1080.c
│ ├── declaration-1443.c
│ ├── declaration-1610.c
│ ├── declaration-1847.c
│ ├── declaration-2243.c
│ ├── declaration-2321.c
│ ├── declaration-2429.c
│ ├── declaration-2477.c
│ ├── declaration-2508.c
│ ├── declaration-2512.c
│ ├── declaration-2594.c
│ ├── declaration-31-field-semicolon.c
│ ├── declaration-31-ty-attr1.c
│ ├── declaration-31-ty-attr2.c
│ ├── declaration-31-ty-attr3.c
│ ├── declaration-659.c
│ ├── declaration-714.c
│ ├── declaration-760.c
│ ├── declaration-837.c
│ ├── declaration-855.c
│ ├── declaration-880.c
│ ├── declaration-983.c
│ ├── declaration-block-2.c
│ ├── declaration-block-3.c
│ ├── declaration-block-4.c
│ ├── declaration-block-5.c
│ ├── declaration-block.c
│ ├── declaration-enum-attr.c
│ ├── declaration-ptr-attr1.c
│ ├── declaration-ptr-attr2.c
│ ├── declaration-ptr-attr3.c
│ ├── declaration-struct.c
│ ├── declaration-typedef.c
│ ├── expression-1295.c
│ ├── expression-1307.c
│ ├── expression-1319.c
│ ├── expression-1338.c
│ ├── expression-1370.c
│ ├── expression-1523.c
│ ├── expression-1595.c
│ ├── expression-2224.c
│ ├── expression-2229.c
│ ├── expression-2234.c
│ ├── expression-2546.c
│ ├── expression-475.c
│ ├── expression-476.c
│ ├── expression-477.c
│ ├── expression-478.c
│ ├── expression-491.c
│ ├── expression-495.c
│ ├── expression-517.c
│ ├── expression-538.c
│ ├── expression-551.c
│ ├── expression-567.c
│ ├── expression-583.c
│ ├── expression-599.c
│ ├── expression-616.c
│ ├── expression-617.c
│ ├── expression-632.c
│ ├── expression-645.c
│ ├── expression-ident-const.c
│ ├── expression-sizeof.c
│ ├── expression-string-1.c
│ ├── expression-string-2.c
│ ├── statement-1408.c
│ ├── statement-1650.c
│ ├── statement-2625.c
│ ├── statement-2669.c
│ ├── statement-case.c
│ ├── statement-case2.c
│ ├── statement-caserange.c
│ ├── statement-caserange2.c
│ ├── statement-caserange3.c
│ ├── statement-caserange4.c
│ ├── statement-caserange5.c
│ ├── statement-default.c
│ ├── statement-label.c
│ ├── translation_unit-1183.c
│ ├── translation_unit-1388.c
│ ├── translation_unit-1692.c
│ ├── translation_unit-1781.c
│ ├── translation_unit-1961.c
│ ├── translation_unit-1993.c
│ ├── translation_unit-2015.c
│ ├── translation_unit-2029.c
│ ├── translation_unit-2045.c
│ ├── translation_unit-2060.c
│ ├── translation_unit-2070.c
│ ├── translation_unit-2086.c
│ ├── translation_unit-2103.c
│ ├── translation_unit-2114.c
│ ├── translation_unit-2129.c
│ ├── translation_unit-2147.c
│ ├── translation_unit-2167.c
│ ├── translation_unit-2190.c
│ ├── translation_unit-2208.c
│ ├── translation_unit-2270.c
│ ├── translation_unit-2300.c
│ ├── translation_unit-2373.c
│ └── translation_unit-31-semicolon.c
└── src/
├── ast.rs
├── astutil.rs
├── bin/
│ ├── dump.rs
│ └── meminfo.rs
├── driver.rs
├── env.rs
├── lib.rs
├── loc.rs
├── parser.rs
├── print.rs
├── span.rs
├── strings.rs
├── tests.rs
└── visit.rs
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/workflows/ci.yml
================================================
on:
push:
pull_request:
schedule: [cron: "40 6 10 1/2 *"]
name: Tests
jobs:
test:
name: test
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
- nightly
- 1.4.0
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- uses: actions-rs/cargo@v1
with:
command: test
================================================
FILE: .gitignore
================================================
/Cargo.lock
/target/
**/*.rs.bk
================================================
FILE: Cargo.toml
================================================
[package]
name = "lang-c"
version = "0.15.1"
authors = ["Vickenty Fesunov <kent@setattr.net>"]
license = "MIT/Apache-2.0"
description = "Lightweight C parser"
include = [ "/src/**/*.rs", "Cargo.toml", "/LICENSE*", "/README.md" ]
documentation = "https://docs.rs/lang-c"
homepage = "https://github.com/vickenty/lang-c"
repository = "https://github.com/vickenty/lang-c"
keywords = [ "ast", "c", "parser", "c-language" ]
categories = [ "parser-implementations" ]
[features]
dev-pegviz = [] # tests only: emit extra output for pegviz
================================================
FILE: LICENSE-APACHE
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
================================================
FILE: LICENSE-MIT
================================================
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
================================================
FILE: Makefile
================================================
.PHONY: all lib
peg?=rust-peg
all: src/parser.rs
cargo b --lib --features '$(features)'
cargo t --features '$(features)'
trace:
rm -f src/parser.rs
make peg=rust-peg-trace features=dev-pegviz
.INTERMEDIATE: src/parser.rs.raw src/parser.rs.fmt
src/parser.rs.raw: grammar.rustpeg grammar.rustfmt grammar.header
$(peg) $< > $@
src/parser.rs.fmt: src/parser.rs.raw
rustfmt --config-path grammar.rustfmt < $< > $@
src/parser.rs: src/parser.rs.fmt
cat grammar.header $< > $@
check:
test src/parser.rs -nt grammar.rustpeg
================================================
FILE: README.md
================================================
# Lang-C
[](https://docs.rs/lang-c)
Ligtweight parser of C language for Rust users. Almost full support for C11 revision of the language.
Several GCC and Clang extensions are also supported as an option.
```rust
extern crate lang_c;
use lang_c::driver::{Config, parse};
fn main() {
let config = Config::default();
println!("{:?}", parse(&config, "example.c"));
}
```
# Bugs
Just open an issue, bug reports and patches are most welcome.
## License
Dual-licenced under Apache 2.0 or MIT licenses (see `LICENSE-APACHE` and `LICENSE-MIT` for legal terms).
## Development
A number of external tools are used during development:
- GNU make
- rustfmt
- [rust-peg](https://github.com/kevinmehall/rust-peg) 0.5.4
Parser (`src/parser.rs`) is built from a PEG grammar in `grammar.rustpeg`. It is updated manually and then
committed, not generated on every build, thus no `rust-peg` in the list of dependencies.
For debugging purposes, it is handy to have a version rust-peg built with tracing enabled.
A makefile is used to script the development process:
- `make` update parser, build the library and run the tests;
- `make trace` rebuilds parser using `rust-peg-trace`, which is expected to be a version of `rust-peg` command with `trace` feature enabled
- `make check` can be used as pre-commit git hook to make sure parser is up to date
================================================
FILE: grammar.header
================================================
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unknown_lints)]
#![allow(ellipsis_inclusive_range_patterns)]
================================================
FILE: grammar.rustfmt
================================================
max_width = 10000
tab_spaces = 4
================================================
FILE: grammar.rustpeg
================================================
// Written for peg 0.5.4
#![arguments(env: &mut Env)]
use ast::*;
use astutil::*;
use env::{Env, Symbol};
use span::{Node, Span};
////
// Prologue
////
box<ex> = e:ex { Box::new(e) }
node<ex> = l:#position e:ex r:#position { Node::new(e, Span::span(l, r)) }
// Lists of elements.
list0<ex> = e:ex ** _ { e }
list1<ex> = e:ex ++ _ { e }
cs0<ex> = e:ex ** (_ "," _) { e }
cs1<ex> = e:ex ++ (_ "," _) { e }
// A list containing 0+ before's, 1 single, and 0+ after's.
list_010<before, single, after> =
before:list0<before> _ single:single _ after:list0<after> {
let mut before = before;
before.push(single);
before.extend(after);
before
}
// A list containing *exactly* one element of a, and any of b.
list_eq1_n<a, b> = list_010<b, a, b>
// A list containing *at least* one element of a, and any of b.
list_ge1_n<a, b> = list_010<b, a, a / b>
////
// Whitespace
////
_ = #quiet<("\r"? "\n" directive? / [ \t])*>
directive = "#" [^\n]*
////
// 6.4.1 Keywords
////
K<E> = #quiet<e:E ![_a-zA-Z0-9] { e }>
////
// 6.4.2 Identifiers
////
// Identifiers.
identifier -> Node<Identifier> = node<identifier0>
identifier0 -> Identifier =
n:$([_a-zA-Z] [_a-zA-Z0-9]*) {?
if !env.reserved.contains(n) {
Ok(Identifier {
name: n.into(),
})
} else {
Err("identifier")
}
}
////
// 6.4.3 Universal character names
////
// TODO
////
// 6.4.4 Constants
////
ohx = "0" [xX]
obb = "0" [bB]
dec = [0-9]
oct = [0-7]
hex = [0-9a-fA-F]
bin = [0-1]
pub constant -> Constant =
&[0-9.] c:numeric_constant { c } /
&['uUL] c:character_constant { Constant::Character(c) }
numeric_constant -> Constant =
c:float_constant { Constant::Float(c) } /
c:integer_constant { Constant::Integer(c) }
integer_constant -> Integer =
n:integer_number suffix:integer_suffix {
let (base, number) = n;
Integer {
base: base,
number: number.to_owned().into_boxed_str(),
suffix: suffix,
}
}
integer_number -> (IntegerBase, &'input str) =
n:$([1-9] dec*) { (IntegerBase::Decimal, n) } /
ohx n:$(hex+) { (IntegerBase::Hexadecimal, n) } /
"0" n:$(oct+) { (IntegerBase::Octal, n) } /
gnu<obb n:$(bin+) { (IntegerBase::Binary, n) }> /
n:$("0") { (IntegerBase::Decimal, n) }
integer_suffix -> IntegerSuffix =
#quiet<integer_suffix_inner> / #expected("integer suffix")
integer_suffix_inner -> IntegerSuffix =
s:$(([uUlL] / gnu<[iIjJ]>)*) {? int_suffix(s) }
float_constant -> Float =
n:float_number suffix:float_suffix {
let (base, number) = n;
Float {
base: base,
number: number.to_string().into_boxed_str(),
suffix: suffix,
}
}
float_number -> (FloatBase, &'input str) =
n:$(float_decimal) { (FloatBase::Decimal, n) } /
ohx n:$(float_hexadecimal) { (FloatBase::Hexadecimal, n) }
float_decimal =
dec* "." dec+ float_decimal_exp? /
dec+ "." float_decimal_exp? /
dec+ float_decimal_exp
float_decimal_exp = [eE][+-]?dec+
float_hexadecimal =
hex* "." hex+ float_binary_exp /
hex+ "." float_binary_exp /
hex+ float_binary_exp
float_binary_exp = [pP][+-]?dec+
float_suffix -> FloatSuffix = #quiet<float_suffix_inner> / #expected("float literal suffix")
float_suffix_inner -> FloatSuffix =
gnu<[iIjJ]> fmt:float_format {
FloatSuffix {
format: fmt,
imaginary: true,
}
} /
fmt:float_format imag:gnu<[iIjJ]>? {
FloatSuffix {
format: fmt,
imaginary: imag.is_some(),
}
}
float_format -> FloatFormat =
f:ts18661_float_suffix { FloatFormat::TS18661Format(f) } /
[fF] { FloatFormat::Float } /
[lL] { FloatFormat::LongDouble } /
{ FloatFormat::Double }
character_constant -> String =
c:$([LuU]? "'" character+ "'") { String::from(c) }
character = [^'\\\n] / escape_sequence
escape_sequence = "\\" (['"?\\abfnrtv] / oct*<1,3> / "x" hex+)
////
// 6.4.5 String literal
////
pub string_literal -> Node<Vec<String>> = s:node<list1<string_literal0>> { s }
string_literal0 -> String =
s:$(encoding_prefix? "\"" string_char* "\"") { String::from(s) }
encoding_prefix = "u8" / [uUL]
string_char = [^"\\\n] / escape_sequence
////
// 6.5.1 Primary expression
////
primary_expression -> Box<Node<Expression>> = box<node<primary_expression0>>
primary_expression0 -> Expression =
a:string_literal { Expression::StringLiteral(Box::new(a)) } /
a:node<constant> { Expression::Constant(Box::new(a)) } /
a:identifier { Expression::Identifier(Box::new(a)) } /
"(" _ a:expression0 _ ")" { a } /
a:node<generic_selection> { Expression::GenericSelection(Box::new(a)) } /
gnu<gnu_primary_expression>
generic_selection -> GenericSelection =
K<"_Generic"> _ "(" _ e:assignment_expression _ "," _ a:cs1<node<generic_association>> _ ")" {
GenericSelection {
expression: e,
associations: a,
}
}
generic_association -> GenericAssociation =
t:type_name _ ":" _ e:assignment_expression {
let span = Span::span(t.span.start, e.span.end);
GenericAssociation::Type(Node::new(GenericAssociationType {
type_name: t,
expression: e,
}, span))
} /
K<"default"> _ ":" _ e:assignment_expression {
GenericAssociation::Default(e)
}
//// 6.5.2 Postfix operators
postfix_expression -> Box<Node<Expression>> = box<node<postfix_expression0>>
#[cache]
postfix_expression0 -> Expression =
e:node<postfix_expression1> _ t:list0<node<postfix_expressionT>> { apply_ops(t, e).node }
postfix_expression1 -> Expression =
compound_literal /
primary_expression0
postfix_expressionT -> Operation =
index_operator /
"(" _ e:cs0<node<assignment_expression0>> _ ")" { Operation::Call(e) } /
o:node<member_operator> _ i:identifier { Operation::Member(o, i) } /
o:node<postfix_operator> { Operation::Unary(o) }
index_operator -> Operation =
i:node<index_operator0> { Operation::Binary(Node::new(BinaryOperator::Index, i.span), i.node) }
index_operator0 -> Node<Expression> =
"[" _ e:node<expression0> _ "]" { e }
member_operator -> MemberOperator =
"." { MemberOperator::Direct } /
"->" { MemberOperator::Indirect }
postfix_operator -> UnaryOperator =
"++" { UnaryOperator::PostIncrement } /
"--" { UnaryOperator::PostDecrement }
compound_literal -> Expression =
n:node<compound_literal_inner> { Expression::CompoundLiteral(Box::new(n)) }
compound_literal_inner -> CompoundLiteral =
"(" _ t:type_name _ ")" _ "{" _ i:cs1<node<initializer_list_item>> _ ","? _ "}" {
CompoundLiteral {
type_name: t,
initializer_list: i,
}
}
////
// 6.5.3 Unary operators
////
unary_expression -> Box<Node<Expression>> = box<node<unary_expression0>>
unary_expression0 -> Expression =
postfix_expression0 /
unary_prefix /
unary_cast /
sizeof_expression /
alignof_expression /
gnu<K<"__extension__">> _ e:unary_expression0 { e }
unary_prefix -> Expression =
n:node<unary_prefix_inner> { Expression::UnaryOperator(Box::new(n)) }
unary_prefix_inner -> UnaryOperatorExpression =
op:node<prefix_operator> _ e:unary_expression {
UnaryOperatorExpression {
operator: op,
operand: e,
}
}
prefix_operator -> UnaryOperator =
"++" { UnaryOperator::PreIncrement } /
"--" { UnaryOperator::PreDecrement }
unary_cast -> Expression =
n:node<unary_cast_inner> { Expression::UnaryOperator(Box::new(n)) }
unary_cast_inner -> UnaryOperatorExpression =
op:node<unary_operator> _ e:cast_expression {
UnaryOperatorExpression {
operator: op,
operand: e,
}
}
unary_operator -> UnaryOperator =
"&"!"&" { UnaryOperator::Address } /
"*" { UnaryOperator::Indirection } /
"+" { UnaryOperator::Plus } /
"-" { UnaryOperator::Minus } /
"~" { UnaryOperator::Complement } /
"!" { UnaryOperator::Negate }
sizeof_expression -> Expression =
n:sizeof_ty_expression { Expression::SizeOfTy(n) } /
n:sizeof_val_expression { Expression::SizeOfVal(n) }
sizeof_ty_expression -> Box<Node<SizeOfTy>> = box<node<sizeof_ty_expression0>>
sizeof_ty_expression0 -> SizeOfTy =
K<"sizeof"> _ "(" _ t:type_name _ ")" {
SizeOfTy(t)
}
sizeof_val_expression -> Box<Node<SizeOfVal>> = box<node<sizeof_val_expression0>>
sizeof_val_expression0 -> SizeOfVal =
K<"sizeof"> _ e:unary_expression {
SizeOfVal(e)
}
alignof_expression -> Expression =
e:alignof { Expression::AlignOf(e) }
alignof -> Box<Node<AlignOf>> = box<node<alignof0>>
alignof0 -> AlignOf =
K<"_Alignof" / gnu<"__alignof" "__"?>> _ "(" _ t:type_name _ ")" {
AlignOf(Box::new(t))
}
////
// 6.5.4 Cast expressions
////
cast_expression -> Box<Node<Expression>> = box<node<cast_expression0>>
cast_expression0 -> Expression =
c:node<cast_expression_inner> { Expression::Cast(Box::new(c)) } /
unary_expression0
cast_expression_inner -> CastExpression =
"(" _ t:type_name _ ")" _ e:cast_expression {
CastExpression {
type_name: t,
expression: e,
}
}
////
// 6.5.5 -- 6.5.14 Binary operators
////
binary_expression -> Box<Node<Expression>> = box<binary_expression0>
binary_expression0 -> Node<Expression> = #infix<binary_operand> {
#L x o:infix<"||"> y { infix(o, BinaryOperator::LogicalOr, x, y) }
#L x o:infix<"&&"> y { infix(o, BinaryOperator::LogicalAnd, x, y) }
#L x o:infix<"|"> y { infix(o, BinaryOperator::BitwiseOr, x, y) }
#L x o:infix<"^"> y { infix(o, BinaryOperator::BitwiseXor, x, y) }
#L x o:infix<"&"!"&"> y { infix(o, BinaryOperator::BitwiseAnd, x, y) }
#L x o:infix<"=="> y { infix(o, BinaryOperator::Equals, x, y) }
x o:infix<"!="> y { infix(o, BinaryOperator::NotEquals, x, y) }
#L x o:infix<"<"> y { infix(o, BinaryOperator::Less, x, y) }
x o:infix<">"> y { infix(o, BinaryOperator::Greater, x, y) }
x o:infix<"<="> y { infix(o, BinaryOperator::LessOrEqual, x, y) }
x o:infix<">="> y { infix(o, BinaryOperator::GreaterOrEqual, x, y) }
#L x o:infix<"<<"> y { infix(o, BinaryOperator::ShiftLeft, x, y) }
x o:infix<">>"> y { infix(o, BinaryOperator::ShiftRight, x, y) }
#L x o:infix<"+"> y { infix(o, BinaryOperator::Plus, x, y) }
x o:infix<"-"> y { infix(o, BinaryOperator::Minus, x, y) }
#L x o:infix<"*"> y { infix(o, BinaryOperator::Multiply, x, y) }
x o:infix<"/"> y { infix(o, BinaryOperator::Divide, x, y) }
x o:infix<"%"> y { infix(o, BinaryOperator::Modulo, x, y) }
}
infix<ex> = _ n:node<ex> _ { n }
binary_operand -> Node<Expression> = node<cast_expression0>
////
// 6.5.15 Conditional operator
////
conditional_expression -> Box<Node<Expression>> = box<node<conditional_expression0>>
conditional_expression0 -> Expression =
a:binary_expression0 _ t:conditional_expressionT? {
if let Some((b, c)) = t {
let span = Span::span(a.span.start, c.span.end);
Expression::Conditional(Box::new(Node::new(ConditionalExpression {
condition: Box::new(a),
then_expression: b,
else_expression: c,
}, span)))
} else {
a.node
}
}
conditional_expressionT -> (Box<Node<Expression>>, Box<Node<Expression>>) =
"?" _ a:node<expression0> _ ":" _ b:node<conditional_expression0> { (Box::new(a), Box::new(b)) }
////
// 6.5.16 Assignment operators
////
assignment_expression -> Box<Node<Expression>> = box<node<assignment_expression0>>
assignment_expression0 -> Expression =
n:node<assignment_expression_inner> { Expression::BinaryOperator(Box::new(n)) } /
conditional_expression0
assignment_expression_inner -> BinaryOperatorExpression =
a:unary_expression _ op:node<assignment_operator> _ b:assignment_expression {
BinaryOperatorExpression {
operator: op,
lhs: a,
rhs: b,
}
}
assignment_operator -> BinaryOperator =
"=" { BinaryOperator::Assign } /
"*=" { BinaryOperator::AssignMultiply } /
"/=" { BinaryOperator::AssignDivide } /
"%=" { BinaryOperator::AssignModulo } /
"+=" { BinaryOperator::AssignPlus } /
"-=" { BinaryOperator::AssignMinus } /
"<<=" { BinaryOperator::AssignShiftLeft } /
">>=" { BinaryOperator::AssignShiftRight } /
"&=" { BinaryOperator::AssignBitwiseAnd } /
"^=" { BinaryOperator::AssignBitwiseXor } /
"|=" { BinaryOperator::AssignBitwiseOr }
////
// 6.5.17 Comma operator
////
pub expression -> Box<Node<Expression>> = box<node<expression0>>
expression0 -> Expression =
e:node<assignment_expression0> _ t:list0<expressionT> {
if t.len() > 0 {
let mut t = t;
t.insert(0, e);
Expression::Comma(Box::new(t))
} else {
e.node
}
}
expressionT -> Node<Expression> =
"," _ e:node<assignment_expression0> { e }
////
// 6.6 Constant expressions
////
constant_expression -> Box<Node<Expression>> = conditional_expression
constant_expression0 -> Expression = conditional_expression0
////
// 6.7 Declarations
////
pub declaration -> Node<Declaration> = node<declaration0>
declaration0 -> Declaration =
gnu<K<"__extension__">>? _ d:declaration1 _ ";" {
Declaration {
specifiers: d.0,
declarators: d.1,
}
}
declaration_seq<h, t> = h:h _ t:t { (concat(h, t.0), t.1) }
declaration1 -> (Vec<Node<DeclarationSpecifier>>, Vec<Node<InitDeclarator>>) =
declaration_seq<declaration_specifiers_unique, declaration2>
declaration2 -> (Vec<Node<DeclarationSpecifier>>, Vec<Node<InitDeclarator>>) =
declaration_seq<declaration_typedef, declaration_typedef_tail> /
declaration_seq<declaration_unique_type, declaration_tail<declaration_specifiers_unique>> /
declaration_seq<declaration_nonunique_type, declaration_tail<declaration_specifiers_nonunique>>
// What can follow a type specifier keyword or typename in a declaration
declaration_tail<s> = declaration_seq<s, declaration_tail1<s>>
declaration_tail1<s> =
declaration_seq<declaration_typedef, declaration_typedef_tail1<s>> /
d:declaration_init_declarators { (Vec::new(), d) }
// What can follow a typedef keyword
declaration_typedef_tail -> (Vec<Node<DeclarationSpecifier>>, Vec<Node<InitDeclarator>>) =
declaration_seq<declaration_specifiers_unique, declaration_typedef_tail0>
declaration_typedef_tail0 -> (Vec<Node<DeclarationSpecifier>>, Vec<Node<InitDeclarator>>) =
declaration_seq<declaration_unique_type, declaration_typedef_tail1<declaration_specifiers_unique>> /
declaration_seq<declaration_nonunique_type, declaration_typedef_tail1<declaration_specifiers_nonunique>>
// What can follow after typedef + type name
declaration_typedef_tail1<s> = s:s _ d:declaration_type_declarators { (s, d) }
declaration_unique_type -> Vec<Node<DeclarationSpecifier>> =
n:node<declaration_specifier_unique_type0> { vec![ n ] }
declaration_nonunique_type -> Vec<Node<DeclarationSpecifier>> =
n:node<declaration_specifier_nonunique_type0> { vec![ n ] }
declaration_specifiers -> Vec<Node<DeclarationSpecifier>> =
s:declaration_specifiers_unique _ t:declaration_specifiers_tail { concat(s, t) }
declaration_specifiers_tail -> Vec<Node<DeclarationSpecifier>> =
t:declaration_unique_type _ s:declaration_specifiers_unique { concat(t, s) } /
t:declaration_nonunique_type _ s:declaration_specifiers_nonunique { concat(t, s) }
declaration_specifiers_unique -> Vec<Node<DeclarationSpecifier>> =
list0<node<declaration_specifier_nontype>>
declaration_specifiers_nonunique -> Vec<Node<DeclarationSpecifier>> =
list0<node<declaration_specifier_nontype / declaration_specifier_nonunique_type0>>
declaration_specifier_nontype -> DeclarationSpecifier =
s:storage_class_specifier { DeclarationSpecifier::StorageClass(s) } /
s:type_qualifier { DeclarationSpecifier::TypeQualifier(s) } /
s:function_specifier { DeclarationSpecifier::Function(s) } /
s:alignment_specifier { DeclarationSpecifier::Alignment(s) } /
s:gnu<attribute_specifier> { DeclarationSpecifier::Extension(s) }
declaration_typedef -> Vec<Node<DeclarationSpecifier>> =
s:node<declaration_typedef0> { vec![ s ] }
declaration_typedef0 -> DeclarationSpecifier =
s:storage_class_typedef { DeclarationSpecifier::StorageClass(s) }
declaration_specifier_unique_type0 -> DeclarationSpecifier =
s:node<type_specifier_unique> { DeclarationSpecifier::TypeSpecifier(s) }
declaration_specifier_nonunique_type0 -> DeclarationSpecifier =
s:node<type_specifier_nonunique> { DeclarationSpecifier::TypeSpecifier(s) }
declaration_init_declarators -> Vec<Node<InitDeclarator>> = cs0<node<init_declarator>>
declaration_type_declarators -> Vec<Node<InitDeclarator>> = cs0<node<type_declarator>>
init_declarator -> InitDeclarator =
d:init_declarator_declarator _ e:gnu<init_declarator_gnu>? _ i:node<init_declarator_init>?
{
InitDeclarator {
declarator: with_ext(d, e),
initializer: i,
}
}
init_declarator_declarator -> Node<Declarator> =
d:declarator {
env.handle_declarator(&d, Symbol::Identifier);
d
}
init_declarator_init -> Initializer =
"=" _ i:initializer { i }
init_declarator_gnu -> Vec<Node<Extension>> =
l:asm_label? _ a:attribute_specifier_list { l.into_iter().chain(a).collect() }
type_declarator -> InitDeclarator =
d:declarator _ e:gnu<init_declarator_gnu>?
{
env.handle_declarator(&d, Symbol::Typename);
InitDeclarator {
declarator: with_ext(d, e),
initializer: None,
}
}
////
// 6.7.1 Storage-class specifiers
////
storage_class_specifier -> Node<StorageClassSpecifier> = node<storage_class_specifier0>
storage_class_specifier0 -> StorageClassSpecifier =
K<"extern"> { StorageClassSpecifier::Extern } /
K<"static"> { StorageClassSpecifier::Static } /
K<"_Thread_local"> { StorageClassSpecifier::ThreadLocal } /
K<"auto"> { StorageClassSpecifier::Auto } /
K<"register"> { StorageClassSpecifier::Register }
storage_class_typedef -> Node<StorageClassSpecifier> = node<storage_class_typedef0>
storage_class_typedef0 -> StorageClassSpecifier =
K<"typedef"> { StorageClassSpecifier::Typedef }
////
// 6.7.2 Type specifiers
////
// ISO 2011, 6.7.2, §2. Void, _Bool, _Atomic, typedef names, struct/unions, and enum
// specifiers can only appear once in declaration specifiers or specifier-qualifiers.
// This resolves the ambiguity with typedef names.
type_specifier_unique -> TypeSpecifier =
K<"void"> { TypeSpecifier::Void } /
K<"_Bool"> { TypeSpecifier::Bool } /
K<"_Atomic"> _ "(" _ t:type_name _ ")" { TypeSpecifier::Atomic(t) } /
s:node<struct_or_union_specifier> { TypeSpecifier::Struct(s) } /
e:node<enum_specifier> { TypeSpecifier::Enum(e) } /
t:typedef_name { TypeSpecifier::TypedefName(t) }
type_specifier_nonunique -> TypeSpecifier =
K<"char"> { TypeSpecifier::Char } /
K<"short"> { TypeSpecifier::Short } /
K<"int"> { TypeSpecifier::Int } /
K<"long"> { TypeSpecifier::Long } /
K<"float"> { TypeSpecifier::Float } /
K<"double"> { TypeSpecifier::Double } /
K<"signed" / gnu<"__signed" "__"?>> { TypeSpecifier::Signed } /
K<"unsigned"> { TypeSpecifier::Unsigned } /
K<"_Complex" / gnu<"__complex" "__"?>> { TypeSpecifier::Complex } /
t:K<ts18661_float_type_specifier> { TypeSpecifier::TS18661Float(t) } /
gnu<typeof_specifier>
struct_or_union_specifier -> StructType =
t:node<struct_or_union> _ i:identifier? _ d:struct_or_union_body {
StructType {
kind: t,
identifier: i,
declarations: d,
}
} /
t:node<struct_or_union> _ i:identifier {
StructType {
kind: t,
identifier: Some(i),
declarations: None,
}
}
struct_or_union_body -> Option<Vec<Node<StructDeclaration>>> =
"{" _ d:list1<node<struct_declaration>> _ "}" { Some(d) } /
gnu<"{" _ "}"> { Some(Vec::new()) } /
{ None }
struct_or_union -> StructKind =
K<"struct"> { StructKind::Struct } /
K<"union"> { StructKind::Union }
struct_declaration -> StructDeclaration =
f:node<struct_field> { StructDeclaration::Field(f) } /
s:static_assert { StructDeclaration::StaticAssert(s) } /
gnu<K<"__extension__">> _ d:struct_declaration { d }
struct_field -> StructField =
s:specifier_qualifiers _ d:cs0<node<struct_declarator>> _ ";" gnu<(_ ";")*>? {
StructField {
specifiers: s,
declarators: d,
}
}
specifier_qualifiers -> Vec<Node<SpecifierQualifier>> =
list_eq1_n<node<specifier_qualifier_unique_type0>, node<specifier_qualifier_qualifier0>> /
list_ge1_n<node<specifier_qualifier_nonunique_type0>, node<specifier_qualifier_qualifier0>>
specifier_qualifier_unique_type0 -> SpecifierQualifier =
s:node<type_specifier_unique> { SpecifierQualifier::TypeSpecifier(s) }
specifier_qualifier_nonunique_type0 -> SpecifierQualifier =
s:node<type_specifier_nonunique> { SpecifierQualifier::TypeSpecifier(s) }
specifier_qualifier_qualifier0 -> SpecifierQualifier =
q:type_qualifier { SpecifierQualifier::TypeQualifier(q) } /
e:gnu<attribute_specifier> { SpecifierQualifier::Extension(e) }
struct_declarator -> StructDeclarator =
d:declarator? _ ":" _ e:constant_expression a:gnu<attribute_specifier_list>? {
StructDeclarator {
declarator: d.map(|d| with_ext(d, a)),
bit_width: Some(e),
}
} /
d:declarator _ a:gnu<attribute_specifier_list>? {
StructDeclarator {
declarator: Some(with_ext(d, a)),
bit_width: None,
}
}
enum_specifier -> EnumType =
K<"enum"> _ i:identifier? _ "{" _ e:cs1<node<enumerator>> _ ","? _ "}" {
EnumType {
identifier: i,
enumerators: e,
}
} /
K<"enum"> _ i:identifier {
EnumType {
identifier: Some(i),
enumerators: Vec::new(),
}
}
enumerator -> Enumerator =
i:identifier _ a:gnu<attribute_specifier_list>? _ e:enumerator_constant? {
env.add_symbol(&i.node.name, Symbol::Identifier);
Enumerator {
identifier: i,
expression: e,
extensions: a.unwrap_or_default(),
}
}
enumerator_constant -> Box<Node<Expression>> =
"=" _ e:constant_expression { e }
////
// 6.7.3 Type qualifiers
////
type_qualifier -> Node<TypeQualifier> = node<type_qualifier0>
type_qualifier0 -> TypeQualifier =
K<"const" / gnu<"__const">> { TypeQualifier::Const } /
K<"restrict" / gnu<"__restrict" "__"?>> { TypeQualifier::Restrict } /
K<"volatile" / gnu<"__volatile" "__"?>> { TypeQualifier::Volatile } /
clang<K<"_Nonnull">> { TypeQualifier::Nonnull } /
clang<K<"_Null_unspecified">> { TypeQualifier::NullUnspecified } /
clang<K<"_Nullable">> { TypeQualifier::Nullable } /
// 6.7.2.4: _Atomics followed by a "(" are interpreted as type specifiers.
K<"_Atomic"> _ !"(" { TypeQualifier::Atomic }
////
// 6.7.4 Function specifiers
////
function_specifier -> Node<FunctionSpecifier> = node<function_specifier0>
function_specifier0 -> FunctionSpecifier =
K<"inline" / gnu<"__inline" "__"?>> { FunctionSpecifier::Inline } /
K<"_Noreturn"> { FunctionSpecifier::Noreturn }
////
// 6.7.5 Alignment specifiers
////
alignment_specifier -> Node<AlignmentSpecifier> = node<alignment_specifier0>
alignment_specifier0 -> AlignmentSpecifier =
K<"_Alignas"> _ "(" _ t:type_name _ ")" { AlignmentSpecifier::Type(t) } /
K<"_Alignas"> _ "(" _ e:constant_expression _ ")" { AlignmentSpecifier::Constant(e) }
////
// 6.7.6 Declarators
////
declarator -> Node<Declarator> = node<declarator0>
declarator0 -> Declarator =
attr:gnu<attribute_specifier_list>? _
pointer:list0<pointer> _
kind:node<direct_declarator> _
derived:list0<node<derived_declarator>>
{
Declarator {
kind: kind,
derived: concat(pointer, derived),
extensions: attr.unwrap_or_default(),
}
}
direct_declarator -> DeclaratorKind =
i:identifier { DeclaratorKind::Identifier(i) } /
"(" _ d:declarator _ ")" { DeclaratorKind::Declarator(Box::new(d)) }
derived_declarator -> DerivedDeclarator =
"[" _ a:node<array_declarator> { DerivedDeclarator::Array(a) } /
"(" _ f:scoped<node<function_declarator>> _ ")" { DerivedDeclarator::Function(f) } /
"(" _ p:cs0<identifier> _ ")" { DerivedDeclarator::KRFunction(p) }
array_declarator -> ArrayDeclarator =
q:list0<type_qualifier> _ "]" {
ArrayDeclarator {
qualifiers: q,
size: ArraySize::Unknown,
}
} /
q:list0<type_qualifier> _ e:assignment_expression _ "]" {
ArrayDeclarator {
qualifiers: q,
size: ArraySize::VariableExpression(e),
}
} /
K<"static"> _ q:list0<type_qualifier> _ e:assignment_expression _ "]" {
ArrayDeclarator {
qualifiers: q,
size: ArraySize::StaticExpression(e),
}
} /
q:list1<type_qualifier> _ K<"static"> _ e:assignment_expression _ "]" {
ArrayDeclarator {
qualifiers: q,
size: ArraySize::StaticExpression(e),
}
} /
q:list0<type_qualifier> _ "*" _ "]" {
ArrayDeclarator {
qualifiers: q,
size: ArraySize::VariableUnknown,
}
}
function_declarator -> FunctionDeclarator =
p:cs1<parameter_declaration> _ e:ellipsis {
FunctionDeclarator {
parameters: p,
ellipsis: e,
}
}
pointer -> Node<DerivedDeclarator> = node<pointer0>
pointer0 -> DerivedDeclarator =
t:$("*" / clang<"^">) _ q:list0<node<pointer_qualifier>> {
if t == "^" {
DerivedDeclarator::Block(q)
} else {
DerivedDeclarator::Pointer(q)
}
}
pointer_qualifier -> PointerQualifier =
q:type_qualifier { PointerQualifier::TypeQualifier(q) } /
e:gnu<attribute_specifier> { PointerQualifier::Extension(e) }
ellipsis -> Ellipsis =
"," _ "..." { Ellipsis::Some } / { Ellipsis::None }
parameter_declaration -> Node<ParameterDeclaration> = node<parameter_declaration0>
parameter_declaration0 -> ParameterDeclaration =
s:declaration_specifiers _ d:parameter_declarator _ a:gnu<attribute_specifier_list>? {
ParameterDeclaration {
specifiers: s,
declarator: d,
extensions: a.unwrap_or_default()
}
}
parameter_declarator -> Option<Node<Declarator>> =
d:declarator {
env.handle_declarator(&d, Symbol::Identifier);
Some(d)
} /
d:abstract_declarator { Some(d) } /
{ None }
////
// 6.7.7 Type names
////
type_name -> Node<TypeName> = node<type_name0>
type_name0 -> TypeName =
s:specifier_qualifiers _ d:abstract_declarator? {
TypeName {
specifiers: s,
declarator: d,
}
}
abstract_declarator -> Node<Declarator> = node<abstract_declarator0>
abstract_declarator0 -> Declarator =
p:list0<pointer> _ k:node<direct_abstract_declarator> _ d:list0<derived_abstract_declarator> {
Declarator {
kind: k,
derived: concat(p, d),
extensions: Vec::new(),
}
} /
p:list0<pointer> k:#position _ d:list1<derived_abstract_declarator> {
Declarator {
kind: Node::new(DeclaratorKind::Abstract, Span::span(k, k)),
derived: concat(p, d),
extensions: Vec::new(),
}
} /
p:list1<pointer> k:#position {
Declarator {
kind: Node::new(DeclaratorKind::Abstract, Span::span(k, k)),
derived: p,
extensions: Vec::new(),
}
}
direct_abstract_declarator -> DeclaratorKind =
"(" _ d:abstract_declarator _ ")" { DeclaratorKind::Declarator(Box::new(d)) }
derived_abstract_declarator -> Node<DerivedDeclarator> = node<derived_abstract_declarator0>
derived_abstract_declarator0 -> DerivedDeclarator =
"[" _ a:node<abstract_array_declarator> { DerivedDeclarator::Array(a) } /
"(" _ d:node<abstract_function_declarator> _ ")" { DerivedDeclarator::Function(d) }
abstract_array_declarator -> ArrayDeclarator =
q:list0<type_qualifier> _ "]" {
ArrayDeclarator {
qualifiers: q,
size: ArraySize::Unknown,
}
} /
q:list0<type_qualifier> _ e:assignment_expression _ "]" {
ArrayDeclarator {
qualifiers: q,
size: ArraySize::VariableExpression(e),
}
} /
K<"static"> _ q:list0<type_qualifier> _ e:assignment_expression _ "]" {
ArrayDeclarator {
qualifiers: q,
size: ArraySize::StaticExpression(e),
}
} /
q:list1<type_qualifier> _ K<"static"> _ e:assignment_expression _ "]" {
ArrayDeclarator {
qualifiers: q,
size: ArraySize::StaticExpression(e),
}
} /
"*" _ "]" {
ArrayDeclarator {
qualifiers: Vec::new(),
size: ArraySize::VariableUnknown,
}
}
abstract_function_declarator -> FunctionDeclarator =
p:cs1<parameter_declaration> _ e:ellipsis {
FunctionDeclarator {
parameters: p,
ellipsis: e,
}
} /
{
FunctionDeclarator {
parameters: Vec::new(),
ellipsis: Ellipsis::None,
}
}
////
// 6.7.8 Type definitions
////
typedef_name -> Node<Identifier> = #quiet<typedef_name0> / #expected("<typedef_name>")
typedef_name0 -> Node<Identifier> = i:identifier {?
if env.is_typename(&i.node.name) {
Ok(i)
} else {
Err("<unused>")
}
}
////
// 6.7.9 Initialization
////
initializer -> Initializer =
e:assignment_expression { Initializer::Expression(e) } /
"{" _ i:cs1<node<initializer_list_item>> _ ","? _ "}" { Initializer::List(i) } /
gnu<"{" _ "}"> { Initializer::List(Vec::new()) }
initializer_list_item -> InitializerListItem =
d:designation? _ i:node<initializer> {
InitializerListItem {
designation: d.unwrap_or_default(),
initializer: Box::new(i),
}
}
designation -> Vec<Node<Designator>> =
d:list1<node<designator>> _ "=" { d } /
d:gnu<node<colon_designation>> { vec! [ d ] } /
d:gnu<node<array_designator>> { vec![ d ] }
colon_designation -> Designator =
i:identifier _ ":" { Designator::Member(i) }
designator -> Designator =
d:array_designator { d } /
"." _ i:identifier { Designator::Member(i) }
array_designator -> Designator =
"[" _ a:node<constant_expression0> _ b:gnu<range_suffix>? "]" {
match b {
Some(b) => {
let span = Span::span(a.span.start, b.span.end);
Designator::Range(Node::new(RangeDesignator { from: a, to: b }, span))
}
None => Designator::Index(a),
}
}
range_suffix -> Node<Expression> = // shared with label
"..." _ e:node<constant_expression0> { e }
////
// 6.7.10 Static assertions
////
static_assert -> Node<StaticAssert> = node<static_assert0>
static_assert0 -> StaticAssert =
gnu<K<"__extension__">>?
_ K<"_Static_assert"> _ "(" _ e:constant_expression _ "," _ s:string_literal _ ")" _ ";" {
StaticAssert {
expression: e,
message: s,
}
}
////
// 6.8 Statements and blocks
////
pub statement -> Box<Node<Statement>> = box<node<statement0>>
statement0 -> Statement =
s:node<labeled_statement> { Statement::Labeled(s) } /
scoped<compound_statement> /
expression_statement /
scoped<selection_statement> /
scoped<iteration_statement> /
jump_statement /
gnu<asm_statement>
////
// 6.8.1 Labeled statements
////
labeled_statement -> LabeledStatement =
l:node<label> _ ":" _ s:statement {
LabeledStatement {
label: l,
statement: s,
}
}
label -> Label =
i:identifier { Label::Identifier(i) } /
K<"case"> _ a:constant_expression _ b:gnu<range_suffix>? {
match b {
Some(b) => {
let span = Span::span(a.span.start, b.span.end);
Label::CaseRange(Node::new(CaseRange { low: a, high: Box::new(b) }, span))
}
None => Label::Case(a),
}
} /
K<"default"> { Label::Default }
////
// 6.8.2 Compound statement
////
compound_statement -> Statement =
"{" _ b:list0<node<block_item>> _ "}" { Statement::Compound(b) }
block_item -> BlockItem =
d:declaration { BlockItem::Declaration(d) } /
s:static_assert { BlockItem::StaticAssert(s) } /
s:node<statement0> { BlockItem::Statement(s) }
////
// 6.8.3 Expression and null statements
////
expression_statement -> Statement =
e:expression? _ ";" { Statement::Expression(e) }
////
// 6.8.4 Selection statement
////
selection_statement -> Statement =
s:node<if_statement> { Statement::If(s) } /
s:node<switch_statement> { Statement::Switch(s) }
if_statement -> IfStatement =
K<"if"> _ "(" _ e:expression _ ")" _ a:statement _ b:else_statement? {
IfStatement {
condition: e,
then_statement: a,
else_statement: b,
}
}
else_statement -> Box<Node<Statement>> = K<"else"> _ s:statement { s }
switch_statement -> SwitchStatement =
K<"switch"> _ "(" _ e:expression _ ")" _ s:statement {
SwitchStatement {
expression: e,
statement: s,
}
}
////
// 6.8.5 Iteration statement
////
iteration_statement -> Statement =
s:node<while_statement> { Statement::While(s) } /
s:node<do_while_statement> { Statement::DoWhile(s) } /
s:node<for_statement> { Statement::For(s) }
while_statement -> WhileStatement =
K<"while"> _ "(" _ e:expression _ ")" _ s:statement {
WhileStatement {
expression: e,
statement: s,
}
}
do_while_statement -> DoWhileStatement =
K<"do"> _ s:statement _ K<"while"> _ "(" _ e:expression _ ")" _ ";" {
DoWhileStatement {
statement: s,
expression: e,
}
}
for_statement -> ForStatement =
K<"for"> _ "(" _ a:node<for_initializer> _ b:expression? _ ";" _ c:expression? _ ")" _ s:statement {
ForStatement {
initializer: a,
condition: b,
step: c,
statement: s,
}
}
for_initializer -> ForInitializer =
e:expression _ ";" { ForInitializer::Expression(e) } /
d:declaration { ForInitializer::Declaration(d) } /
s:static_assert { ForInitializer::StaticAssert(s) } /
";" { ForInitializer::Empty }
////
// 6.8.6 Jump statements
////
jump_statement -> Statement =
K<"goto"> _ i:identifier _ ";" { Statement::Goto(i) } /
K<"continue"> _ ";" { Statement::Continue } /
K<"break"> _ ";" { Statement::Break } /
K<"return"> _ e:expression? _ ";" { Statement::Return(e) }
////
// 6.9 External definitions
////
scoped<e> = ({ env.enter_scope(); }) e:e? {? env.leave_scope(); e.ok_or("") }
pub translation_unit -> TranslationUnit =
directive? _ d:list0<node<external_declaration>> _ { TranslationUnit(d) }
external_declaration -> ExternalDeclaration =
d:external_declaration0 gnu<(_ ";")*>? { d }
external_declaration0 -> ExternalDeclaration =
d:declaration { ExternalDeclaration::Declaration(d) } /
s:static_assert { ExternalDeclaration::StaticAssert(s) } /
d:scoped<node<function_definition>> { ExternalDeclaration::FunctionDefinition(d) }
function_definition -> FunctionDefinition =
gnu<K<"__extension__">>?
_ a:declaration_specifiers _ b:declarator _ c:list0<declaration>
_ d:node<compound_statement> {
FunctionDefinition {
specifiers: a,
declarator: b,
declarations: c,
statement: d,
}
}
////
// GNU extensions
////
gnu<E> = &gnu_guard e:E { e }
gnu_guard = {? if env.extensions_gnu { Ok(()) } else { Err("gnu extensions disabled") } }
////
// GNU attributes
////
attribute_specifier_list -> Vec<Node<Extension>> =
a:list0<attribute_specifier> { a.into_iter().flat_map(|v| v).collect() }
attribute_specifier -> Vec<Node<Extension>> =
K<"__attribute" "__"?> _ "((" _ a:cs0<node<attribute>> _ "))" { a }
attribute -> Extension =
c:clang<node<attr_availability>> { Extension::AvailabilityAttribute(c) } /
n:node<attribute_name> _ p:attribute_parameters? {
Extension::Attribute(Attribute {
name: n,
arguments: p.unwrap_or_default(),
})
}
attribute_name -> String =
n:$(#quiet<[_a-zA-Z][_a-zA-Z0-9]*>) { String::from(n) }
attribute_parameters -> Vec<Node<Expression>> =
"(" _ e:cs0<node<assignment_expression0>> _ ")" { e }
attr_availability -> AvailabilityAttribute =
K<"availability"> _ "(" _ p:identifier _ "," _ c:cs1<node<attr_availability_clause>> _ ")" {
AvailabilityAttribute {
platform: p,
clauses: c,
}
}
attr_availability_clause -> AvailabilityClause =
K<"introduced"> _ "=" _ v:node<attr_availability_version> { AvailabilityClause::Introduced(v) } /
K<"deprecated"> _ "=" _ v:node<attr_availability_version> { AvailabilityClause::Deprecated(v) } /
K<"obsoleted"> _ "=" _ v:node<attr_availability_version> { AvailabilityClause::Obsoleted(v) } /
K<"unavailable"> { AvailabilityClause::Unavailable } /
K<"message"> _ "=" _ s:string_literal { AvailabilityClause::Message(s) } /
K<"replacement"> _ "=" _ s:string_literal { AvailabilityClause::Replacement(s) }
attr_availability_version -> AvailabilityVersion =
a:$(dec+) b:("." $(dec+) )? c:("." $(dec+) )? {
AvailabilityVersion {
major: a.into(),
minor: b.map(str::to_owned),
subminor: c.map(str::to_owned),
}
}
////
// GNU assembler labels
////
asm_label -> Node<Extension> = node<asm_label0>
asm_label0 -> Extension =
asm_label_keyword _ "(" _ s:string_literal _ ")" { Extension::AsmLabel(s) }
asm_label_keyword =
#quiet<K<"asm"> / K<"__asm" "__"?>> / #expected("asm")
////
// GNU assembler statements
////
asm_statement -> Statement =
s:node<asm_statement0> { Statement::Asm(s) }
asm_statement0 -> AsmStatement =
K<"asm" / "__asm" "__"?> _ q:type_qualifier? _ "(" _
a:string_literal _
o:asm_ext<asm_operand_list, asm_ext<asm_operand_list, asm_ext<cs0<string_literal>, ()>>>? _
")" _ ";" {
if let Some((o, (i, (c, ())))) = o {
AsmStatement::GnuExtended(GnuExtendedAsmStatement {
qualifier: q,
template: a,
outputs: o,
inputs: i,
clobbers: c,
})
} else {
AsmStatement::GnuBasic(a)
}
}
asm_ext<e, t> = ":" _ e:e _ t:t? { (e, t.unwrap_or_default()) }
asm_operand_list -> Vec<Node<GnuAsmOperand>> = cs0<node<asm_operand>>
asm_operand -> GnuAsmOperand =
i:("[" _ i:identifier _ "]" _ {i})? s:string_literal _ "(" _ e:node<expression0> _ ")" {
GnuAsmOperand {
symbolic_name: i,
constraints: s,
variable_name: e,
}
}
////
// GNU expression extensions
////
gnu_primary_expression -> Expression =
statement_expression /
offsetof_expression /
va_arg_expression /
keyword_expression
statement_expression -> Expression =
"(" _ s:scoped<node<compound_statement>> _ ")" { Expression::Statement(Box::new(s)) }
va_arg_expression -> Expression =
n:node<va_arg_expression_inner> { Expression::VaArg(Box::new(n)) }
va_arg_expression_inner -> VaArgExpression =
K<"__builtin_va_arg"> _ "(" _ e:assignment_expression _ "," _ t:type_name _ ")" {
VaArgExpression {
va_list: e,
type_name: t,
}
}
keyword_expression -> Expression =
k:node<$(keyword_expression0)> {
let ident = Identifier {
name: k.node.to_string(),
};
Expression::Identifier(Box::new(Node::new(ident, k.span)))
}
keyword_expression0 =
K<"__func__"> /
K<"__FUNCTION__"> /
K<"__PRETTY_FUNCTION__">
offsetof_expression -> Expression =
n:node<offsetof_expression_inner> { Expression::OffsetOf(Box::new(n)) }
offsetof_expression_inner -> OffsetOfExpression =
K<"__builtin_offsetof"> _ "(" _ t:type_name _ "," _ d:node<offsetof_designator> _ ")" {
OffsetOfExpression {
type_name: t,
designator: d,
}
}
offsetof_designator -> OffsetDesignator =
i:identifier _ d:list0<node<offsetof_member>> {
OffsetDesignator {
base: i,
members: d,
}
}
offsetof_member -> OffsetMember =
"." _ i:identifier { OffsetMember::Member(i) } /
"->" _ i:identifier { OffsetMember::IndirectMember(i) } /
"[" _ e:node<expression0> _ "]" { OffsetMember::Index(e) }
////
// GNU typeof extension
////
typeof_specifier -> TypeSpecifier =
K<"typeof" / "__typeof" "__"?> _ "(" _ e:node<typeof_specifier0> _ ")" { TypeSpecifier::TypeOf(e) }
typeof_specifier0 -> TypeOf =
e:node<expression0> { TypeOf::Expression(e) } /
t:type_name { TypeOf::Type(t) }
////
// ISO/IEC TS 18661 series floating point extensions
////
ts18661_float_type_specifier -> TS18661FloatType =
ts18661_binary_float /
ts18661_decimal_float
ts18661_binary_float -> TS18661FloatType =
"_Float" width:ts18661_binary_width extended:"x"? {
ts18661_float(true, width, extended.is_some())
}
ts18661_binary_width -> usize =
n:$("16" / "32" / "64" / "128") {
n.parse().unwrap()
}
ts18661_decimal_float -> TS18661FloatType =
"_Decimal" width:ts18661_decimal_width extended:"x"? {
ts18661_float(false, width, extended.is_some())
}
ts18661_decimal_width -> usize =
n:$("32" / "64" / "128") {
n.parse().unwrap()
}
ts18661_float_suffix -> TS18661FloatType =
("df" / "DF") { ts18661_float(false, 32, false) } /
("dd" / "DD") { ts18661_float(false, 64, false) } /
("dl" / "DL") { ts18661_float(false, 128, false) } /
[fF] width:ts18661_binary_width extended:"x"? {
ts18661_float(true, width, extended.is_some())
} /
[dD] width:ts18661_decimal_width extended:"x"? {
ts18661_float(false, width, extended.is_some())
}
////
// Clang extensions
////
clang<E> = &clang_guard e:E { e }
clang_guard = {? if env.extensions_clang { Ok(()) } else { Err("clang extensions disabled") } }
================================================
FILE: reftests/constant-322.c
================================================
#pragma gnu
0
/*===
Constant
Integer "0"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
===*/
================================================
FILE: reftests/constant-323.c
================================================
#pragma gnu
1
/*===
Constant
Integer "1"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
===*/
================================================
FILE: reftests/constant-324.c
================================================
#pragma gnu
1234567890
/*===
Constant
Integer "1234567890"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
===*/
================================================
FILE: reftests/constant-328.c
================================================
#pragma gnu
01234567
/*===
Constant
Integer "1234567"
IntegerBase Octal
IntegerSuffix false false
IntegerSize Int
===*/
================================================
FILE: reftests/constant-332.c
================================================
#pragma gnu
0x1234567890abdefABCDEF
/*===
Constant
Integer "1234567890abdefABCDEF"
IntegerBase Hexadecimal
IntegerSuffix false false
IntegerSize Int
===*/
================================================
FILE: reftests/constant-336.c
================================================
#pragma gnu
0b0001001000110100
/*===
Constant
Integer "0001001000110100"
IntegerBase Binary
IntegerSuffix false false
IntegerSize Int
===*/
================================================
FILE: reftests/constant-340.c
================================================
#pragma gnu
042lu
/*===
Constant
Integer "42"
IntegerBase Octal
IntegerSuffix true false
IntegerSize Long
===*/
================================================
FILE: reftests/constant-341.c
================================================
#pragma gnu
042ul
/*===
Constant
Integer "42"
IntegerBase Octal
IntegerSuffix true false
IntegerSize Long
===*/
================================================
FILE: reftests/constant-342.c
================================================
#pragma gnu
042uL
/*===
Constant
Integer "42"
IntegerBase Octal
IntegerSuffix true false
IntegerSize Long
===*/
================================================
FILE: reftests/constant-344.c
================================================
#pragma gnu
1a
/*===
~ERROR
===*/
================================================
FILE: reftests/constant-345.c
================================================
#pragma gnu
08
/*===
~ERROR
===*/
================================================
FILE: reftests/constant-346.c
================================================
#pragma gnu
0xX
/*===
~ERROR
===*/
================================================
FILE: reftests/constant-347.c
================================================
#pragma gnu
1lul
/*===
~ERROR
===*/
================================================
FILE: reftests/constant-348.c
================================================
#pragma gnu
2lL
/*===
~ERROR
===*/
================================================
FILE: reftests/constant-349.c
================================================
#pragma gnu
0b2
/*===
~ERROR
===*/
================================================
FILE: reftests/constant-370.c
================================================
#pragma gnu
2.
/*===
Constant
Float "2."
FloatBase Decimal
FloatSuffix false
FloatFormat Double
===*/
================================================
FILE: reftests/constant-371.c
================================================
#pragma gnu
2.e2
/*===
Constant
Float "2.e2"
FloatBase Decimal
FloatSuffix false
FloatFormat Double
===*/
================================================
FILE: reftests/constant-375.c
================================================
#pragma gnu
.2
/*===
Constant
Float ".2"
FloatBase Decimal
FloatSuffix false
FloatFormat Double
===*/
================================================
FILE: reftests/constant-376.c
================================================
#pragma gnu
.2e2
/*===
Constant
Float ".2e2"
FloatBase Decimal
FloatSuffix false
FloatFormat Double
===*/
================================================
FILE: reftests/constant-380.c
================================================
#pragma gnu
2.0
/*===
Constant
Float "2.0"
FloatBase Decimal
FloatSuffix false
FloatFormat Double
===*/
================================================
FILE: reftests/constant-381.c
================================================
#pragma gnu
2.0f
/*===
Constant
Float "2.0"
FloatBase Decimal
FloatSuffix false
FloatFormat Float
===*/
================================================
FILE: reftests/constant-383.c
================================================
#pragma gnu
24.01e100
/*===
Constant
Float "24.01e100"
FloatBase Decimal
FloatSuffix false
FloatFormat Double
===*/
================================================
FILE: reftests/constant-387.c
================================================
#pragma gnu
24.01e+100
/*===
Constant
Float "24.01e+100"
FloatBase Decimal
FloatSuffix false
FloatFormat Double
===*/
================================================
FILE: reftests/constant-391.c
================================================
#pragma gnu
24.01e-100
/*===
Constant
Float "24.01e-100"
FloatBase Decimal
FloatSuffix false
FloatFormat Double
===*/
================================================
FILE: reftests/constant-395.c
================================================
#pragma gnu
24.01e100f
/*===
Constant
Float "24.01e100"
FloatBase Decimal
FloatSuffix false
FloatFormat Float
===*/
================================================
FILE: reftests/constant-400.c
================================================
#pragma gnu
0x2Ap19L
/*===
Constant
Float "2Ap19"
FloatBase Hexadecimal
FloatSuffix false
FloatFormat LongDouble
===*/
================================================
FILE: reftests/constant-404.c
================================================
#pragma gnu
0x2A.p19L
/*===
Constant
Float "2A.p19"
FloatBase Hexadecimal
FloatSuffix false
FloatFormat LongDouble
===*/
================================================
FILE: reftests/constant-408.c
================================================
#pragma gnu
0x.DEp19L
/*===
Constant
Float ".DEp19"
FloatBase Hexadecimal
FloatSuffix false
FloatFormat LongDouble
===*/
================================================
FILE: reftests/constant-412.c
================================================
#pragma gnu
0x2A.DEp19L
/*===
Constant
Float "2A.DEp19"
FloatBase Hexadecimal
FloatSuffix false
FloatFormat LongDouble
===*/
================================================
FILE: reftests/constant-442.c
================================================
#pragma gnu
1.0f64
/*===
Constant
Float "1.0"
FloatBase Decimal
FloatSuffix false
FloatFormat
TS18661FloatType 64
TS18661FloatFormat BinaryInterchange
===*/
================================================
FILE: reftests/constant-446.c
================================================
#pragma gnu
0xAp1f16
/*===
Constant
Float "Ap1"
FloatBase Hexadecimal
FloatSuffix false
FloatFormat
TS18661FloatType 16
TS18661FloatFormat BinaryInterchange
===*/
================================================
FILE: reftests/constant-458.c
================================================
#pragma gnu
'a'
/*===
Constant Character 'a'
===*/
================================================
FILE: reftests/constant-459.c
================================================
#pragma gnu
'\n'
/*===
Constant Character '\n'
===*/
================================================
FILE: reftests/constant-460.c
================================================
#pragma gnu
'\\'
/*===
Constant Character '\\'
===*/
================================================
FILE: reftests/constant-461.c
================================================
#pragma gnu
'\''
/*===
Constant Character '\''
===*/
================================================
FILE: reftests/constant-462.c
================================================
#pragma gnu
'\1'
/*===
Constant Character '\1'
===*/
================================================
FILE: reftests/constant-463.c
================================================
#pragma gnu
'\02'
/*===
Constant Character '\02'
===*/
================================================
FILE: reftests/constant-464.c
================================================
#pragma gnu
'\027'
/*===
Constant Character '\027'
===*/
================================================
FILE: reftests/constant-465.c
================================================
#pragma gnu
'\xde'
/*===
Constant Character '\xde'
===*/
================================================
FILE: reftests/constant-466.c
================================================
'\c'
/*===
~ERROR
===*/
================================================
FILE: reftests/declaration-1080.c
================================================
#pragma gnu
__attribute__((noreturn)) void d0 (void),
__attribute__((format(printf, 1, 2))) d1 (const char *, ...),
d2 (void);
/*===
Declaration
DeclarationSpecifier
Extension
Attribute "noreturn"
DeclarationSpecifier
TypeSpecifier Void
InitDeclarator
Declarator
DeclaratorKind
Identifier "d0"
DerivedDeclarator
FunctionDeclarator
ParameterDeclaration
DeclarationSpecifier
TypeSpecifier Void
Ellipsis None
InitDeclarator
Declarator
DeclaratorKind
Identifier "d1"
DerivedDeclarator
FunctionDeclarator
ParameterDeclaration
DeclarationSpecifier
TypeQualifier Const
DeclarationSpecifier
TypeSpecifier Char
Declarator
DeclaratorKind Abstract
DerivedDeclarator Pointer
Ellipsis Some
Extension
Attribute "format"
Expression
Identifier "printf"
Expression
Constant
Integer "1"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
Expression
Constant
Integer "2"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
InitDeclarator
Declarator
DeclaratorKind
Identifier "d2"
DerivedDeclarator
FunctionDeclarator
ParameterDeclaration
DeclarationSpecifier
TypeSpecifier Void
Ellipsis None
===*/
================================================
FILE: reftests/declaration-1443.c
================================================
#pragma gnu
union { long double __l; int __i[3]; } __u = { __l: __x };
/*===
Declaration
DeclarationSpecifier
TypeSpecifier
StructType
StructKind Union
StructDeclaration
StructField
SpecifierQualifier
TypeSpecifier Long
SpecifierQualifier
TypeSpecifier Double
StructDeclarator
Declarator
DeclaratorKind
Identifier "__l"
StructDeclaration
StructField
SpecifierQualifier
TypeSpecifier Int
StructDeclarator
Declarator
DeclaratorKind
Identifier "__i"
DerivedDeclarator
ArrayDeclarator
ArraySize VariableExpression
Expression
Constant
Integer "3"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
InitDeclarator
Declarator
DeclaratorKind
Identifier "__u"
Initializer
InitializerListItem
Designator
Identifier "__l"
Initializer
Expression
Identifier "__x"
===*/
================================================
FILE: reftests/declaration-1610.c
================================================
#pragma gnu
__typeof__(foo(bar, baz)) ook = foo(bar, baz);
/*===
Declaration
DeclarationSpecifier
TypeSpecifier
TypeOf
Expression
CallExpression
Expression
Identifier "foo"
Expression
Identifier "bar"
Expression
Identifier "baz"
InitDeclarator
Declarator
DeclaratorKind
Identifier "ook"
Initializer
Expression
CallExpression
Expression
Identifier "foo"
Expression
Identifier "bar"
Expression
Identifier "baz"
===*/
================================================
FILE: reftests/declaration-1847.c
================================================
#pragma gnu
typedef struct {
long long __max_align_ll __attribute__((__aligned__(__alignof__(long long))));
long double __max_align_ld __attribute__((__aligned__(__alignof__(long double))));
} max_align_t;
/*===
Declaration
DeclarationSpecifier
StorageClassSpecifier Typedef
DeclarationSpecifier
TypeSpecifier
StructType
StructKind Struct
StructDeclaration
StructField
SpecifierQualifier
TypeSpecifier Long
SpecifierQualifier
TypeSpecifier Long
StructDeclarator
Declarator
DeclaratorKind
Identifier "__max_align_ll"
Extension
Attribute "__aligned__"
Expression
AlignOf
TypeName
SpecifierQualifier
TypeSpecifier Long
SpecifierQualifier
TypeSpecifier Long
StructDeclaration
StructField
SpecifierQualifier
TypeSpecifier Long
SpecifierQualifier
TypeSpecifier Double
StructDeclarator
Declarator
DeclaratorKind
Identifier "__max_align_ld"
Extension
Attribute "__aligned__"
Expression
AlignOf
TypeName
SpecifierQualifier
TypeSpecifier Long
SpecifierQualifier
TypeSpecifier Double
InitDeclarator
Declarator
DeclaratorKind
Identifier "max_align_t"
===*/
================================================
FILE: reftests/declaration-2243.c
================================================
#pragma gnu
_Float64 foo = 1.5;
/*===
Declaration
DeclarationSpecifier
TypeSpecifier
TS18661FloatType 64
TS18661FloatFormat BinaryInterchange
InitDeclarator
Declarator
DeclaratorKind
Identifier "foo"
Initializer
Expression
Constant
Float "1.5"
FloatBase Decimal
FloatSuffix false
FloatFormat Double
===*/
================================================
FILE: reftests/declaration-2321.c
================================================
// This is the first Clang-specific declaration you'll encounter in macOS
// if you #include <stdio.h>.
#pragma gnu
#pragma clang
int (* _Nullable _close)(void *);
/*===
Declaration
DeclarationSpecifier
TypeSpecifier Int
InitDeclarator
Declarator
DeclaratorKind
Declarator
DeclaratorKind
Identifier "_close"
DerivedDeclarator Pointer
PointerQualifier
TypeQualifier Nullable
DerivedDeclarator
FunctionDeclarator
ParameterDeclaration
DeclarationSpecifier
TypeSpecifier Void
Declarator
DeclaratorKind Abstract
DerivedDeclarator Pointer
Ellipsis None
===*/
================================================
FILE: reftests/declaration-2429.c
================================================
#pragma gnu
#pragma clang
int f __attribute__((availability(p1,introduced=1.2.3))) __attribute__((availability(p2,unavailable,replacement="f2")));
/*===
Declaration
DeclarationSpecifier
TypeSpecifier Int
InitDeclarator
Declarator
DeclaratorKind
Identifier "f"
Extension
AvailabilityAttribute
Extension
AvailabilityAttribute
===*/
================================================
FILE: reftests/declaration-2477.c
================================================
#pragma gnu
struct foo S;
/*===
Declaration
DeclarationSpecifier
TypeSpecifier
StructType
StructKind Struct
Identifier "foo"
InitDeclarator
Declarator
DeclaratorKind
Identifier "S"
===*/
================================================
FILE: reftests/declaration-2508.c
================================================
struct foo { } S;
/*===
~ERROR
===*/
================================================
FILE: reftests/declaration-2512.c
================================================
#pragma gnu
struct foo { } S;
/*===
Declaration
DeclarationSpecifier
TypeSpecifier
StructType
StructKind Struct
Identifier "foo"
InitDeclarator
Declarator
DeclaratorKind
Identifier "S"
===*/
================================================
FILE: reftests/declaration-2594.c
================================================
// #23
typedef const int foo;
/*===
Declaration
DeclarationSpecifier
StorageClassSpecifier Typedef
DeclarationSpecifier
TypeQualifier Const
DeclarationSpecifier
TypeSpecifier Int
InitDeclarator
Declarator
DeclaratorKind
Identifier "foo"
===*/
================================================
FILE: reftests/declaration-31-field-semicolon.c
================================================
#pragma gnu
struct s {
int i;;
};
/*===
Declaration
DeclarationSpecifier
TypeSpecifier
StructType
StructKind Struct
Identifier "s"
StructDeclaration
StructField
SpecifierQualifier
TypeSpecifier Int
StructDeclarator
Declarator
DeclaratorKind
Identifier "i"
===*/
================================================
FILE: reftests/declaration-31-ty-attr1.c
================================================
#pragma gnu
// #31
struct s {
struct t {
int i;
} __attribute((packed)) v;
};
/*===
Declaration
DeclarationSpecifier
TypeSpecifier
StructType
StructKind Struct
Identifier "s"
StructDeclaration
StructField
SpecifierQualifier
TypeSpecifier
StructType
StructKind Struct
Identifier "t"
StructDeclaration
StructField
SpecifierQualifier
TypeSpecifier Int
StructDeclarator
Declarator
DeclaratorKind
Identifier "i"
SpecifierQualifier
Extension
Attribute "packed"
StructDeclarator
Declarator
DeclaratorKind
Identifier "v"
===*/
================================================
FILE: reftests/declaration-31-ty-attr2.c
================================================
#pragma gnu
struct s {
union { int i; } __attribute__((aligned(8)));
};
/*===
Declaration
DeclarationSpecifier
TypeSpecifier
StructType
StructKind Struct
Identifier "s"
StructDeclaration
StructField
SpecifierQualifier
TypeSpecifier
StructType
StructKind Union
StructDeclaration
StructField
SpecifierQualifier
TypeSpecifier Int
StructDeclarator
Declarator
DeclaratorKind
Identifier "i"
SpecifierQualifier
Extension
Attribute "aligned"
Expression
Constant
Integer "8"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
===*/
================================================
FILE: reftests/declaration-31-ty-attr3.c
================================================
#pragma gnu
struct s {
int __attribute__((aligned(8))) *i;
};
/*===
Declaration
DeclarationSpecifier
TypeSpecifier
StructType
StructKind Struct
Identifier "s"
StructDeclaration
StructField
SpecifierQualifier
TypeSpecifier Int
SpecifierQualifier
Extension
Attribute "aligned"
Expression
Constant
Integer "8"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
StructDeclarator
Declarator
DeclaratorKind
Identifier "i"
DerivedDeclarator Pointer
===*/
================================================
FILE: reftests/declaration-659.c
================================================
#pragma gnu
int typedef * foo, baz[static 10][const *];
#pragma is_typename foo
#pragma is_typename baz
/*===
Declaration
DeclarationSpecifier
TypeSpecifier Int
DeclarationSpecifier
StorageClassSpecifier Typedef
InitDeclarator
Declarator
DeclaratorKind
Identifier "foo"
DerivedDeclarator Pointer
InitDeclarator
Declarator
DeclaratorKind
Identifier "baz"
DerivedDeclarator
ArrayDeclarator
ArraySize StaticExpression
Expression
Constant
Integer "10"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
DerivedDeclarator
ArrayDeclarator
TypeQualifier Const
ArraySize VariableUnknown
===*/
================================================
FILE: reftests/declaration-714.c
================================================
#pragma gnu
typedef enum { FOO, BAR = 1 } * const foobar;
#pragma is_typename foobar
/*===
Declaration
DeclarationSpecifier
StorageClassSpecifier Typedef
DeclarationSpecifier
TypeSpecifier
EnumType
Enumerator
Identifier "FOO"
Enumerator
Identifier "BAR"
Expression
Constant
Integer "1"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
InitDeclarator
Declarator
DeclaratorKind
Identifier "foobar"
DerivedDeclarator Pointer
PointerQualifier
TypeQualifier Const
===*/
================================================
FILE: reftests/declaration-760.c
================================================
#pragma gnu
struct { int a, b; float c; } S;
/*===
Declaration
DeclarationSpecifier
TypeSpecifier
StructType
StructKind Struct
StructDeclaration
StructField
SpecifierQualifier
TypeSpecifier Int
StructDeclarator
Declarator
DeclaratorKind
Identifier "a"
StructDeclarator
Declarator
DeclaratorKind
Identifier "b"
StructDeclaration
StructField
SpecifierQualifier
TypeSpecifier Float
StructDeclarator
Declarator
DeclaratorKind
Identifier "c"
InitDeclarator
Declarator
DeclaratorKind
Identifier "S"
===*/
================================================
FILE: reftests/declaration-837.c
================================================
int __restrict__;
/*===
Declaration
DeclarationSpecifier
TypeSpecifier Int
InitDeclarator
Declarator
DeclaratorKind
Identifier "__restrict__"
===*/
================================================
FILE: reftests/declaration-855.c
================================================
#pragma gnu
int __restrict__;
/*===
Declaration
DeclarationSpecifier
TypeSpecifier Int
DeclarationSpecifier
TypeQualifier Restrict
===*/
================================================
FILE: reftests/declaration-880.c
================================================
#pragma gnu
#pragma typedef FILE
#pragma typedef size_t
char *fparseln(FILE *, size_t *, size_t *, const char[3], int);
/*===
Declaration
DeclarationSpecifier
TypeSpecifier Char
InitDeclarator
Declarator
DeclaratorKind
Identifier "fparseln"
DerivedDeclarator Pointer
DerivedDeclarator
FunctionDeclarator
ParameterDeclaration
DeclarationSpecifier
TypeSpecifier TypedefName
Identifier "FILE"
Declarator
DeclaratorKind Abstract
DerivedDeclarator Pointer
ParameterDeclaration
DeclarationSpecifier
TypeSpecifier TypedefName
Identifier "size_t"
Declarator
DeclaratorKind Abstract
DerivedDeclarator Pointer
ParameterDeclaration
DeclarationSpecifier
TypeSpecifier TypedefName
Identifier "size_t"
Declarator
DeclaratorKind Abstract
DerivedDeclarator Pointer
ParameterDeclaration
DeclarationSpecifier
TypeQualifier Const
DeclarationSpecifier
TypeSpecifier Char
Declarator
DeclaratorKind Abstract
DerivedDeclarator
ArrayDeclarator
ArraySize VariableExpression
Expression
Constant
Integer "3"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
ParameterDeclaration
DeclarationSpecifier
TypeSpecifier Int
Ellipsis None
===*/
================================================
FILE: reftests/declaration-983.c
================================================
#pragma gnu
#pragma typedef size_t
extern int strerror_r (int __errnum, char *__buf, size_t __buflen)
__asm__ ("" "__xpg_strerror_r") __attribute__ ((__nothrow__ , __leaf__))
__attribute__ ((__nonnull__ (2)));
/*===
Declaration
DeclarationSpecifier
StorageClassSpecifier Extern
DeclarationSpecifier
TypeSpecifier Int
InitDeclarator
Declarator
DeclaratorKind
Identifier "strerror_r"
DerivedDeclarator
FunctionDeclarator
ParameterDeclaration
DeclarationSpecifier
TypeSpecifier Int
Declarator
DeclaratorKind
Identifier "__errnum"
ParameterDeclaration
DeclarationSpecifier
TypeSpecifier Char
Declarator
DeclaratorKind
Identifier "__buf"
DerivedDeclarator Pointer
ParameterDeclaration
DeclarationSpecifier
TypeSpecifier TypedefName
Identifier "size_t"
Declarator
DeclaratorKind
Identifier "__buflen"
Ellipsis None
Extension
StringLiteral ["\"\"", "\"__xpg_strerror_r\""]
Extension
Attribute "__nothrow__"
Extension
Attribute "__leaf__"
Extension
Attribute "__nonnull__"
Expression
Constant
Integer "2"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
===*/
================================================
FILE: reftests/declaration-block-2.c
================================================
#pragma clang
void (^ const p)(int);
/*===
Declaration
DeclarationSpecifier
TypeSpecifier Void
InitDeclarator
Declarator
DeclaratorKind
Declarator
DeclaratorKind
Identifier "p"
DerivedDeclarator Block
PointerQualifier
TypeQualifier Const
DerivedDeclarator
FunctionDeclarator
ParameterDeclaration
DeclarationSpecifier
TypeSpecifier Int
Ellipsis None
===*/
================================================
FILE: reftests/declaration-block-3.c
================================================
#pragma clang
#pragma typedef size_t
void *bsearch_b(const void *__key, const void *__base, size_t __nel,
size_t __width, int (^ _Nonnull __compar)(const void *, const void *) __attribute__((__noescape__)))
__attribute__((availability(macosx,introduced=10.6)));
/*===
Declaration
DeclarationSpecifier
TypeSpecifier Void
InitDeclarator
Declarator
DeclaratorKind
Identifier "bsearch_b"
DerivedDeclarator Pointer
DerivedDeclarator
FunctionDeclarator
ParameterDeclaration
DeclarationSpecifier
TypeQualifier Const
DeclarationSpecifier
TypeSpecifier Void
Declarator
DeclaratorKind
Identifier "__key"
DerivedDeclarator Pointer
ParameterDeclaration
DeclarationSpecifier
TypeQualifier Const
DeclarationSpecifier
TypeSpecifier Void
Declarator
DeclaratorKind
Identifier "__base"
DerivedDeclarator Pointer
ParameterDeclaration
DeclarationSpecifier
TypeSpecifier TypedefName
Identifier "size_t"
Declarator
DeclaratorKind
Identifier "__nel"
ParameterDeclaration
DeclarationSpecifier
TypeSpecifier TypedefName
Identifier "size_t"
Declarator
DeclaratorKind
Identifier "__width"
ParameterDeclaration
DeclarationSpecifier
TypeSpecifier Int
Declarator
DeclaratorKind
Declarator
DeclaratorKind
Identifier "__compar"
DerivedDeclarator Block
PointerQualifier
TypeQualifier Nonnull
DerivedDeclarator
FunctionDeclarator
ParameterDeclaration
DeclarationSpecifier
TypeQualifier Const
DeclarationSpecifier
TypeSpecifier Void
Declarator
DeclaratorKind Abstract
DerivedDeclarator Pointer
ParameterDeclaration
DeclarationSpecifier
TypeQualifier Const
DeclarationSpecifier
TypeSpecifier Void
Declarator
DeclaratorKind Abstract
DerivedDeclarator Pointer
Ellipsis None
Extension
Attribute "__noescape__"
Ellipsis None
Extension
AvailabilityAttribute
===*/
================================================
FILE: reftests/declaration-block-4.c
================================================
int ^none;
/*===
~ERROR
===*/
================================================
FILE: reftests/declaration-block-5.c
================================================
int (^p)(int);
/*===
~ERROR
===*/
================================================
FILE: reftests/declaration-block.c
================================================
#pragma clang
int ^block;
/*===
Declaration
DeclarationSpecifier
TypeSpecifier Int
InitDeclarator
Declarator
DeclaratorKind
Identifier "block"
DerivedDeclarator Block
===*/
================================================
FILE: reftests/declaration-enum-attr.c
================================================
#pragma gnu
enum {
SOME_THING = 0,
OTHER_THING = 1,
OLD_THING __attribute__((deprecated)) = 2,
};
/*===
Declaration
DeclarationSpecifier
TypeSpecifier
EnumType
Enumerator
Identifier "SOME_THING"
Expression
Constant
Integer "0"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
Enumerator
Identifier "OTHER_THING"
Expression
Constant
Integer "1"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
Enumerator
Identifier "OLD_THING"
Expression
Constant
Integer "2"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
Extension
Attribute "deprecated"
===*/
================================================
FILE: reftests/declaration-ptr-attr1.c
================================================
#pragma gnu
void (****f)(void) __attribute__((noreturn));
/*===
Declaration
DeclarationSpecifier
TypeSpecifier Void
InitDeclarator
Declarator
DeclaratorKind
Declarator
DeclaratorKind
Identifier "f"
DerivedDeclarator Pointer
DerivedDeclarator Pointer
DerivedDeclarator Pointer
DerivedDeclarator Pointer
DerivedDeclarator
FunctionDeclarator
ParameterDeclaration
DeclarationSpecifier
TypeSpecifier Void
Ellipsis None
Extension
Attribute "noreturn"
===*/
================================================
FILE: reftests/declaration-ptr-attr2.c
================================================
#pragma gnu
void (__attribute__((noreturn)) ****f) (void);
/*===
Declaration
DeclarationSpecifier
TypeSpecifier Void
InitDeclarator
Declarator
DeclaratorKind
Declarator
DeclaratorKind
Identifier "f"
DerivedDeclarator Pointer
DerivedDeclarator Pointer
DerivedDeclarator Pointer
DerivedDeclarator Pointer
Extension
Attribute "noreturn"
DerivedDeclarator
FunctionDeclarator
ParameterDeclaration
DeclarationSpecifier
TypeSpecifier Void
Ellipsis None
===*/
================================================
FILE: reftests/declaration-ptr-attr3.c
================================================
#pragma gnu
char *__attribute__((aligned(8))) *f;
/*===
Declaration
DeclarationSpecifier
TypeSpecifier Char
InitDeclarator
Declarator
DeclaratorKind
Identifier "f"
DerivedDeclarator Pointer
PointerQualifier
Extension
Attribute "aligned"
Expression
Constant
Integer "8"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
DerivedDeclarator Pointer
===*/
================================================
FILE: reftests/declaration-struct.c
================================================
struct foo {
int x;
};
/*===
Declaration
DeclarationSpecifier
TypeSpecifier
StructType
StructKind Struct
Identifier "foo"
StructDeclaration
StructField
SpecifierQualifier
TypeSpecifier Int
StructDeclarator
Declarator
DeclaratorKind
Identifier "x"
===*/
================================================
FILE: reftests/declaration-typedef.c
================================================
typedef struct foo {
int x;
} bar;
/*===
Declaration
DeclarationSpecifier
StorageClassSpecifier Typedef
DeclarationSpecifier
TypeSpecifier
StructType
StructKind Struct
Identifier "foo"
StructDeclaration
StructField
SpecifierQualifier
TypeSpecifier Int
StructDeclarator
Declarator
DeclaratorKind
Identifier "x"
InitDeclarator
Declarator
DeclaratorKind
Identifier "bar"
===*/
================================================
FILE: reftests/expression-1295.c
================================================
#pragma gnu
_Alignof(long long)
/*===
Expression
AlignOf
TypeName
SpecifierQualifier
TypeSpecifier Long
SpecifierQualifier
TypeSpecifier Long
===*/
================================================
FILE: reftests/expression-1307.c
================================================
#pragma gnu
__alignof(long long)
/*===
Expression
AlignOf
TypeName
SpecifierQualifier
TypeSpecifier Long
SpecifierQualifier
TypeSpecifier Long
===*/
================================================
FILE: reftests/expression-1319.c
================================================
#pragma gnu
__alignof__(long long)
/*===
Expression
AlignOf
TypeName
SpecifierQualifier
TypeSpecifier Long
SpecifierQualifier
TypeSpecifier Long
===*/
================================================
FILE: reftests/expression-1338.c
================================================
#pragma gnu
({ int p = 0; p; })
/*===
Expression
Statement Compound
BlockItem
Declaration
DeclarationSpecifier
TypeSpecifier Int
InitDeclarator
Declarator
DeclaratorKind
Identifier "p"
Initializer
Expression
Constant
Integer "0"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
BlockItem
Statement
Expression
Identifier "p"
===*/
================================================
FILE: reftests/expression-1370.c
================================================
#pragma gnu
#pragma typedef U64
(U64)foo
/*===
Expression
CastExpression
TypeName
SpecifierQualifier
TypeSpecifier TypedefName
Identifier "U64"
Expression
Identifier "foo"
===*/
================================================
FILE: reftests/expression-1523.c
================================================
#pragma gnu
__builtin_offsetof(struct { struct { int b; } a[2]; }, a->b)
/*===
Expression
OffsetOfExpression
TypeName
SpecifierQualifier
TypeSpecifier
StructType
StructKind Struct
StructDeclaration
StructField
SpecifierQualifier
TypeSpecifier
StructType
StructKind Struct
StructDeclaration
StructField
SpecifierQualifier
TypeSpecifier Int
StructDeclarator
Declarator
DeclaratorKind
Identifier "b"
StructDeclarator
Declarator
DeclaratorKind
Identifier "a"
DerivedDeclarator
ArrayDeclarator
ArraySize VariableExpression
Expression
Constant
Integer "2"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
OffsetDesignator
Identifier "a"
OffsetMember IndirectMember
Identifier "b"
===*/
================================================
FILE: reftests/expression-1595.c
================================================
#pragma gnu
foo(bar, baz)
/*===
Expression
CallExpression
Expression
Identifier "foo"
Expression
Identifier "bar"
Expression
Identifier "baz"
===*/
================================================
FILE: reftests/expression-2224.c
================================================
#pragma gnu
__func__
/*===
Expression
Identifier "__func__"
===*/
================================================
FILE: reftests/expression-2229.c
================================================
#pragma gnu
__FUNCTION__
/*===
Expression
Identifier "__FUNCTION__"
===*/
================================================
FILE: reftests/expression-2234.c
================================================
#pragma gnu
__PRETTY_FUNCTION__
/*===
Expression
Identifier "__PRETTY_FUNCTION__"
===*/
================================================
FILE: reftests/expression-2546.c
================================================
#pragma gnu
(struct test_struct) { 1, .x = 2, 3 }
/*===
Expression
CompoundLiteral
TypeName
SpecifierQualifier
TypeSpecifier
StructType
StructKind Struct
Identifier "test_struct"
InitializerListItem
Initializer
Expression
Constant
Integer "1"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
InitializerListItem
Designator
Identifier "x"
Initializer
Expression
Constant
Integer "2"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
InitializerListItem
Initializer
Expression
Constant
Integer "3"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
===*/
================================================
FILE: reftests/expression-475.c
================================================
#pragma gnu
"foo"
/*===
Expression
StringLiteral ["\"foo\""]
===*/
================================================
FILE: reftests/expression-476.c
================================================
#pragma gnu
"foo\n"
/*===
Expression
StringLiteral ["\"foo\\n\""]
===*/
================================================
FILE: reftests/expression-477.c
================================================
#pragma gnu
"\'\""
/*===
Expression
StringLiteral ["\"\\\'\\\"\""]
===*/
================================================
FILE: reftests/expression-478.c
================================================
#pragma gnu
"\xaf"
/*===
Expression
StringLiteral ["\"\\xaf\""]
===*/
================================================
FILE: reftests/expression-491.c
================================================
#pragma gnu
a ++
/*===
Expression
UnaryOperatorExpression
Expression
Identifier "a"
UnaryOperator PostIncrement
===*/
================================================
FILE: reftests/expression-495.c
================================================
#pragma gnu
a.b->c[ d[ e ] ] ++
/*===
Expression
UnaryOperatorExpression
Expression
BinaryOperatorExpression
Expression
MemberExpression
MemberOperator Indirect
Expression
MemberExpression
MemberOperator Direct
Expression
Identifier "a"
Identifier "b"
Identifier "c"
Expression
BinaryOperatorExpression
Expression
Identifier "d"
Expression
Identifier "e"
BinaryOperator Index
BinaryOperator Index
UnaryOperator PostIncrement
===*/
================================================
FILE: reftests/expression-517.c
================================================
#pragma gnu
a-- * ++b / c
/*===
Expression
BinaryOperatorExpression
Expression
BinaryOperatorExpression
Expression
UnaryOperatorExpression
Expression
Identifier "a"
UnaryOperator PostDecrement
Expression
UnaryOperatorExpression
UnaryOperator PreIncrement
Expression
Identifier "b"
BinaryOperator Multiply
Expression
Identifier "c"
BinaryOperator Divide
===*/
================================================
FILE: reftests/expression-538.c
================================================
#pragma gnu
a && b
/*===
Expression
BinaryOperatorExpression
Expression
Identifier "a"
Expression
Identifier "b"
BinaryOperator LogicalAnd
===*/
================================================
FILE: reftests/expression-551.c
================================================
#pragma gnu
a && b && c
/*===
Expression
BinaryOperatorExpression
Expression
BinaryOperatorExpression
Expression
Identifier "a"
Expression
Identifier "b"
BinaryOperator LogicalAnd
Expression
Identifier "c"
BinaryOperator LogicalAnd
===*/
================================================
FILE: reftests/expression-567.c
================================================
#pragma gnu
a || b || c
/*===
Expression
BinaryOperatorExpression
Expression
BinaryOperatorExpression
Expression
Identifier "a"
Expression
Identifier "b"
BinaryOperator LogicalOr
Expression
Identifier "c"
BinaryOperator LogicalOr
===*/
================================================
FILE: reftests/expression-583.c
================================================
#pragma gnu
a << b << c
/*===
Expression
BinaryOperatorExpression
Expression
BinaryOperatorExpression
Expression
Identifier "a"
Expression
Identifier "b"
BinaryOperator ShiftLeft
Expression
Identifier "c"
BinaryOperator ShiftLeft
===*/
================================================
FILE: reftests/expression-599.c
================================================
#pragma gnu
a >> b >> c
/*===
Expression
BinaryOperatorExpression
Expression
BinaryOperatorExpression
Expression
Identifier "a"
Expression
Identifier "b"
BinaryOperator ShiftRight
Expression
Identifier "c"
BinaryOperator ShiftRight
===*/
================================================
FILE: reftests/expression-616.c
================================================
#pragma gnu
a
/*===
Expression
Identifier "a"
===*/
================================================
FILE: reftests/expression-617.c
================================================
#pragma gnu
a, a, a,a
,a
/*===
Expression
Expression
Identifier "a"
Expression
Identifier "a"
Expression
Identifier "a"
Expression
Identifier "a"
Expression
Identifier "a"
===*/
================================================
FILE: reftests/expression-632.c
================================================
#pragma gnu
(int) 1
/*===
Expression
CastExpression
TypeName
SpecifierQualifier
TypeSpecifier Int
Expression
Constant
Integer "1"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
===*/
================================================
FILE: reftests/expression-645.c
================================================
#pragma gnu
(foo) 1
/*===
~ERROR
===*/
================================================
FILE: reftests/expression-ident-const.c
================================================
uident, Uident, Lident, u8ident,
u"str", U"str", L"str", u8"str",
u'chr', U'chr', L'chr'
/*===
Expression
Expression
Identifier "uident"
Expression
Identifier "Uident"
Expression
Identifier "Lident"
Expression
Identifier "u8ident"
Expression
StringLiteral ["u\"str\""]
Expression
StringLiteral ["U\"str\""]
Expression
StringLiteral ["L\"str\""]
Expression
StringLiteral ["u8\"str\""]
Expression
Constant Character u'chr'
Expression
Constant Character U'chr'
Expression
Constant Character L'chr'
===*/
================================================
FILE: reftests/expression-sizeof.c
================================================
#pragma typedef a
sizeof(a) + sizeof b + sizeof(c*10)
/*===
Expression
BinaryOperatorExpression
Expression
BinaryOperatorExpression
Expression
SizeOfTy
TypeName
SpecifierQualifier
TypeSpecifier TypedefName
Identifier "a"
Expression
SizeOfVal
Expression
Identifier "b"
BinaryOperator Plus
Expression
SizeOfVal
Expression
BinaryOperatorExpression
Expression
Identifier "c"
Expression
Constant
Integer "10"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
BinaryOperator Multiply
BinaryOperator Plus
===*/
================================================
FILE: reftests/expression-string-1.c
================================================
L".."
/*===
Expression
StringLiteral ["L\"..\""]
===*/
================================================
FILE: reftests/expression-string-2.c
================================================
u8".."
/*===
Expression
StringLiteral ["u8\"..\""]
===*/
================================================
FILE: reftests/statement-1408.c
================================================
#pragma gnu
__asm ("pmovmskb %1, %0" : "=r" (__m) : "x" (__x));
/*===
Statement
AsmStatement
GnuExtendedAsmStatement
StringLiteral ["\"pmovmskb %1, %0\""]
GnuAsmOperand
StringLiteral ["\"=r\""]
Expression
Identifier "__m"
GnuAsmOperand
StringLiteral ["\"x\""]
Expression
Identifier "__x"
===*/
================================================
FILE: reftests/statement-1650.c
================================================
#pragma gnu
if (x) do {} while(y); else z();
/*===
Statement
IfStatement
Expression
Identifier "x"
Statement
DoWhileStatement
Statement Compound
Expression
Identifier "y"
Statement
Expression
CallExpression
Expression
Identifier "z"
===*/
================================================
FILE: reftests/statement-2625.c
================================================
// #27
#pragma gnu
#pragma typedef test_t
return (test_t) { 1, .x = 2, 3 };
/*===
Statement Return
Expression
CompoundLiteral
TypeName
SpecifierQualifier
TypeSpecifier TypedefName
Identifier "test_t"
InitializerListItem
Initializer
Expression
Constant
Integer "1"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
InitializerListItem
Designator
Identifier "x"
Initializer
Expression
Constant
Integer "2"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
InitializerListItem
Initializer
Expression
Constant
Integer "3"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
===*/
================================================
FILE: reftests/statement-2669.c
================================================
// #27 - make sure expressions starting with a type name in parens still work
#pragma gnu
#pragma typedef test_t
return (test_t) + 1;
/*===
Statement Return
Expression
CastExpression
TypeName
SpecifierQualifier
TypeSpecifier TypedefName
Identifier "test_t"
Expression
UnaryOperatorExpression
UnaryOperator Plus
Expression
Constant
Integer "1"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
===*/
================================================
FILE: reftests/statement-case.c
================================================
case 1: ;
/*===
Statement
LabeledStatement
Label
Expression
Constant
Integer "1"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
Statement
===*/
================================================
FILE: reftests/statement-case2.c
================================================
case 1+2: ;
/*===
Statement
LabeledStatement
Label
Expression
BinaryOperatorExpression
Expression
Constant
Integer "1"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
Expression
Constant
Integer "2"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
BinaryOperator Plus
Statement
===*/
================================================
FILE: reftests/statement-caserange.c
================================================
case 1 ... 2: ;
/*===
~ERROR
===*/
================================================
FILE: reftests/statement-caserange2.c
================================================
#pragma gnu
case 1 ... 2: ;
/*===
Statement
LabeledStatement
Label
CaseRange
Expression
Constant
Integer "1"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
Expression
Constant
Integer "2"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
Statement
===*/
================================================
FILE: reftests/statement-caserange3.c
================================================
#pragma gnu
case 'a'...'z':;
/*===
Statement
LabeledStatement
Label
CaseRange
Expression
Constant Character 'a'
Expression
Constant Character 'z'
Statement
===*/
================================================
FILE: reftests/statement-caserange4.c
================================================
#pragma gnu
switch(num) {
for(;;) {
case 1 ... 10:
return;
break;
}
}
/*===
Statement
SwitchStatement
Expression
Identifier "num"
Statement Compound
BlockItem
Statement
ForStatement
ForInitializer Empty
Statement Compound
BlockItem
Statement
LabeledStatement
Label
CaseRange
Expression
Constant
Integer "1"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
Expression
Constant
Integer "10"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
Statement Return
BlockItem
Statement Break
===*/
================================================
FILE: reftests/statement-caserange5.c
================================================
#pragma gnu
case 1...3:;
/*===
~ERROR
===*/
================================================
FILE: reftests/statement-default.c
================================================
default:;
/*===
Statement
LabeledStatement
Label Default
Statement
===*/
================================================
FILE: reftests/statement-label.c
================================================
foo: {}
/*===
Statement
LabeledStatement
Label
Identifier "foo"
Statement Compound
===*/
================================================
FILE: reftests/translation_unit-1183.c
================================================
#pragma gnu
extern __inline __attribute__ ((__always_inline__)) __attribute__
((__artificial__)) __attribute__ ((__warn_unused_result__)) char *
__attribute__ ((__nothrow__ , __leaf__)) realpath (const char *__restrict
__name, char *__restrict __resolved) {}
/*===
TranslationUnit
ExternalDeclaration
FunctionDefinition
DeclarationSpecifier
StorageClassSpecifier Extern
DeclarationSpecifier
FunctionSpecifier Inline
DeclarationSpecifier
Extension
Attribute "__always_inline__"
DeclarationSpecifier
Extension
Attribute "__artificial__"
DeclarationSpecifier
Extension
Attribute "__warn_unused_result__"
DeclarationSpecifier
TypeSpecifier Char
Declarator
DeclaratorKind
Identifier "realpath"
DerivedDeclarator Pointer
PointerQualifier
Extension
Attribute "__nothrow__"
Extension
Attribute "__leaf__"
DerivedDeclarator
FunctionDeclarator
ParameterDeclaration
DeclarationSpecifier
TypeQualifier Const
DeclarationSpecifier
TypeSpecifier Char
Declarator
DeclaratorKind
Identifier "__name"
DerivedDeclarator Pointer
PointerQualifier
TypeQualifier Restrict
ParameterDeclaration
DeclarationSpecifier
TypeSpecifier Char
Declarator
DeclaratorKind
Identifier "__resolved"
DerivedDeclarator Pointer
PointerQualifier
TypeQualifier Restrict
Ellipsis None
Statement Compound
===*/
================================================
FILE: reftests/translation_unit-1388.c
================================================
#pragma gnu
# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 31 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 32 "<command-line>" 2
# 1 "<stdin>"
/*===
TranslationUnit
===*/
================================================
FILE: reftests/translation_unit-1692.c
================================================
// Check that a typedef that can be mistaken for a K&R-style argument declaration is correctly
// parsed as an external declaration. What went wrong: until we encounter bar, the thing looks like
// a function definition, where the name is followed by a two declarations K&R-style, similar to:
//
// ```
// int foo(i)
// int i; // <-- __attribute__ and typedef occupy this slot, since both are valid declarations.
// { }
// ```
#pragma gnu
int foo (int) __attribute__ ((__nothrow__));
typedef int named;
int bar (int f) { }
/*===
TranslationUnit
ExternalDeclaration
Declaration
DeclarationSpecifier
TypeSpecifier Int
InitDeclarator
Declarator
DeclaratorKind
Identifier "foo"
DerivedDeclarator
FunctionDeclarator
ParameterDeclaration
DeclarationSpecifier
TypeSpecifier Int
Ellipsis None
Extension
Attribute "__nothrow__"
ExternalDeclaration
Declaration
DeclarationSpecifier
StorageClassSpecifier Typedef
DeclarationSpecifier
TypeSpecifier Int
InitDeclarator
Declarator
DeclaratorKind
Identifier "named"
ExternalDeclaration
FunctionDefinition
DeclarationSpecifier
TypeSpecifier Int
Declarator
DeclaratorKind
Identifier "bar"
DerivedDeclarator
FunctionDeclarator
ParameterDeclaration
DeclarationSpecifier
TypeSpecifier Int
Declarator
DeclaratorKind
Identifier "f"
Ellipsis None
Statement Compound
===*/
================================================
FILE: reftests/translation_unit-1781.c
================================================
#pragma gnu
int foo(int a __attribute__((unused)), int b __attribute__((unused))) {}
/*===
TranslationUnit
ExternalDeclaration
FunctionDefinition
DeclarationSpecifier
TypeSpecifier Int
Declarator
DeclaratorKind
Identifier "foo"
DerivedDeclarator
FunctionDeclarator
ParameterDeclaration
DeclarationSpecifier
TypeSpecifier Int
Declarator
DeclaratorKind
Identifier "a"
Extension
Attribute "unused"
ParameterDeclaration
DeclarationSpecifier
TypeSpecifier Int
Declarator
DeclaratorKind
Identifier "b"
Extension
Attribute "unused"
Ellipsis None
Statement Compound
===*/
================================================
FILE: reftests/translation_unit-1961.c
================================================
#pragma gnu
typedef int a;
int foo() {
int a;
}
/*===
TranslationUnit
ExternalDeclaration
Declaration
DeclarationSpecifier
StorageClassSpecifier Typedef
DeclarationSpecifier
TypeSpecifier Int
InitDeclarator
Declarator
DeclaratorKind
Identifier "a"
ExternalDeclaration
FunctionDefinition
DeclarationSpecifier
TypeSpecifier Int
Declarator
DeclaratorKind
Identifier "foo"
DerivedDeclarator KRFunction
Statement Compound
BlockItem
Declaration
DeclarationSpecifier
TypeSpecifier Int
InitDeclarator
Declarator
DeclaratorKind
Identifier "a"
===*/
================================================
FILE: reftests/translation_unit-1993.c
================================================
#pragma gnu
typedef int a;
void foo() {
unsigned int;
const a;
a x;
unsigned a;
a = 1;
}
/*===
TranslationUnit
ExternalDeclaration
Declaration
DeclarationSpecifier
StorageClassSpecifier Typedef
DeclarationSpecifier
TypeSpecifier Int
InitDeclarator
Declarator
DeclaratorKind
Identifier "a"
ExternalDeclaration
FunctionDefinition
DeclarationSpecifier
TypeSpecifier Void
Declarator
DeclaratorKind
Identifier "foo"
DerivedDeclarator KRFunction
Statement Compound
BlockItem
Declaration
DeclarationSpecifier
TypeSpecifier Unsigned
DeclarationSpecifier
TypeSpecifier Int
BlockItem
Declaration
DeclarationSpecifier
TypeQualifier Const
DeclarationSpecifier
TypeSpecifier TypedefName
Identifier "a"
BlockItem
Declaration
DeclarationSpecifier
TypeSpecifier TypedefName
Identifier "a"
InitDeclarator
Declarator
DeclaratorKind
Identifier "x"
BlockItem
Declaration
DeclarationSpecifier
TypeSpecifier Unsigned
InitDeclarator
Declarator
DeclaratorKind
Identifier "a"
BlockItem
Statement
Expression
BinaryOperatorExpression
Expression
Identifier "a"
Expression
Constant
Integer "1"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
BinaryOperator Assign
===*/
================================================
FILE: reftests/translation_unit-2015.c
================================================
// If parameter list treated "a" as a type specifier instead of identifier, this would succeed.
#pragma gnu
typedef int a;
int foo(int a* b) {}
/*===
~ERROR
===*/
================================================
FILE: reftests/translation_unit-2029.c
================================================
// If struct field treated "a" as a type specifier instead of identifier, this would succeed.
#pragma gnu
typedef int a;
struct a { a a, b; };
/*===
TranslationUnit
ExternalDeclaration
Declaration
DeclarationSpecifier
StorageClassSpecifier Typedef
DeclarationSpecifier
TypeSpecifier Int
InitDeclarator
Declarator
DeclaratorKind
Identifier "a"
ExternalDeclaration
Declaration
DeclarationSpecifier
TypeSpecifier
StructType
StructKind Struct
Identifier "a"
StructDeclaration
StructField
SpecifierQualifier
TypeSpecifier TypedefName
Identifier "a"
StructDeclarator
Declarator
DeclaratorKind
Identifier "a"
StructDeclarator
Declarator
DeclaratorKind
Identifier "b"
===*/
================================================
FILE: reftests/translation_unit-2045.c
================================================
// Struct fields maintain a separate
#pragma gnu
typedef int a;
struct a { a a; a b; };
/*===
TranslationUnit
ExternalDeclaration
Declaration
DeclarationSpecifier
StorageClassSpecifier Typedef
DeclarationSpecifier
TypeSpecifier Int
InitDeclarator
Declarator
DeclaratorKind
Identifier "a"
ExternalDeclaration
Declaration
DeclarationSpecifier
TypeSpecifier
StructType
StructKind Struct
Identifier "a"
StructDeclaration
StructField
SpecifierQualifier
TypeSpecifier TypedefName
Identifier "a"
StructDeclarator
Declarator
DeclaratorKind
Identifier "a"
StructDeclaration
StructField
SpecifierQualifier
TypeSpecifier TypedefName
Identifier "a"
StructDeclarator
Declarator
DeclaratorKind
Identifier "b"
===*/
================================================
FILE: reftests/translation_unit-2060.c
================================================
#pragma gnu
typedef int a;
void foo() {
a a;
_Atomic (a) b;
}
/*===
~ERROR
===*/
================================================
FILE: reftests/translation_unit-2070.c
================================================
#pragma gnu
typedef int a;
void foo(int a, _Atomic (a) b) {}
/*===
~ERROR
===*/
================================================
FILE: reftests/translation_unit-2086.c
================================================
// Technically, "a" is defined as a symbol before the "= .." part of the initializer is parsed.
#pragma gnu
typedef int a;
int foo() {
int a = sizeof(_Atomic(a));
}
/*===
~ERROR
===*/
================================================
FILE: reftests/translation_unit-2103.c
================================================
// enum {a} defines a new variable "a" into the current scope. So the next _Atomic(a) must fail.
#pragma gnu
typedef int a;
int foo() {
int x = (enum {a})1;
_Atomic(a) b;
}
/*===
~ERROR
===*/
================================================
FILE: reftests/translation_unit-2114.c
================================================
// enum {a} defines a new variable "a" into the current scope immediately after its declaration.
#pragma gnu
typedef int a;
int foo() {
int x = (enum {a, b = (a)1})1;
}
/*===
~ERROR
===*/
================================================
FILE: reftests/translation_unit-2129.c
================================================
#pragma gnu
typedef int a;
int foo(a a) {}
int bar(int a);
_Atomic (a) b;
/*===
TranslationUnit
ExternalDeclaration
Declaration
DeclarationSpecifier
StorageClassSpecifier Typedef
DeclarationSpecifier
TypeSpecifier Int
InitDeclarator
Declarator
DeclaratorKind
Identifier "a"
ExternalDeclaration
FunctionDefinition
DeclarationSpecifier
TypeSpecifier Int
Declarator
DeclaratorKind
Identifier "foo"
DerivedDeclarator
FunctionDeclarator
ParameterDeclaration
DeclarationSpecifier
TypeSpecifier TypedefName
Identifier "a"
Declarator
DeclaratorKind
Identifier "a"
Ellipsis None
Statement Compound
ExternalDeclaration
Declaration
DeclarationSpecifier
TypeSpecifier Int
InitDeclarator
Declarator
DeclaratorKind
Identifier "bar"
DerivedDeclarator
FunctionDeclarator
ParameterDeclaration
DeclarationSpecifier
TypeSpecifier Int
Declarator
DeclaratorKind
Identifier "a"
Ellipsis None
ExternalDeclaration
Declaration
DeclarationSpecifier
TypeSpecifier Atomic
TypeName
SpecifierQualifier
TypeSpecifier TypedefName
Identifier "a"
InitDeclarator
Declarator
DeclaratorKind
Identifier "b"
===*/
================================================
FILE: reftests/translation_unit-2147.c
================================================
#pragma gnu
void foo() {
typedef int a;
{
a a;
}
_Atomic (a) b;
}
/*===
TranslationUnit
ExternalDeclaration
FunctionDefinition
DeclarationSpecifier
TypeSpecifier Void
Declarator
DeclaratorKind
Identifier "foo"
DerivedDeclarator KRFunction
Statement Compound
BlockItem
Declaration
DeclarationSpecifier
StorageClassSpecifier Typedef
DeclarationSpecifier
TypeSpecifier Int
InitDeclarator
Declarator
DeclaratorKind
Identifier "a"
BlockItem
Statement Compound
BlockItem
Declaration
DeclarationSpecifier
TypeSpecifier TypedefName
Identifier "a"
InitDeclarator
Declarator
DeclaratorKind
Identifier "a"
BlockItem
Declaration
DeclarationSpecifier
TypeSpecifier Atomic
TypeName
SpecifierQualifier
TypeSpecifier TypedefName
Identifier "a"
InitDeclarator
Declarator
DeclaratorKind
Identifier "b"
===*/
================================================
FILE: reftests/translation_unit-2167.c
================================================
#pragma gnu
typedef int a;
void foo() {
for (a a;;)
a = a;
while (true) {int a;}
do { int a; } while(true);
_Atomic (a) b;
}
/*===
TranslationUnit
ExternalDeclaration
Declaration
DeclarationSpecifier
StorageClassSpecifier Typedef
DeclarationSpecifier
TypeSpecifier Int
InitDeclarator
Declarator
DeclaratorKind
Identifier "a"
ExternalDeclaration
FunctionDefinition
DeclarationSpecifier
TypeSpecifier Void
Declarator
DeclaratorKind
Identifier "foo"
DerivedDeclarator KRFunction
Statement Compound
BlockItem
Statement
ForStatement
ForInitializer
Declaration
DeclarationSpecifier
TypeSpecifier TypedefName
Identifier "a"
InitDeclarator
Declarator
DeclaratorKind
Identifier "a"
Statement
Expression
BinaryOperatorExpression
Expression
Identifier "a"
Expression
Identifier "a"
BinaryOperator Assign
BlockItem
Statement
WhileStatement
Expression
Identifier "true"
Statement Compound
BlockItem
Declaration
DeclarationSpecifier
TypeSpecifier Int
InitDeclarator
Declarator
DeclaratorKind
Identifier "a"
BlockItem
Statement
DoWhileStatement
Statement Compound
BlockItem
Declaration
DeclarationSpecifier
TypeSpecifier Int
InitDeclarator
Declarator
DeclaratorKind
Identifier "a"
Expression
Identifier "true"
BlockItem
Declaration
DeclarationSpecifier
TypeSpecifier Atomic
TypeName
SpecifierQualifier
TypeSpecifier TypedefName
Identifier "a"
InitDeclarator
Declarator
DeclaratorKind
Identifier "b"
===*/
================================================
FILE: reftests/translation_unit-2190.c
================================================
// Test that scope of "if" condition and statement is cleaned up.
#pragma gnu
typedef int a, b;
int x;
void foo() {
if (sizeof(enum {a})) x = sizeof(enum{b});
else x = b;
switch (sizeof(enum {b})) x = b;
a x, y;
b z, w;
}
/*===
TranslationUnit
ExternalDeclaration
Declaration
DeclarationSpecifier
StorageClassSpecifier Typedef
DeclarationSpecifier
TypeSpecifier Int
InitDeclarator
Declarator
DeclaratorKind
Identifier "a"
InitDeclarator
Declarator
DeclaratorKind
Identifier "b"
ExternalDeclaration
Declaration
DeclarationSpecifier
TypeSpecifier Int
InitDeclarator
Declarator
DeclaratorKind
Identifier "x"
ExternalDeclaration
FunctionDefinition
DeclarationSpecifier
TypeSpecifier Void
Declarator
DeclaratorKind
Identifier "foo"
DerivedDeclarator KRFunction
Statement Compound
BlockItem
Statement
IfStatement
Expression
SizeOfTy
TypeName
SpecifierQualifier
TypeSpecifier
EnumType
Enumerator
Identifier "a"
Statement
Expression
BinaryOperatorExpression
Expression
Identifier "x"
Expression
SizeOfTy
TypeName
SpecifierQualifier
TypeSpecifier
EnumType
Enumerator
Identifier "b"
BinaryOperator Assign
Statement
Expression
BinaryOperatorExpression
Expression
Identifier "x"
Expression
Identifier "b"
BinaryOperator Assign
BlockItem
Statement
SwitchStatement
Expression
SizeOfTy
TypeName
SpecifierQualifier
TypeSpecifier
EnumType
Enumerator
Identifier "b"
Statement
Expression
BinaryOperatorExpression
Expression
Identifier "x"
Expression
Identifier "b"
BinaryOperator Assign
BlockItem
Declaration
DeclarationSpecifier
TypeSpecifier TypedefName
Identifier "a"
InitDeclarator
Declarator
DeclaratorKind
Identifier "x"
InitDeclarator
Declarator
DeclaratorKind
Identifier "y"
BlockItem
Declaration
DeclarationSpecifier
TypeSpecifier TypedefName
Identifier "b"
InitDeclarator
Declarator
DeclaratorKind
Identifier "z"
InitDeclarator
Declarator
DeclaratorKind
Identifier "w"
===*/
================================================
FILE: reftests/translation_unit-2208.c
================================================
// Test that "if" condition enum constants are defined within its scope.
#pragma gnu
typedef int a;
void foo() {
int x;
if (sizeof(enum {a})) x = (_Atomic(a))1;
}
/*===
~ERROR
===*/
================================================
FILE: reftests/translation_unit-2270.c
================================================
#pragma gnu
__extension__ union { long l; };
/*===
TranslationUnit
ExternalDeclaration
Declaration
DeclarationSpecifier
TypeSpecifier
StructType
StructKind Union
StructDeclaration
StructField
SpecifierQualifier
TypeSpecifier Long
StructDeclarator
Declarator
DeclaratorKind
Identifier "l"
===*/
================================================
FILE: reftests/translation_unit-2300.c
================================================
#pragma gnu
__extension__ _Static_assert(1,"ERR");
/*===
TranslationUnit
ExternalDeclaration
StaticAssert
Expression
Constant
Integer "1"
IntegerBase Decimal
IntegerSuffix false false
IntegerSize Int
StringLiteral ["\"ERR\""]
===*/
================================================
FILE: reftests/translation_unit-2373.c
================================================
#pragma gnu
int main(argc, argv) int argc; char **argv; { }
/*===
TranslationUnit
ExternalDeclaration
FunctionDefinition
DeclarationSpecifier
TypeSpecifier Int
Declarator
DeclaratorKind
Identifier "main"
DerivedDeclarator KRFunction
Identifier "argc"
Identifier "argv"
Declaration
DeclarationSpecifier
TypeSpecifier Int
InitDeclarator
Declarator
DeclaratorKind
Identifier "argc"
Declaration
DeclarationSpecifier
TypeSpecifier Char
InitDeclarator
Declarator
DeclaratorKind
Identifier "argv"
DerivedDeclarator Pointer
DerivedDeclarator Pointer
Statement Compound
===*/
================================================
FILE: reftests/translation_unit-31-semicolon.c
================================================
#pragma gnu
void f(void) {
};
/*===
TranslationUnit
ExternalDeclaration
FunctionDefinition
DeclarationSpecifier
TypeSpecifier Void
Declarator
DeclaratorKind
Identifier "f"
DerivedDeclarator
FunctionDeclarator
ParameterDeclaration
DeclarationSpecifier
TypeSpecifier Void
Ellipsis None
Statement Compound
===*/
================================================
FILE: src/ast.rs
================================================
//! Abstract syntax tree
//!
//! Types in this module represent various pieces a C program can
//! contain after preprocessing phase. They mostly follow C11 grammar
//! naming conventions.
//!
//! References to C11 standard given in parenthesis refer to the
//! [ISO/IEC 9899:201x
//! draft](http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf)
//! published on April 12, 2011.
//!
//! A number of GNU extensions to the standard C are included here.
//! Types, struct fields or enum variants specific to GNU are marked as
//! "GNU extension" with a link to the relevant section of gcc
//! documentation. Supported extensions are:
//!
//! - attributes in various positions
//! - inline assembly statements and asm labels
//! - extensions to the initializer list syntax
//! - statement expressions
//! - `typeof` type specifiers
use span::Node;
// From 6.4 Lexical elements
/// Variable, function and other names that are not type names
///
/// (C11 6.4.2)
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
pub struct Identifier {
pub name: String,
}
/// Constant literals
///
/// C11 places string literals under primary expressions, thus they
/// are not included here.
///
/// (C11 6.4.4)
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
pub enum Constant {
Integer(Integer),
Float(Float),
Character(String),
}
/// Integer number literal
///
/// (C11 6.4.4.1)
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
pub struct Integer {
pub base: IntegerBase,
pub number: Box<str>,
pub suffix: IntegerSuffix,
}
/// Base of the integer literal
///
/// (C11 6.4.4.1)
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
pub enum IntegerBase {
Decimal,
Octal,
Hexadecimal,
/// [GNU extension](https://gcc.gnu.org/onlinedocs/gcc/Binary-constants.html)
Binary,
}
/// Suffix of an integer literal
///
/// (C11 6.4.4.1)
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
pub struct IntegerSuffix {
/// Minimum size of the integer literal
pub size: IntegerSize,
/// Integer literal has unsigned type
pub unsigned: bool,
/// Integer literal is an imaginary part of a complex number
///
/// [GNU extension](https://gcc.gnu.org/onlinedocs/gcc/Complex.html) suffixes `i` and `j`.
pub imaginary: bool,
}
/// Size part of a integer literal suffix
///
/// (C11 6.4.4.1)
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)]
pub enum IntegerSize {
/// no `l` or `ll`
Int = 0,
/// `l`
Long,
/// `ll`
LongLong,
}
/// Floating point number literal
///
/// (C11 6.4.4.2)
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
pub struct Float {
pub base: FloatBase,
pub number: Box<str>,
pub suffix: FloatSuffix,
}
/// Floating point number base
///
/// (C11 6.4.4.2)
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
pub enum FloatBase {
Decimal,
Hexadecimal,
}
/// Floating point number suffix
///
/// (C11 6.4.4.2)
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
pub struct FloatSuffix {
pub format: FloatFormat,
/// Integer literal is an imaginary part of a complex number
///
/// [GNU extension](https://gcc.gnu.org/onlinedocs/gcc/Complex.html) suffixes `i` and `j`.
pub imaginary: bool,
}
/// Floating point literal format specified by the suffix
///
/// (C11 6.4.4.2)
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
pub enum FloatFormat {
/// `f` suffix
Float,
/// no suffix
Double,
/// `l` suffix
LongDouble,
/// [ISO/IEC TS 18661-2:2015](http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1912.pdf)
/// `df`, `dd`, `dl` suffixes
///
/// [ISO/IEC TS 18661-3:2015](http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1945.pdf)
/// `fN`, `fNx`, `dN`, `dNx` suffixes
TS18661Format(TS18661FloatType),
}
/// String literal
///
/// (C11 6.4.5)
pub type StringLiteral = Vec<String>;
// From 6.5 Expressions
/// Expressions
///
/// (C11 6.5)
#[derive(Debug, PartialEq, Clone)]
pub enum Expression {
/// Identifier
///
/// May be a variable, function name or enumerator. The latter is
/// different from the standard, where enumerators are classified
/// as constants.
///
/// (C11 6.5.1)
Identifier(Box<Node<Identifier>>),
/// Numeric and character constants
///
/// Enumerator constants, being valid identifiers, are reprented
/// as `Identifier` in this enum.
///
/// (C11 6.5.1)
Constant(Box<Node<Constant>>),
/// String literal
///
/// (C11 6.5.1)
StringLiteral(Box<Node<StringLiteral>>),
/// Generic selection
///
/// (C11 6.5.1.1)
GenericSelection(Box<Node<GenericSelection>>),
/// Structure and union members
///
/// Both direct (`.`) and indirect (`->`) access.
///
/// (C11 6.5.2)
Member(Box<Node<MemberExpression>>),
/// Function call expression
///
/// (C11 6.5.2)
Call(Box<Node<CallExpression>>),
/// Compound literal
///
/// (C11 6.5.2)
CompoundLiteral(Box<Node<CompoundLiteral>>),
/// Size of a type
///
/// (C11 6.5.3)
SizeOfTy(Box<Node<SizeOfTy>>),
/// Size of a unary expression
///
/// (C11 6.5.3)
SizeOfVal(Box<Node<SizeOfVal>>),
/// Alignment of a type
///
/// (C11 6.5.3)
AlignOf(Box<Node<AlignOf>>),
/// Unary operators
///
/// This represents both postfix and prefix unary oprators. Postfix expressions that take
/// additional operands are represented by a separate entry in this enum.
///
/// (C11 6.5.2, c11 6.5.3)
UnaryOperator(Box<Node<UnaryOperatorExpression>>),
/// Cast expression
///
/// `(type) expr`
///
/// (C11 6.5.4)
Cast(Box<Node<CastExpression>>),
/// Binary operators
///
/// All of C binary operators that can be applied to two expressions.
///
/// (C11 6.5.5 -- 6.5.16)
BinaryOperator(Box<Node<BinaryOperatorExpression>>),
/// Conditional operator
///
/// (C11 6.5.15)
Conditional(Box<Node<ConditionalExpression>>),
/// Comma operator
///
/// (C11 6.5.17)
Comma(Box<Vec<Node<Expression>>>),
/// Member offset expression
///
/// Result of expansion of `offsetof` macro.
///
/// (C11 7.19 §3).
OffsetOf(Box<Node<OffsetOfExpression>>),
/// Variable argument list access
///
/// Result of expansion of `va_arg` macro.
///
/// (C11 7.16.1.1).
VaArg(Box<Node<VaArgExpression>>),
/// Statement expression
///
/// [GNU extension](https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html)
Statement(Box<Node<Statement>>),
}
/// Struct or union member access
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
pub enum MemberOperator {
/// `expression.identifier`
Direct,
/// `expression->identifier`
Indirect,
}
/// Generic selection expression
///
/// (C11 6.5.1.1)
#[derive(Debug, PartialEq, Clone)]
pub struct GenericSelection {
pub expression: Box<Node<Expression>>,
pub associations: Vec<Node<GenericAssociation>>,
}
/// Single element of a generic selection expression
///
/// (C11 6.5.1.1)
#[derive(Debug, PartialEq, Clone)]
pub enum GenericAssociation {
Type(Node<GenericAssociationType>),
Default(Box<Node<Expression>>),
}
/// Type match case in a generic selection expression
///
/// (C11 6.5.1.1)
#[derive(Debug, PartialEq, Clone)]
pub struct GenericAssociationType {
pub type_name: Node<TypeName>,
pub expression: Box<Node<Expression>>,
}
/// Structure and union members
///
/// Both direct (`.`) and indirect (`->`) access.
///
/// (C11 6.5.2)
#[derive(Debug, PartialEq, Clone)]
pub struct MemberExpression {
pub operator: Node<MemberOperator>,
pub expression: Box<Node<Expression>>,
pub identifier: Node<Identifier>,
}
/// Function call expression
///
/// (C11 6.5.2)
#[derive(Debug, PartialEq, Clone)]
pub struct CallExpression {
pub callee: Box<Node<Expression>>,
pub arguments: Vec<Node<Expression>>,
}
/// Compound literal
///
/// (C11 6.5.2)
#[derive(Debug, PartialEq, Clone)]
pub struct CompoundLiteral {
pub type_name: Node<TypeName>,
pub initializer_list: Vec<Node<InitializerListItem>>,
}
/// SizeOf a type
///
/// (C11 6.5.3)
#[derive(Debug, PartialEq, Clone)]
pub struct SizeOfTy(pub Node<TypeName>);
/// Size of an unary expression
///
/// (C11 6.5.3)
#[derive(Debug, PartialEq, Clone)]
pub struct SizeOfVal(pub Box<Node<Expression>>);
/// Alignment of a type
///
/// (C11 6.5.3)
#[derive(Debug, PartialEq, Clone)]
pub struct AlignOf(pub Box<Node<TypeName>>);
/// All operators with one operand
///
/// (C11 6.5)
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
pub enum UnaryOperator {
/// `operand++`
PostIncrement,
/// `operand--`
PostDecrement,
/// `++operand`
PreIncrement,
/// `--operand`
PreDecrement,
/// `&operand`
Address,
/// `*operand`
Indirection,
/// `+operand`
Plus,
/// `-operand`
Minus,
/// `~operand`
Complement,
/// `!operand`
Negate,
}
/// Unary operator expression
///
/// This represents both postfix and prefix unary oprators. Postfix expressions that take
/// additional operands are represented by a separate entry in this enum.
///
/// (C11 6.5.2, c11 6.5.3)
#[derive(Debug, PartialEq, Clone)]
pub struct UnaryOperatorExpression {
pub operator: Node<UnaryOperator>,
pub operand: Box<Node<Expression>>,
}
/// Cast expression
///
/// `(type) expr`
///
/// (C11 6.5.4)
#[derive(Debug, PartialEq, Clone)]
pub struct CastExpression {
pub type_name: Node<TypeName>,
pub expression: Box<Node<Expression>>,
}
/// All operators with two operands
///
/// (C11 6.5)
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
pub enum BinaryOperator {
/// `lhs[rhs]`
Index,
/// `lhs * rhs`
Multiply,
/// `lhs / rhs`
Divide,
/// `lhs % rhs`
Modulo,
/// `lhs + rhs`
Plus,
/// `lhs - rhs`
Minus,
/// `lhs << rhs`
ShiftLeft,
/// `lhs >> rhs`
ShiftRight,
/// `lhs < rhs`
Less,
/// `lhs > rhs`
Greater,
/// `lhs <= rhs`
LessOrEqual,
/// `lhs >= rhs`
GreaterOrEqual,
/// `lhs == rhs`
Equals,
/// `lhs != rhs`
NotEquals,
/// `lhs & rhs`
BitwiseAnd,
/// `lhs ^ rhs`
BitwiseXor,
/// `lhs | rhs`
BitwiseOr,
/// `lhs && rhs`
LogicalAnd,
/// `lhs || rhs`
LogicalOr,
/// `lhs = rhs`
Assign,
/// `lhs *= rhs`
AssignMultiply,
/// `lhs /= rhs`
AssignDivide,
/// `lhs %= rhs`
AssignModulo,
/// `lhs += rhs`
AssignPlus,
/// `lhs -= rhs`
AssignMinus,
/// `lhs <<= rhs`
AssignShiftLeft,
/// `lhs >>= rhs`
AssignShiftRight,
/// `lhs &= rhs`
AssignBitwiseAnd,
/// `lhs ^= rhs`
AssignBitwiseXor,
/// `lhs |= rhs`
AssignBitwiseOr,
}
/// Binary operators
///
/// All of C binary operators that can be applied to two expressions.
///
/// (C11 6.5.5 -- 6.5.16)
#[derive(Debug, PartialEq, Clone)]
pub struct BinaryOperatorExpression {
pub operator: Node<BinaryOperator>,
pub lhs: Box<Node<Expression>>,
pub rhs: Box<Node<Expression>>,
}
/// Conditional operator
///
/// (C11 6.5.15)
#[derive(Debug, PartialEq, Clone)]
pub struct ConditionalExpression {
pub condition: Box<Node<Expression>>,
pub then_expression: Box<Node<Expression>>,
pub else_expression: Box<Node<Expression>>,
}
/// Variable argument list access
///
/// Result of expansion of `va_arg` macro.
///
/// (C11 7.16.1.1).
#[derive(Debug, PartialEq, Clone)]
pub struct VaArgExpression {
pub va_list: Box<Node<Expression>>,
pub type_name: Node<TypeName>,
}
/// Member offset expression
///
/// Result of expansion of `offsetof` macro.
///
/// (C11 7.19 §3).
#[derive(Debug, PartialEq, Clone)]
pub struct OffsetOfExpression {
pub type_name: Node<TypeName>,
pub designator: Node<OffsetDesignator>,
}
/// Offset designator in a `offsetof` macro expansion
///
/// (C11 7.19 §3).
#[derive(Debug, PartialEq, Clone)]
pub struct OffsetDesignator {
pub base: Node<Identifier>,
pub members: Vec<Node<OffsetMember>>,
}
/// Single element of an offset designator
///
/// (C11 7.19 §3).
#[derive(Debug, PartialEq, Clone)]
pub enum OffsetMember {
Member(Node<Identifier>),
IndirectMember(Node<Identifier>),
Index(Node<Expression>),
}
// From 6.7 Declarations
/// Variable, function or type declaration
///
/// (C11 6.7)
#[derive(Debug, PartialEq, Clone)]
pub struct Declaration {
pub specifiers: Vec<Node<DeclarationSpecifier>>,
pub declarators: Vec<Node<InitDeclarator>>,
}
/// Common part of a declaration
///
/// These apply to all declarators in a declaration.
///
/// (C11 6.7)
#[derive(Debug, PartialEq, Clone)]
pub enum DeclarationSpecifier {
StorageClass(Node<StorageClassSpecifier>),
TypeSpecifier(Node<TypeSpecifier>),
TypeQualifier(Node<TypeQualifier>),
Function(Node<FunctionSpecifier>),
Alignment(Node<AlignmentSpecifier>),
/// Vendor-specific declaration extensions that can be mixed with standard specifiers
Extension(Vec<Node<Extension>>),
}
/// Defines a single name in a declaration
///
/// (C11 6.7.6)
#[derive(Debug, PartialEq, Clone)]
pub struct InitDeclarator {
pub declarator: Node<Declarator>,
pub initializer: Option<Node<Initializer>>,
}
// From 6.7.1
/// Storage class
///
/// (C11 6.7.1)
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
pub enum StorageClassSpecifier {
/// `typedef`
Typedef,
/// `extern`
Extern,
/// `static`
Static,
/// `_Thread_local`
ThreadLocal,
/// `auto`
Auto,
/// `register`
Register,
}
// From 6.7.2
/// Type specifier
///
/// (C11 6.7.2)
#[derive(Debug, PartialEq, Clone)]
pub enum TypeSpecifier {
/// `void`
Void,
/// `char`
Char,
/// `short`
Short,
/// `int`
Int,
/// `long`
Long,
/// `float`
Float,
/// `double`
Double,
/// `signed`
///
/// `__signed`, `__signed__` (GNU extension)
Signed,
/// `unsigned`
Unsigned,
/// `_Bool`
Bool,
/// `_Complex`
///
/// `__complex`, `__complex__` (GNU extension)
Complex,
/// `_Atomic(typename)`
Atomic(Node<TypeName>),
/// `struct identifier { … }`
///
/// `union identifier { … }`
Struct(Node<StructType>),
/// `enum identifier { … }`
Enum(Node<EnumType>),
/// Name of a previously defined type
TypedefName(Node<Identifier>),
/// Specifies type of another type or expression
///
/// [GNU extension](https://gcc.gnu.org/onlinedocs/gcc/Typeof.html)
TypeOf(Node<TypeOf>),
/// Floating point types with guaranteed width and representation
///
/// `_Float16`, `_Float32`, `_Float64`, `_Float128`
///
/// `_Float16x`, `_Float32x`, `_Float64x`, `_Float128x`
///
/// `_Decimal16`, `_Decimal32`, `_Decimal64`, `_Decimal128`
///
/// `_Decimal16x`, `_Decimal32x`, `_Decimal64x`, `_Decimal128x`
///
/// [ISO/IEC TS 18661-3:2015](http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1945.pdf)
TS18661Float(TS18661FloatType),
}
/// Floating point type with guaranteed width and format
///
/// [ISO/IEC TS 18661-3:2015](http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1945.pdf)
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
pub struct TS18661FloatType {
pub format: TS18661FloatFormat,
pub width: usize,
}
/// Floating point formats
///
/// [ISO/IEC TS 18661-3:2015](http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1945.pdf)
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
pub enum TS18661FloatFormat {
BinaryInterchange,
BinaryExtended,
DecimalInterchange,
DecimalExtended,
}
// From 6.7.2.1
/// Structure or union type specifier
///
/// (C11 6.7.2.1)
#[derive(Debug, PartialEq, Clone)]
pub struct StructType {
pub kind: Node<StructKind>,
pub identifier: Option<Node<Identifier>>,
/// List of structure of union members, when present.
///
/// A [GNU extension](https://gcc.gnu.org/onlinedocs/gcc-8.1.0/gcc/Empty-Structures.html) allows the list to be empty.
pub declarations: Option<Vec<Node<StructDeclaration>>>,
}
/// The only difference between a `struct` and a `union`
///
/// (C11 6.7.2.1)
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
pub enum StructKind {
Struct,
Union,
}
/// Single declaration in a struct or a union
///
/// (C11 6.7.2.1)
#[derive(Debug, PartialEq, Clone)]
pub enum StructDeclaration {
Field(Node<StructField>),
StaticAssert(Node<StaticAssert>),
}
/// Struct field declaration
#[derive(Debug, PartialEq, Clone)]
pub struct StructField {
pub specifiers: Vec<Node<SpecifierQualifier>>,
pub declarators: Vec<Node<StructDeclarator>>,
}
/// Type and qualifiers for a struct declaration
///
/// C11 also uses this type in a few other places.
///
/// (C11 6.7.2.1)
#[derive(Debug, PartialEq, Clone)]
pub enum SpecifierQualifier {
TypeSpecifier(Node<TypeSpecifier>),
TypeQualifier(Node<TypeQualifier>),
Extension(Vec<Node<Extension>>),
}
/// Field declarator for a struct or a union
///
/// (C11 6.7.2.1)
#[derive(Debug, PartialEq, Clone)]
pub struct StructDeclarator {
pub declarator: Option<Node<Declarator>>,
pub bit_width: Option<Box<Node<Expression>>>,
}
// From 6.7.2.2
/// Enumeration type specifier
///
/// (C11 6.7.2.2)
#[derive(Debug, PartialEq, Clone)]
pub struct EnumType {
pub identifier: Option<Node<Identifier>>,
pub enumerators: Vec<Node<Enumerator>>,
}
/// Single constant inside a `enum` definition
///
/// (C11 6.7.2.2)
#[derive(Debug, PartialEq, Clone)]
pub struct Enumerator {
pub identifier: Node<Identifier>,
pub expression: Option<Box<Node<Expression>>>,
pub extensions: Vec<Node<Extension>>,
}
// From 6.7.3
/// Type qualifier
///
/// (C11 6.7.3)
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
pub enum TypeQualifier {
/// `const`
///
/// `__const` (GNU extension)
Const,
/// `restrict`
///
/// `__restrict`, `__restrict__` (GNU extension)
Restrict,
/// `volatile`
///
/// `__volatile`, `__volatile__` (GNU extension)
Volatile,
/// '_Nonnull' (Clang extension)
///
/// [Clang extension](https://clang.llvm.org/docs/AttributeReference.html)
Nonnull,
/// '_Null_unspecified' (Clang extension)
///
/// [Clang extension](https://clang.llvm.org/docs/AttributeReference.html)
NullUnspecified,
/// '_Nullable' (Clang extension)
///
/// [Clang extension](https://clang.llvm.org/docs/AttributeReference.html)
Nullable,
/// `_Atomic`
Atomic,
}
// From 6.7.4
/// Function specifier
///
/// (C11 6.7.4)
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
pub enum FunctionSpecifier {
/// `inline`
///
/// `__inline`, `__inline__` (GNU extension)
Inline,
/// `_Noreturn`
Noreturn,
}
// From 6.7.5
/// Alignment specifier
///
/// (C11 6.7.5)
#[derive(Debug, PartialEq, Clone)]
pub enum AlignmentSpecifier {
/// `_Alignas(typename)`
Type(Node<TypeName>),
/// `_Alignas(expression)`
Constant(Box<Node<Expression>>),
}
// From 6.7.6 Declarators
/// Single item in a declaration
///
/// Represents both normal and abstract declarators.
///
/// (C11 6.7.6, 6.7.7)
#[derive(Debug, PartialEq, Clone)]
pub struct Declarator {
/// What is being declared
pub kind: Node<DeclaratorKind>,
/// Contains pointer, array and function declarator elements
pub derived: Vec<Node<DerivedDeclarator>>,
/// Vendor-specific extensions
pub extensions: Vec<Node<Extension>>,
}
/// Name of a declarator
///
/// (C11 6.7.6, 6.7.7)
#[derive(Debug, PartialEq, Clone)]
pub enum DeclaratorKind {
/// Unnamed declarator
///
/// E.g. part of a function prototype without parameter names.
Abstract,
/// Named declarator
///
/// E.g. a variable or a named function parameter.
Identifier(Node<Identifier>),
/// Nested declarator
///
/// Any group of parenthesis inside a declarator. E.g. pointer to
/// a function.
Declarator(Box<Node<Declarator>>),
}
/// Modifies declarator type
///
/// (C11 6.7.6)
#[derive(Debug, PartialEq, Clone)]
pub enum DerivedDeclarator {
/// `* qualifiers …`
Pointer(Vec<Node<PointerQualifier>>),
/// `… []`
Array(Node<ArrayDeclarator>),
/// `… ( parameters )`
Function(Node<FunctionDeclarator>),
/// `… ( identifiers )`
KRFunction(Vec<Node<Identifier>>),
/// `^ qualifiers …`
///
/// [Clang extension](https://clang.llvm.org/docs/BlockLanguageSpec.html)
Block(Vec<Node<PointerQualifier>>),
}
/// Array part of a declarator
#[derive(Debug, PartialEq, Clone)]
pub struct ArrayDeclarator {
pub qualifiers: Vec<Node<TypeQualifier>>,
pub size: ArraySize,
}
/// Function parameter part of a declarator
#[derive(Debug, PartialEq, Clone)]
pub struct FunctionDeclarator {
pub parameters: Vec<Node<ParameterDeclaration>>,
pub ellipsis: Ellipsis,
}
/// List of qualifiers that can follow a `*` in a declaration
///
/// (C11 6.7.6.1)
#[derive(Debug, PartialEq, Clone)]
pub enum PointerQualifier {
TypeQualifier(Node<TypeQualifier>),
Extension(Vec<Node<Extension>>),
}
/// Size of an array in a declaration
///
/// (C11 6.7.6.2)
#[derive(Debug, PartialEq, Clone)]
pub enum ArraySize {
/// `[]`
Unknown,
/// `[*]`
VariableUnknown,
/// `[10]`
VariableExpression(Box<Node<Expression>>),
/// `[static 10]`
StaticExpression(Box<Node<Expression>>),
}
/// Complete parameter declaration in a function prototype or declaration
///
/// This is so called "new-style" or "C89" parameter declaration that
/// follows in parenthesis after a function name. "Old-style" or "K&R"
/// function parameter declarations are collected in the
/// `FunctionDefinition::declarations` field.
///
/// (C11 6.7.6.3)
#[derive(Debug, PartialEq, Clone)]
pub struct ParameterDeclaration {
pub specifiers: Vec<Node<DeclarationSpecifier>>,
pub declarator: Option<Node<Declarator>>,
pub extensions: Vec<Node<Extension>>,
}
/// Whether function signature ends with a `...`
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
pub enum Ellipsis {
Some,
None,
}
// From 6.7.7 Type names
/// References to types outside of declarations
///
/// Type names contain only abstract declarators.
///
/// (C11 6.7.7)
#[derive(Debug, PartialEq, Clone)]
pub struct TypeName {
pub specifiers: Vec<Node<SpecifierQualifier>>,
pub declarator: Option<Node<Declarator>>,
}
// From 6.7.9 Initialization
/// Value that is assigned immediately in a declaration
///
/// (C11 6.7.9)
#[derive(Debug, PartialEq, Clone)]
pub enum Initializer {
Expression(Box<Node<Expression>>),
List(Vec<Node<InitializerListItem>>),
}
/// Initializes one field or array element in a initializer list
///
/// (C11 6.7.9)
#[derive(Debug, PartialEq, Clone)]
pub struct InitializerListItem {
pub designation: Vec<Node<Designator>>,
pub initializer: Box<Node<Initializer>>,
}
/// Single element of an designation in an initializer
#[derive(Debug, PartialEq, Clone)]
pub enum Designator {
/// Array element
///
/// `{ [expression] = … }`
///
/// `{ [expression] … }` (obsolete GNU extension)
Index(Node<Expression>),
/// Struct or union member
///
/// `{ .identifier = … }`
///
/// `{ identifier: … }` (obsolete GNU extension)
Member(Node<Identifier>),
/// Range of array elements
///
/// `{ [from ... to] … }`
/// ([GNU extension](https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html#Designated-Inits))
Range(Node<RangeDesignator>),
}
/// Range array designator in an initializer
///
/// `[from ... to]`
///
/// ([GNU extension](https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html#Designated-Inits))
#[derive(Debug, PartialEq, Clone)]
pub struct RangeDesignator {
pub from: Node<Expression>,
pub to: Node<Expression>,
}
// From 6.7.10 Static assertions
/// Static assertion
///
/// (C11 6.7.10)
#[derive(Debug, PartialEq, Clone)]
pub struct StaticAssert {
pub expression: Box<Node<Expression>>,
pub message: Node<StringLiteral>,
}
// From 6.8 Statement
/// Element of a function body
///
/// (C11 6.8)
#[derive(Debug, PartialEq, Clone)]
pub enum Statement {
Labeled(Node<LabeledStatement>),
Compound(Vec<Node<BlockItem>>),
Expression(Option<Box<Node<Expression>>>),
If(Node<IfStatement>),
Switch(Node<SwitchStatement>),
While(Node<WhileStatement>),
DoWhile(Node<DoWhileStatement>),
For(Node<ForStatement>),
Goto(Node<Identifier>),
Continue,
Break,
Return(Option<Box<Node<Expression>>>),
/// Vendor specific inline assembly extensions
Asm(Node<AsmStatement>),
}
/// Labeled statement
///
/// (C11 6.8.1)
#[derive(Debug, PartialEq, Clone)]
pub struct LabeledStatement {
pub label: Node<Label>,
pub statement: Box<Node<Statement>>,
}
/// If statement
///
/// (C11 6.8.4)
#[derive(Debug, PartialEq, Clone)]
pub struct IfStatement {
pub condition: Box<Node<Expression>>,
pub then_statement: Box<Node<Statement>>,
pub else_statement: Option<Box<Node<Statement>>>,
}
/// Switch statement
///
/// (C11 6.8.4)
#[derive(Debug, PartialEq, Clone)]
pub struct SwitchStatement {
pub expression: Box<Node<Expression>>,
pub statement: Box<Node<Statement>>,
}
/// While statement
///
/// (C11 6.8.5)
#[derive(Debug, PartialEq, Clone)]
pub struct WhileStatement {
pub expression: Box<Node<Expression>>,
pub statement: Box<Node<Statement>>,
}
/// Do statement
///
/// (C11 6.8.5)
#[derive(Debug, PartialEq, Clone)]
pub struct DoWhileStatement {
pub statement: Box<Node<Statement>>,
pub expression: Box<Node<Expression>>,
}
/// For statement
///
/// (C11 6.8.5)
#[derive(Debug, PartialEq, Clone)]
pub struct ForStatement {
pub initializer: Node<ForInitializer>,
pub condition: Option<Box<Node<Expression>>>,
pub step: Option<Box<Node<Expression>>>,
pub statement: Box<Node<Statement>>,
}
/// Statement labels for `goto` and `switch`
#[derive(Debug, PartialEq, Clone)]
pub enum Label {
/// Goto label
///
/// `ident: …`
Identifier(Node<Identifier>),
/// Case in a `switch` statement
///
/// `case 'a': …`
Case(Box<Node<Expression>>),
/// Case with a range in a `switch` statement
///
/// `case 'a' ... 'z': …`
///
/// [GNU extension](https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html)
CaseRange(Node<CaseRange>),
/// Default case in a `switch` statement
///
/// `default: …`
Default,
}
/// Case range expression
///
/// `from ... to`
///
/// [GNU extension](https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html)
#[derive(Debug, PartialEq, Clone)]
pub struct CaseRange {
pub low: Box<Node<Expression>>,
pub high: Box<Node<Expression>>,
}
/// First element of a `for` statement
#[derive(Debug, PartialEq, Clone)]
pub enum ForInitializer {
/// `for(; …)`
Empty,
/// `for(a = 1; …)`
Expression(Box<Node<Expression>>),
/// `for(int a = 1; …)`
Declaration(Node<Declaration>),
/// `for(_StaticAssert(…); …)`
StaticAssert(Node<StaticAssert>),
}
// From 6.8.2
/// Element of a compound statement
#[derive(Debug, PartialEq, Clone)]
pub enum BlockItem {
Declaration(Node<Declaration>),
StaticAssert(Node<StaticAssert>),
Statement(Node<Statement>),
}
// From 6.9 External definitions
/// Entire C source file after preprocessing
///
/// (C11 6.9)
#[derive(Debug, PartialEq, Clone)]
pub struct TranslationUnit(pub Vec<Node<ExternalDeclaration>>);
/// Top-level elements of a C program
///
/// (C11 6.9)
#[derive(Debug, PartialEq, Clone)]
pub enum ExternalDeclaration {
Declaration(Node<Declaration>),
StaticAssert(Node<StaticAssert>),
FunctionDefinition(Node<FunctionDefinition>),
}
/// Function definition
///
/// (C11 6.9.1)
#[derive(Debug, PartialEq, Clone)]
pub struct FunctionDefinition {
/// Return type of the function, possibly mixed with other specifiers
pub specifiers: Vec<Node<DeclarationSpecifier>>,
/// Contains function name and parameter list
pub declarator: Node<Declarator>,
/// K&R style parameter type definitions (C11 6.9.1 §6)
pub declarations: Vec<Node<Declaration>>,
/// Body of the function.
pub statement: Node<Statement>,
}
// Syntax extensions
/// Extended vendor-specific syntax that does not fit elsewhere
#[derive(Debug, PartialEq, Clone)]
pub enum Extension {
/// Attributes
///
/// [GNU extension](https://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html)
Attribute(Attribute),
/// Assembler name for an object
///
/// [GNU extension](https://gcc.gnu.org/onlinedocs/gcc/Asm-Labels.html)
AsmLabel(Node<StringLiteral>),
/// Platform availability
///
/// [Clang extension](https://clang.llvm.org/docs/AttributeReference.html#availability)
AvailabilityAttribute(Node<AvailabilityAttribute>),
}
/// Attributes
///
/// [GNU extension](https://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html)
#[derive(Debug, PartialEq, Clone)]
pub struct Attribute {
pub name: Node<String>,
pub arguments: Vec<Node<Expression>>,
}
/// Platform availability attribute
///
/// [Clang extension](https://clang.llvm.org/docs/AttributeReference.html#availability)
#[derive(Debug, PartialEq, Clone)]
pub struct AvailabilityAttribute {
pub platform: Node<Identifier>,
pub clauses: Vec<Node<AvailabilityClause>>,
}
/// Platfrom availability attribute clause
///
/// [Clang extension](https://clang.llvm.org/docs/AttributeReference.html#availability)
#[derive(Debug, PartialEq, Clone)]
pub enum AvailabilityClause {
Introduced(Node<AvailabilityVersion>),
Deprecated(Node<AvailabilityVersion>),
Obsoleted(Node<AvailabilityVersion>),
Unavailable,
Message(Node<StringLiteral>),
Replacement(Node<StringLiteral>),
}
/// Platfrom version inside availability attribute
///
/// [Clang extension](https://clang.llvm.org/docs/AttributeReference.html#availability)
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
pub struct AvailabilityVersion {
pub major: String,
pub minor: Option<String>,
pub subminor: Option<String>,
}
/// Inline assembler
#[derive(Debug, PartialEq, Clone)]
pub enum AsmStatement {
/// Basic asm statement with just source code
///
/// [GNU extension](https://gcc.gnu.org/onlinedocs/gcc/Basic-Asm.html)
GnuBasic(Node<StringLiteral>),
/// Extended statement that has access to C variables
///
/// [GNU extension](https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html)
GnuExtended(GnuExtendedAsmStatement),
}
/// Extended statement that has access to C variables
///
/// [GNU extension](https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html)
#[derive(Debug, PartialEq, Clone)]
pub struct GnuExtendedAsmStatement {
pub qualifier: Option<Node<TypeQualifier>>,
pub template: Node<StringLiteral>,
pub outputs: Vec<Node<GnuAsmOperand>>,
pub inputs: Vec<Node<GnuAsmOperand>>,
pub clobbers: Vec<Node<StringLiteral>>,
}
/// Single input or output operand specifier for GNU extended asm statement
///
/// [GNU extension](https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Output-Operands)
#[derive(Debug, PartialEq, Clone)]
pub struct GnuAsmOperand {
pub symbolic_name: Option<Node<Identifier>>,
pub constraints: Node<StringLiteral>,
pub variable_name: Node<Expression>,
}
/// Type of an expression or type
///
/// [GNU extension](https://gcc.gnu.org/onlinedocs/gcc/Typeof.html)
#[derive(Debug, PartialEq, Clone)]
pub enum TypeOf {
Expression(Node<Expression>),
Type(Node<TypeName>),
}
================================================
FILE: src/astutil.rs
================================================
use ast::*;
use span::{Node, Span};
#[cfg_attr(test, derive(Debug, PartialEq, Clone))]
pub enum Operation {
Member(Node<MemberOperator>, Node<Identifier>),
Unary(Node<UnaryOperator>),
Binary(Node<BinaryOperator>, Node<Expression>),
Call(Vec<Node<Expression>>),
}
fn apply_op(a: Node<Expression>, op: Node<Operation>) -> Node<Expression> {
let span = Span::span(a.span.start, op.span.end);
let expr = match op.node {
Operation::Member(op, id) => Expression::Member(Box::new(Node::new(
MemberExpression {
operator: op,
expression: Box::new(a),
identifier: id,
},
span,
))),
Operation::Unary(op) => Expression::UnaryOperator(Box::new(Node::new(
UnaryOperatorExpression {
operator: op,
operand: Box::new(a),
},
span,
))),
Operation::Binary(op, b) => Expression::BinaryOperator(Box::new(Node::new(
BinaryOperatorExpression {
operator: op,
lhs: Box::new(a),
rhs: Box::new(b),
},
span,
))),
Operation::Call(args) => Expression::Call(Box::new(Node::new(
CallExpression {
callee: Box::new(a),
arguments: args,
},
span,
))),
};
Node::new(expr, span)
}
pub fn apply_ops(ops: Vec<Node<Operation>>, expr: Node<Expression>) -> Node<Expression> {
ops.into_iter().fold(expr, apply_op)
}
pub fn concat<T>(mut a: Vec<T>, b: Vec<T>) -> Vec<T> {
a.extend(b);
a
}
pub fn infix(
node: Node<()>,
op: BinaryOperator,
lhs: Node<Expression>,
rhs: Node<Expression>,
) -> Node<Expression> {
let span = Span::span(lhs.span.start, rhs.span.end);
Node::new(
Expression::BinaryOperator(Box::new(Node::new(
BinaryOperatorExpression {
operator: Node::new(op, node.span),
lhs: Box::new(lhs),
rhs: Box::new(rhs),
},
span,
))),
span,
)
}
pub fn with_ext(mut d: Node<Declarator>, e: Option<Vec<Node<Extension>>>) -> Node<Declarator> {
if let Some(e) = e {
d.node.extensions.extend(e);
}
d
}
pub fn ts18661_float(binary: bool, width: usize, extended: bool) -> TS18661FloatType {
TS18661FloatType {
format: match (binary, extended) {
(true, false) => TS18661FloatFormat::BinaryInterchange,
(true, true) => TS18661FloatFormat::BinaryExtended,
(false, false) => TS18661FloatFormat::DecimalInterchange,
(false, true) => TS18661FloatFormat::DecimalExtended,
},
width: width,
}
}
pub fn int_suffix(mut s: &str) -> Result<IntegerSuffix, &'static str> {
let mut l = IntegerSize::Int;
let mut u = false;
let mut i = false;
while s.len() > 0 {
if l == IntegerSize::Int && (s.starts_with("ll") || s.starts_with("LL")) {
l = IntegerSize::LongLong;
s = &s[2..];
} else if l == IntegerSize::Int && (s.starts_with("l") || s.starts_with("L")) {
l = IntegerSize::Long;
s = &s[1..];
} else if !u && (s.starts_with("u") || s.starts_with("U")) {
u = true;
s = &s[1..];
} else if !i
&& (s.starts_with("i")
|| s.starts_with("I")
|| s.starts_with("j")
|| s.starts_with("J"))
{
i = true;
s = &s[1..];
} else {
return Err("integer suffix");
}
}
Ok(IntegerSuffix {
size: l,
unsigned: u,
imaginary: i,
})
}
================================================
FILE: src/bin/dump.rs
================================================
//! Parse a C file and dump the AST.
extern crate lang_c;
use std::process::exit;
use lang_c::driver::{Config, Flavor};
use lang_c::visit::Visit;
fn main() {
let mut config = Config::default();
let mut source = None;
let mut quiet = false;
for opt in std::env::args().skip(1) {
if opt == "-use-gcc" {
config = Config::with_gcc();
} else if opt == "-use-clang" {
config = Config::with_clang();
} else if opt == "-use-std" {
config.flavor = Flavor::StdC11;
} else if opt == "-q" {
quiet = true;
} else if opt.starts_with("-") {
config.cpp_options.push(opt);
} else {
if source.is_none() {
source = Some(opt);
} else {
println!("multiple input files given");
exit(1);
}
}
}
let source = match source {
Some(s) => s,
None => {
println!("input file required");
exit(1);
}
};
match lang_c::driver::parse(&config, &source) {
Ok(parse) => {
if !quiet {
let mut buf = String::new();
{
let mut printer = lang_c::print::Printer::new(&mut buf);
printer.visit_translation_unit(&parse.unit);
}
println!("{}", buf);
}
}
Err(err) => {
println!("{}", err);
exit(1);
}
}
}
================================================
FILE: src/bin/meminfo.rs
================================================
extern crate lang_c;
use lang_c::ast::*;
use std::mem::size_of;
macro_rules! ps {
($( $i:ident )+) => ({ $(println!("{:3} {}", size_of::<$i>(), stringify!($i));)+ })
}
fn main() {
ps! {
TypeOf
Identifier
Constant
Integer
Float
Expression
MemberOperator
GenericAssociation
UnaryOperator
BinaryOperator
OffsetDesignator
OffsetMember
Declaration
DeclarationSpecifier
InitDeclarator
gitextract_k8z0_aj5/
├── .github/
│ └── workflows/
│ └── ci.yml
├── .gitignore
├── Cargo.toml
├── LICENSE-APACHE
├── LICENSE-MIT
├── Makefile
├── README.md
├── grammar.header
├── grammar.rustfmt
├── grammar.rustpeg
├── reftests/
│ ├── constant-322.c
│ ├── constant-323.c
│ ├── constant-324.c
│ ├── constant-328.c
│ ├── constant-332.c
│ ├── constant-336.c
│ ├── constant-340.c
│ ├── constant-341.c
│ ├── constant-342.c
│ ├── constant-344.c
│ ├── constant-345.c
│ ├── constant-346.c
│ ├── constant-347.c
│ ├── constant-348.c
│ ├── constant-349.c
│ ├── constant-370.c
│ ├── constant-371.c
│ ├── constant-375.c
│ ├── constant-376.c
│ ├── constant-380.c
│ ├── constant-381.c
│ ├── constant-383.c
│ ├── constant-387.c
│ ├── constant-391.c
│ ├── constant-395.c
│ ├── constant-400.c
│ ├── constant-404.c
│ ├── constant-408.c
│ ├── constant-412.c
│ ├── constant-442.c
│ ├── constant-446.c
│ ├── constant-458.c
│ ├── constant-459.c
│ ├── constant-460.c
│ ├── constant-461.c
│ ├── constant-462.c
│ ├── constant-463.c
│ ├── constant-464.c
│ ├── constant-465.c
│ ├── constant-466.c
│ ├── declaration-1080.c
│ ├── declaration-1443.c
│ ├── declaration-1610.c
│ ├── declaration-1847.c
│ ├── declaration-2243.c
│ ├── declaration-2321.c
│ ├── declaration-2429.c
│ ├── declaration-2477.c
│ ├── declaration-2508.c
│ ├── declaration-2512.c
│ ├── declaration-2594.c
│ ├── declaration-31-field-semicolon.c
│ ├── declaration-31-ty-attr1.c
│ ├── declaration-31-ty-attr2.c
│ ├── declaration-31-ty-attr3.c
│ ├── declaration-659.c
│ ├── declaration-714.c
│ ├── declaration-760.c
│ ├── declaration-837.c
│ ├── declaration-855.c
│ ├── declaration-880.c
│ ├── declaration-983.c
│ ├── declaration-block-2.c
│ ├── declaration-block-3.c
│ ├── declaration-block-4.c
│ ├── declaration-block-5.c
│ ├── declaration-block.c
│ ├── declaration-enum-attr.c
│ ├── declaration-ptr-attr1.c
│ ├── declaration-ptr-attr2.c
│ ├── declaration-ptr-attr3.c
│ ├── declaration-struct.c
│ ├── declaration-typedef.c
│ ├── expression-1295.c
│ ├── expression-1307.c
│ ├── expression-1319.c
│ ├── expression-1338.c
│ ├── expression-1370.c
│ ├── expression-1523.c
│ ├── expression-1595.c
│ ├── expression-2224.c
│ ├── expression-2229.c
│ ├── expression-2234.c
│ ├── expression-2546.c
│ ├── expression-475.c
│ ├── expression-476.c
│ ├── expression-477.c
│ ├── expression-478.c
│ ├── expression-491.c
│ ├── expression-495.c
│ ├── expression-517.c
│ ├── expression-538.c
│ ├── expression-551.c
│ ├── expression-567.c
│ ├── expression-583.c
│ ├── expression-599.c
│ ├── expression-616.c
│ ├── expression-617.c
│ ├── expression-632.c
│ ├── expression-645.c
│ ├── expression-ident-const.c
│ ├── expression-sizeof.c
│ ├── expression-string-1.c
│ ├── expression-string-2.c
│ ├── statement-1408.c
│ ├── statement-1650.c
│ ├── statement-2625.c
│ ├── statement-2669.c
│ ├── statement-case.c
│ ├── statement-case2.c
│ ├── statement-caserange.c
│ ├── statement-caserange2.c
│ ├── statement-caserange3.c
│ ├── statement-caserange4.c
│ ├── statement-caserange5.c
│ ├── statement-default.c
│ ├── statement-label.c
│ ├── translation_unit-1183.c
│ ├── translation_unit-1388.c
│ ├── translation_unit-1692.c
│ ├── translation_unit-1781.c
│ ├── translation_unit-1961.c
│ ├── translation_unit-1993.c
│ ├── translation_unit-2015.c
│ ├── translation_unit-2029.c
│ ├── translation_unit-2045.c
│ ├── translation_unit-2060.c
│ ├── translation_unit-2070.c
│ ├── translation_unit-2086.c
│ ├── translation_unit-2103.c
│ ├── translation_unit-2114.c
│ ├── translation_unit-2129.c
│ ├── translation_unit-2147.c
│ ├── translation_unit-2167.c
│ ├── translation_unit-2190.c
│ ├── translation_unit-2208.c
│ ├── translation_unit-2270.c
│ ├── translation_unit-2300.c
│ ├── translation_unit-2373.c
│ └── translation_unit-31-semicolon.c
└── src/
├── ast.rs
├── astutil.rs
├── bin/
│ ├── dump.rs
│ └── meminfo.rs
├── driver.rs
├── env.rs
├── lib.rs
├── loc.rs
├── parser.rs
├── print.rs
├── span.rs
├── strings.rs
├── tests.rs
└── visit.rs
SYMBOL INDEX (726 symbols across 43 files)
FILE: reftests/declaration-2477.c
type foo (line 2) | struct foo
FILE: reftests/declaration-2508.c
type foo (line 1) | struct foo { }
FILE: reftests/declaration-2512.c
type foo (line 2) | struct foo { }
FILE: reftests/declaration-2594.c
type foo (line 3) | typedef const int foo;
FILE: reftests/declaration-31-field-semicolon.c
type s (line 3) | struct s {
FILE: reftests/declaration-31-ty-attr1.c
type s (line 5) | struct s {
FILE: reftests/declaration-31-ty-attr2.c
type s (line 3) | struct s {
FILE: reftests/declaration-31-ty-attr3.c
type s (line 3) | struct s {
FILE: reftests/declaration-struct.c
type foo (line 1) | struct foo {
FILE: reftests/declaration-typedef.c
type bar (line 1) | typedef struct foo {
FILE: reftests/expression-2546.c
type test_struct (line 2) | struct test_struct
FILE: reftests/translation_unit-1692.c
type named (line 14) | typedef int named;
function bar (line 15) | int bar (int f) { }
FILE: reftests/translation_unit-1781.c
function foo (line 2) | int foo(int a __attribute__((unused)), int b __attribute__((unused))) {}
FILE: reftests/translation_unit-1961.c
type a (line 3) | typedef int a;
function foo (line 4) | int foo() {
FILE: reftests/translation_unit-1993.c
type a (line 3) | typedef int a;
function foo (line 4) | void foo() {
FILE: reftests/translation_unit-2015.c
type a (line 4) | typedef int a;
function foo (line 5) | int foo(int a* b) {}
FILE: reftests/translation_unit-2029.c
type a (line 5) | typedef int a;
type a (line 6) | struct a { a a, b; }
FILE: reftests/translation_unit-2045.c
type a (line 5) | typedef int a;
type a (line 6) | struct a { a a; a b; }
FILE: reftests/translation_unit-2060.c
type a (line 3) | typedef int a;
function foo (line 4) | void foo() {
FILE: reftests/translation_unit-2070.c
type a (line 3) | typedef int a;
function foo (line 4) | void foo(int a, _Atomic (a) b) {}
FILE: reftests/translation_unit-2086.c
type a (line 5) | typedef int a;
function foo (line 6) | int foo() {
FILE: reftests/translation_unit-2103.c
type a (line 5) | typedef int a;
function foo (line 6) | int foo() {
FILE: reftests/translation_unit-2114.c
type a (line 4) | typedef int a;
function foo (line 5) | int foo() {
FILE: reftests/translation_unit-2129.c
type a (line 3) | typedef int a;
function foo (line 4) | int foo(a a) {}
FILE: reftests/translation_unit-2147.c
function foo (line 3) | void foo() {
FILE: reftests/translation_unit-2167.c
type a (line 3) | typedef int a;
function foo (line 4) | void foo() {
FILE: reftests/translation_unit-2190.c
type a (line 4) | typedef int a, b;
function foo (line 6) | void foo() {
FILE: reftests/translation_unit-2208.c
type a (line 5) | typedef int a;
function foo (line 6) | void foo() {
FILE: reftests/translation_unit-2373.c
function main (line 2) | int main(argc, argv) int argc; char **argv; { }
FILE: reftests/translation_unit-31-semicolon.c
function f (line 3) | void f(void) {
FILE: src/ast.rs
type Identifier (line 31) | pub struct Identifier {
type Constant (line 42) | pub enum Constant {
type Integer (line 52) | pub struct Integer {
type IntegerBase (line 62) | pub enum IntegerBase {
type IntegerSuffix (line 74) | pub struct IntegerSuffix {
type IntegerSize (line 89) | pub enum IntegerSize {
type Float (line 102) | pub struct Float {
type FloatBase (line 112) | pub enum FloatBase {
type FloatSuffix (line 121) | pub struct FloatSuffix {
type FloatFormat (line 133) | pub enum FloatFormat {
type StringLiteral (line 151) | pub type StringLiteral = Vec<String>;
type Expression (line 159) | pub enum Expression {
type MemberOperator (line 272) | pub enum MemberOperator {
type GenericSelection (line 283) | pub struct GenericSelection {
type GenericAssociation (line 292) | pub enum GenericAssociation {
type GenericAssociationType (line 301) | pub struct GenericAssociationType {
type MemberExpression (line 312) | pub struct MemberExpression {
type CallExpression (line 322) | pub struct CallExpression {
type CompoundLiteral (line 331) | pub struct CompoundLiteral {
type SizeOfTy (line 340) | pub struct SizeOfTy(pub Node<TypeName>);
type SizeOfVal (line 346) | pub struct SizeOfVal(pub Box<Node<Expression>>);
type AlignOf (line 352) | pub struct AlignOf(pub Box<Node<TypeName>>);
type UnaryOperator (line 358) | pub enum UnaryOperator {
type UnaryOperatorExpression (line 388) | pub struct UnaryOperatorExpression {
type CastExpression (line 399) | pub struct CastExpression {
type BinaryOperator (line 408) | pub enum BinaryOperator {
type BinaryOperatorExpression (line 477) | pub struct BinaryOperatorExpression {
type ConditionalExpression (line 487) | pub struct ConditionalExpression {
type VaArgExpression (line 499) | pub struct VaArgExpression {
type OffsetOfExpression (line 510) | pub struct OffsetOfExpression {
type OffsetDesignator (line 519) | pub struct OffsetDesignator {
type OffsetMember (line 528) | pub enum OffsetMember {
type Declaration (line 540) | pub struct Declaration {
type DeclarationSpecifier (line 551) | pub enum DeclarationSpecifier {
type InitDeclarator (line 565) | pub struct InitDeclarator {
type StorageClassSpecifier (line 576) | pub enum StorageClassSpecifier {
type TypeSpecifier (line 597) | pub enum TypeSpecifier {
type TS18661FloatType (line 656) | pub struct TS18661FloatType {
type TS18661FloatFormat (line 665) | pub enum TS18661FloatFormat {
type StructType (line 678) | pub struct StructType {
type StructKind (line 691) | pub enum StructKind {
type StructDeclaration (line 700) | pub enum StructDeclaration {
type StructField (line 707) | pub struct StructField {
type SpecifierQualifier (line 718) | pub enum SpecifierQualifier {
type StructDeclarator (line 728) | pub struct StructDeclarator {
type EnumType (line 739) | pub struct EnumType {
type Enumerator (line 748) | pub struct Enumerator {
type TypeQualifier (line 760) | pub enum TypeQualifier {
type FunctionSpecifier (line 795) | pub enum FunctionSpecifier {
type AlignmentSpecifier (line 810) | pub enum AlignmentSpecifier {
type Declarator (line 825) | pub struct Declarator {
type DeclaratorKind (line 838) | pub enum DeclaratorKind {
type DerivedDeclarator (line 858) | pub enum DerivedDeclarator {
type ArrayDeclarator (line 875) | pub struct ArrayDeclarator {
type FunctionDeclarator (line 882) | pub struct FunctionDeclarator {
type PointerQualifier (line 891) | pub enum PointerQualifier {
type ArraySize (line 900) | pub enum ArraySize {
type ParameterDeclaration (line 920) | pub struct ParameterDeclaration {
type Ellipsis (line 928) | pub enum Ellipsis {
type TypeName (line 941) | pub struct TypeName {
type Initializer (line 952) | pub enum Initializer {
type InitializerListItem (line 961) | pub struct InitializerListItem {
type Designator (line 968) | pub enum Designator {
type RangeDesignator (line 996) | pub struct RangeDesignator {
type StaticAssert (line 1007) | pub struct StaticAssert {
type Statement (line 1018) | pub enum Statement {
type LabeledStatement (line 1039) | pub struct LabeledStatement {
type IfStatement (line 1048) | pub struct IfStatement {
type SwitchStatement (line 1058) | pub struct SwitchStatement {
type WhileStatement (line 1067) | pub struct WhileStatement {
type DoWhileStatement (line 1076) | pub struct DoWhileStatement {
type ForStatement (line 1085) | pub struct ForStatement {
type Label (line 1094) | pub enum Label {
type CaseRange (line 1121) | pub struct CaseRange {
type ForInitializer (line 1128) | pub enum ForInitializer {
type BlockItem (line 1143) | pub enum BlockItem {
type TranslationUnit (line 1155) | pub struct TranslationUnit(pub Vec<Node<ExternalDeclaration>>);
type ExternalDeclaration (line 1161) | pub enum ExternalDeclaration {
type FunctionDefinition (line 1171) | pub struct FunctionDefinition {
type Extension (line 1186) | pub enum Extension {
type Attribute (line 1205) | pub struct Attribute {
type AvailabilityAttribute (line 1214) | pub struct AvailabilityAttribute {
type AvailabilityClause (line 1223) | pub enum AvailabilityClause {
type AvailabilityVersion (line 1236) | pub struct AvailabilityVersion {
type AsmStatement (line 1244) | pub enum AsmStatement {
type GnuExtendedAsmStatement (line 1260) | pub struct GnuExtendedAsmStatement {
type GnuAsmOperand (line 1272) | pub struct GnuAsmOperand {
type TypeOf (line 1282) | pub enum TypeOf {
FILE: src/astutil.rs
type Operation (line 5) | pub enum Operation {
function apply_op (line 12) | fn apply_op(a: Node<Expression>, op: Node<Operation>) -> Node<Expression> {
function apply_ops (line 50) | pub fn apply_ops(ops: Vec<Node<Operation>>, expr: Node<Expression>) -> N...
function concat (line 54) | pub fn concat<T>(mut a: Vec<T>, b: Vec<T>) -> Vec<T> {
function infix (line 59) | pub fn infix(
function with_ext (line 79) | pub fn with_ext(mut d: Node<Declarator>, e: Option<Vec<Node<Extension>>>...
function ts18661_float (line 86) | pub fn ts18661_float(binary: bool, width: usize, extended: bool) -> TS18...
function int_suffix (line 98) | pub fn int_suffix(mut s: &str) -> Result<IntegerSuffix, &'static str> {
FILE: src/bin/dump.rs
function main (line 10) | fn main() {
FILE: src/bin/meminfo.rs
function main (line 9) | fn main() {
FILE: src/driver.rs
type Config (line 17) | pub struct Config {
method with_gcc (line 28) | pub fn with_gcc() -> Config {
method with_clang (line 37) | pub fn with_clang() -> Config {
method default (line 48) | fn default() -> Config {
method default (line 53) | fn default() -> Config {
type Flavor (line 60) | pub enum Flavor {
type Parse (line 71) | pub struct Parse {
type Error (line 80) | pub enum Error {
method from (line 86) | fn from(e: SyntaxError) -> Error {
method fmt (line 92) | fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
method description (line 101) | fn description(&self) -> &str {
type SyntaxError (line 111) | pub struct SyntaxError {
method format_expected (line 126) | pub fn format_expected(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
method get_location (line 139) | pub fn get_location(&self) -> (loc::Location, Vec<loc::Location>) {
method fmt (line 145) | fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
function parse (line 161) | pub fn parse<P: AsRef<Path>>(config: &Config, source: P) -> Result<Parse...
function parse_preprocessed (line 170) | pub fn parse_preprocessed(config: &Config, source: String) -> Result<Par...
function preprocess (line 192) | fn preprocess(config: &Config, source: &Path) -> io::Result<String> {
FILE: src/env.rs
type Symbol (line 8) | pub enum Symbol {
type Env (line 13) | pub struct Env {
method with_core (line 21) | pub fn with_core() -> Env {
method with_gnu (line 32) | pub fn with_gnu() -> Env {
method with_clang (line 46) | pub fn with_clang() -> Env {
method enter_scope (line 61) | pub fn enter_scope(&mut self) {
method leave_scope (line 65) | pub fn leave_scope(&mut self) {
method is_typename (line 69) | pub fn is_typename(&self, ident: &str) -> bool {
method handle_declarator (line 78) | pub fn handle_declarator(&mut self, d: &Node<Declarator>, sym: Symbol) {
method add_symbol (line 84) | pub fn add_symbol(&mut self, s: &str, symbol: Symbol) {
method add_typename (line 93) | pub fn add_typename(&mut self, s: &str) {
function find_declarator_name (line 98) | fn find_declarator_name(d: &DeclaratorKind) -> Option<&str> {
FILE: src/loc.rs
constant F_NEW (line 2) | const F_NEW: u32 = 1;
constant F_RET (line 3) | const F_RET: u32 = 2;
type Location (line 6) | pub struct Location<'a> {
function get_location_for_offset (line 16) | pub fn get_location_for_offset<'a>(src: &'a str, pos: usize) -> (Locatio...
function test_get_location_for_offset (line 45) | fn test_get_location_for_offset() {
function strip_prefix (line 101) | fn strip_prefix<'a>(s: &'a str, p: &str) -> Option<&'a str> {
function parse_line_directive (line 110) | fn parse_line_directive(s: &str) -> Option<(Location, u32)> {
function test_line_directive (line 140) | fn test_line_directive() {
FILE: src/parser.rs
function escape_default (line 10) | fn escape_default(s: &str) -> String {
function char_range_at (line 13) | fn char_range_at(s: &str, pos: usize) -> (char, usize) {
type RuleResult (line 19) | enum RuleResult<T> {
type ParseError (line 24) | pub struct ParseError {
method fmt (line 32) | fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::result::Resul...
method description (line 49) | fn description(&self) -> &str {
type ParseResult (line 30) | pub type ParseResult<T> = Result<T, ParseError>;
function slice_eq (line 53) | fn slice_eq(input: &str, state: &mut ParseState, pos: usize, m: &'static...
function slice_eq_case_insensitive (line 63) | fn slice_eq_case_insensitive(input: &str, state: &mut ParseState, pos: u...
function any_char (line 77) | fn any_char(input: &str, state: &mut ParseState, pos: usize) -> RuleResu...
function pos_to_line (line 87) | fn pos_to_line(input: &str, pos: usize) -> (usize, usize) {
function mark_failure (line 94) | fn mark_failure(&mut self, pos: usize, expected: &'static str) -> RuleRe...
type ParseState (line 107) | struct ParseState<'input> {
function new (line 115) | fn new() -> ParseState<'input> {
function __parse__ (line 120) | fn __parse__<'input>(__input: &'input str, __state: &mut ParseState<'inp...
function __parse_directive (line 179) | fn __parse_directive<'input>(__input: &'input str, __state: &mut ParseSt...
function __parse_identifier (line 213) | fn __parse_identifier<'input>(__input: &'input str, __state: &mut ParseS...
function __parse_identifier0 (line 236) | fn __parse_identifier0<'input>(__input: &'input str, __state: &mut Parse...
function __parse_ohx (line 304) | fn __parse_ohx<'input>(__input: &'input str, __state: &mut ParseState<'i...
function __parse_obb (line 325) | fn __parse_obb<'input>(__input: &'input str, __state: &mut ParseState<'i...
function __parse_dec (line 346) | fn __parse_dec<'input>(__input: &'input str, __state: &mut ParseState<'i...
function __parse_oct (line 359) | fn __parse_oct<'input>(__input: &'input str, __state: &mut ParseState<'i...
function __parse_hex (line 372) | fn __parse_hex<'input>(__input: &'input str, __state: &mut ParseState<'i...
function __parse_bin (line 385) | fn __parse_bin<'input>(__input: &'input str, __state: &mut ParseState<'i...
function __parse_constant (line 398) | fn __parse_constant<'input>(__input: &'input str, __state: &mut ParseSta...
function __parse_numeric_constant (line 465) | fn __parse_numeric_constant<'input>(__input: &'input str, __state: &mut ...
function __parse_integer_constant (line 488) | fn __parse_integer_constant<'input>(__input: &'input str, __state: &mut ...
function __parse_integer_number (line 508) | fn __parse_integer_number<'input>(__input: &'input str, __state: &mut Pa...
function __parse_integer_suffix (line 727) | fn __parse_integer_suffix<'input>(__input: &'input str, __state: &mut Pa...
function __parse_integer_suffix_inner (line 746) | fn __parse_integer_suffix_inner<'input>(__input: &'input str, __state: &...
function __parse_float_constant (line 826) | fn __parse_float_constant<'input>(__input: &'input str, __state: &mut Pa...
function __parse_float_number (line 846) | fn __parse_float_number<'input>(__input: &'input str, __state: &mut Pars...
function __parse_float_decimal (line 887) | fn __parse_float_decimal<'input>(__input: &'input str, __state: &mut Par...
function __parse_float_decimal_exp (line 1024) | fn __parse_float_decimal_exp<'input>(__input: &'input str, __state: &mut...
function __parse_float_hexadecimal (line 1081) | fn __parse_float_hexadecimal<'input>(__input: &'input str, __state: &mut...
function __parse_float_binary_exp (line 1212) | fn __parse_float_binary_exp<'input>(__input: &'input str, __state: &mut ...
function __parse_float_suffix (line 1269) | fn __parse_float_suffix<'input>(__input: &'input str, __state: &mut Pars...
function __parse_float_suffix_inner (line 1288) | fn __parse_float_suffix_inner<'input>(__input: &'input str, __state: &mu...
function __parse_float_format (line 1382) | fn __parse_float_format<'input>(__input: &'input str, __state: &mut Pars...
function __parse_character_constant (line 1439) | fn __parse_character_constant<'input>(__input: &'input str, __state: &mu...
function __parse_character (line 1506) | fn __parse_character<'input>(__input: &'input str, __state: &mut ParseSt...
function __parse_escape_sequence (line 1525) | fn __parse_escape_sequence<'input>(__input: &'input str, __state: &mut P...
function __parse_string_literal (line 1607) | fn __parse_string_literal<'input>(__input: &'input str, __state: &mut Pa...
function __parse_string_literal0 (line 1672) | fn __parse_string_literal0<'input>(__input: &'input str, __state: &mut P...
function __parse_encoding_prefix (line 1725) | fn __parse_encoding_prefix<'input>(__input: &'input str, __state: &mut P...
function __parse_string_char (line 1746) | fn __parse_string_char<'input>(__input: &'input str, __state: &mut Parse...
function __parse_primary_expression (line 1765) | fn __parse_primary_expression<'input>(__input: &'input str, __state: &mu...
function __parse_primary_expression0 (line 1794) | fn __parse_primary_expression0<'input>(__input: &'input str, __state: &m...
function __parse_generic_selection (line 1939) | fn __parse_generic_selection<'input>(__input: &'input str, __state: &mut...
function __parse_generic_association (line 2109) | fn __parse_generic_association<'input>(__input: &'input str, __state: &m...
function __parse_postfix_expression (line 2216) | fn __parse_postfix_expression<'input>(__input: &'input str, __state: &mu...
function __parse_postfix_expression0 (line 2245) | fn __parse_postfix_expression0<'input>(__input: &'input str, __state: &m...
function __parse_postfix_expression1 (line 2341) | fn __parse_postfix_expression1<'input>(__input: &'input str, __state: &m...
function __parse_postfix_expressionT (line 2352) | fn __parse_postfix_expressionT<'input>(__input: &'input str, __state: &m...
function __parse_index_operator (line 2527) | fn __parse_index_operator<'input>(__input: &'input str, __state: &mut Pa...
function __parse_index_operator0 (line 2556) | fn __parse_index_operator0<'input>(__input: &'input str, __state: &mut P...
function __parse_member_operator (line 2609) | fn __parse_member_operator<'input>(__input: &'input str, __state: &mut P...
function __parse_postfix_operator (line 2632) | fn __parse_postfix_operator<'input>(__input: &'input str, __state: &mut ...
function __parse_compound_literal (line 2655) | fn __parse_compound_literal<'input>(__input: &'input str, __state: &mut ...
function __parse_compound_literal_inner (line 2684) | fn __parse_compound_literal_inner<'input>(__input: &'input str, __state:...
function __parse_unary_expression (line 2836) | fn __parse_unary_expression<'input>(__input: &'input str, __state: &mut ...
function __parse_unary_expression0 (line 2865) | fn __parse_unary_expression0<'input>(__input: &'input str, __state: &mut...
function __parse_unary_prefix (line 2971) | fn __parse_unary_prefix<'input>(__input: &'input str, __state: &mut Pars...
function __parse_unary_prefix_inner (line 3000) | fn __parse_unary_prefix_inner<'input>(__input: &'input str, __state: &mu...
function __parse_prefix_operator (line 3041) | fn __parse_prefix_operator<'input>(__input: &'input str, __state: &mut P...
function __parse_unary_cast (line 3064) | fn __parse_unary_cast<'input>(__input: &'input str, __state: &mut ParseS...
function __parse_unary_cast_inner (line 3093) | fn __parse_unary_cast_inner<'input>(__input: &'input str, __state: &mut ...
function __parse_unary_operator (line 3134) | fn __parse_unary_operator<'input>(__input: &'input str, __state: &mut Pa...
function __parse_sizeof_expression (line 3219) | fn __parse_sizeof_expression<'input>(__input: &'input str, __state: &mut...
function __parse_sizeof_ty_expression (line 3242) | fn __parse_sizeof_ty_expression<'input>(__input: &'input str, __state: &...
function __parse_sizeof_ty_expression0 (line 3271) | fn __parse_sizeof_ty_expression0<'input>(__input: &'input str, __state: ...
function __parse_sizeof_val_expression (line 3351) | fn __parse_sizeof_val_expression<'input>(__input: &'input str, __state: ...
function __parse_sizeof_val_expression0 (line 3380) | fn __parse_sizeof_val_expression0<'input>(__input: &'input str, __state:...
function __parse_alignof_expression (line 3436) | fn __parse_alignof_expression<'input>(__input: &'input str, __state: &mu...
function __parse_alignof (line 3447) | fn __parse_alignof<'input>(__input: &'input str, __state: &mut ParseStat...
function __parse_alignof0 (line 3476) | fn __parse_alignof0<'input>(__input: &'input str, __state: &mut ParseSta...
function __parse_cast_expression (line 3591) | fn __parse_cast_expression<'input>(__input: &'input str, __state: &mut P...
function __parse_cast_expression0 (line 3620) | fn __parse_cast_expression0<'input>(__input: &'input str, __state: &mut ...
function __parse_cast_expression_inner (line 3655) | fn __parse_cast_expression_inner<'input>(__input: &'input str, __state: ...
function __parse_binary_expression (line 3702) | fn __parse_binary_expression<'input>(__input: &'input str, __state: &mut...
function __parse_binary_expression0 (line 3713) | fn __parse_binary_expression0<'input>(__input: &'input str, __state: &mu...
function __parse_binary_operand (line 4558) | fn __parse_binary_operand<'input>(__input: &'input str, __state: &mut Pa...
function __parse_conditional_expression (line 4581) | fn __parse_conditional_expression<'input>(__input: &'input str, __state:...
function __parse_conditional_expression0 (line 4610) | fn __parse_conditional_expression0<'input>(__input: &'input str, __state...
function __parse_conditional_expressionT (line 4643) | fn __parse_conditional_expressionT<'input>(__input: &'input str, __state...
function __parse_assignment_expression (line 4726) | fn __parse_assignment_expression<'input>(__input: &'input str, __state: ...
function __parse_assignment_expression0 (line 4755) | fn __parse_assignment_expression0<'input>(__input: &'input str, __state:...
function __parse_assignment_expression_inner (line 4790) | fn __parse_assignment_expression_inner<'input>(__input: &'input str, __s...
function __parse_assignment_operator (line 4843) | fn __parse_assignment_operator<'input>(__input: &'input str, __state: &m...
function __parse_expression (line 4974) | fn __parse_expression<'input>(__input: &'input str, __state: &mut ParseS...
function __parse_expression0 (line 5003) | fn __parse_expression0<'input>(__input: &'input str, __state: &mut Parse...
function __parse_expressionT (line 5084) | fn __parse_expressionT<'input>(__input: &'input str, __state: &mut Parse...
function __parse_constant_expression (line 5125) | fn __parse_constant_expression<'input>(__input: &'input str, __state: &m...
function __parse_constant_expression0 (line 5130) | fn __parse_constant_expression0<'input>(__input: &'input str, __state: &...
function __parse_declaration (line 5135) | fn __parse_declaration<'input>(__input: &'input str, __state: &mut Parse...
function __parse_declaration0 (line 5158) | fn __parse_declaration0<'input>(__input: &'input str, __state: &mut Pars...
function __parse_declaration1 (line 5249) | fn __parse_declaration1<'input>(__input: &'input str, __state: &mut Pars...
function __parse_declaration2 (line 5272) | fn __parse_declaration2<'input>(__input: &'input str, __state: &mut Pars...
function __parse_declaration_typedef_tail (line 5475) | fn __parse_declaration_typedef_tail<'input>(__input: &'input str, __stat...
function __parse_declaration_typedef_tail0 (line 5498) | fn __parse_declaration_typedef_tail0<'input>(__input: &'input str, __sta...
function __parse_declaration_unique_type (line 5581) | fn __parse_declaration_unique_type<'input>(__input: &'input str, __state...
function __parse_declaration_nonunique_type (line 5610) | fn __parse_declaration_nonunique_type<'input>(__input: &'input str, __st...
function __parse_declaration_specifiers (line 5639) | fn __parse_declaration_specifiers<'input>(__input: &'input str, __state:...
function __parse_declaration_specifiers_tail (line 5662) | fn __parse_declaration_specifiers_tail<'input>(__input: &'input str, __s...
function __parse_declaration_specifiers_unique (line 5709) | fn __parse_declaration_specifiers_unique<'input>(__input: &'input str, _...
function __parse_declaration_specifiers_nonunique (line 5764) | fn __parse_declaration_specifiers_nonunique<'input>(__input: &'input str...
function __parse_declaration_specifier_nontype (line 5825) | fn __parse_declaration_specifier_nontype<'input>(__input: &'input str, _...
function __parse_declaration_typedef (line 5904) | fn __parse_declaration_typedef<'input>(__input: &'input str, __state: &m...
function __parse_declaration_typedef0 (line 5933) | fn __parse_declaration_typedef0<'input>(__input: &'input str, __state: &...
function __parse_declaration_specifier_unique_type0 (line 5944) | fn __parse_declaration_specifier_unique_type0<'input>(__input: &'input s...
function __parse_declaration_specifier_nonunique_type0 (line 5973) | fn __parse_declaration_specifier_nonunique_type0<'input>(__input: &'inpu...
function __parse_declaration_init_declarators (line 6002) | fn __parse_declaration_init_declarators<'input>(__input: &'input str, __...
function __parse_declaration_type_declarators (line 6069) | fn __parse_declaration_type_declarators<'input>(__input: &'input str, __...
function __parse_init_declarator (line 6136) | fn __parse_init_declarator<'input>(__input: &'input str, __state: &mut P...
function __parse_init_declarator_declarator (line 6215) | fn __parse_init_declarator_declarator<'input>(__input: &'input str, __st...
function __parse_init_declarator_init (line 6229) | fn __parse_init_declarator_init<'input>(__input: &'input str, __state: &...
function __parse_init_declarator_gnu (line 6252) | fn __parse_init_declarator_gnu<'input>(__input: &'input str, __state: &m...
function __parse_type_declarator (line 6278) | fn __parse_type_declarator<'input>(__input: &'input str, __state: &mut P...
function __parse_storage_class_specifier (line 6327) | fn __parse_storage_class_specifier<'input>(__input: &'input str, __state...
function __parse_storage_class_specifier0 (line 6350) | fn __parse_storage_class_specifier0<'input>(__input: &'input str, __stat...
function __parse_storage_class_typedef (line 6574) | fn __parse_storage_class_typedef<'input>(__input: &'input str, __state: ...
function __parse_storage_class_typedef0 (line 6597) | fn __parse_storage_class_typedef0<'input>(__input: &'input str, __state:...
function __parse_type_specifier_unique (line 6641) | fn __parse_type_specifier_unique<'input>(__input: &'input str, __state: ...
function __parse_type_specifier_nonunique (line 6883) | fn __parse_type_specifier_nonunique<'input>(__input: &'input str, __stat...
function __parse_struct_or_union_specifier (line 7428) | fn __parse_struct_or_union_specifier<'input>(__input: &'input str, __sta...
function __parse_struct_or_union_body (line 7526) | fn __parse_struct_or_union_body<'input>(__input: &'input str, __state: &...
function __parse_struct_or_union (line 7665) | fn __parse_struct_or_union<'input>(__input: &'input str, __state: &mut P...
function __parse_struct_declaration (line 7754) | fn __parse_struct_declaration<'input>(__input: &'input str, __state: &mu...
function __parse_struct_field (line 7872) | fn __parse_struct_field<'input>(__input: &'input str, __state: &mut Pars...
function __parse_specifier_qualifiers (line 8021) | fn __parse_specifier_qualifiers<'input>(__input: &'input str, __state: &...
function __parse_specifier_qualifier_unique_type0 (line 8362) | fn __parse_specifier_qualifier_unique_type0<'input>(__input: &'input str...
function __parse_specifier_qualifier_nonunique_type0 (line 8391) | fn __parse_specifier_qualifier_nonunique_type0<'input>(__input: &'input ...
function __parse_specifier_qualifier_qualifier0 (line 8420) | fn __parse_specifier_qualifier_qualifier0<'input>(__input: &'input str, ...
function __parse_struct_declarator (line 8463) | fn __parse_struct_declarator<'input>(__input: &'input str, __state: &mut...
function __parse_enum_specifier (line 8577) | fn __parse_enum_specifier<'input>(__input: &'input str, __state: &mut Pa...
function __parse_enumerator (line 8810) | fn __parse_enumerator<'input>(__input: &'input str, __state: &mut ParseS...
function __parse_enumerator_constant (line 8874) | fn __parse_enumerator_constant<'input>(__input: &'input str, __state: &m...
function __parse_type_qualifier (line 8897) | fn __parse_type_qualifier<'input>(__input: &'input str, __state: &mut Pa...
function __parse_type_qualifier0 (line 8920) | fn __parse_type_qualifier0<'input>(__input: &'input str, __state: &mut P...
function __parse_function_specifier (line 9410) | fn __parse_function_specifier<'input>(__input: &'input str, __state: &mu...
function __parse_function_specifier0 (line 9433) | fn __parse_function_specifier0<'input>(__input: &'input str, __state: &m...
function __parse_alignment_specifier (line 9557) | fn __parse_alignment_specifier<'input>(__input: &'input str, __state: &m...
function __parse_alignment_specifier0 (line 9580) | fn __parse_alignment_specifier0<'input>(__input: &'input str, __state: &...
function __parse_declarator (line 9741) | fn __parse_declarator<'input>(__input: &'input str, __state: &mut ParseS...
function __parse_declarator0 (line 9764) | fn __parse_declarator0<'input>(__input: &'input str, __state: &mut Parse...
function __parse_direct_declarator (line 9934) | fn __parse_direct_declarator<'input>(__input: &'input str, __state: &mut...
function __parse_derived_declarator (line 9981) | fn __parse_derived_declarator<'input>(__input: &'input str, __state: &mu...
function __parse_array_declarator (line 10184) | fn __parse_array_declarator<'input>(__input: &'input str, __state: &mut ...
function __parse_function_declarator (line 10605) | fn __parse_function_declarator<'input>(__input: &'input str, __state: &m...
function __parse_pointer (line 10676) | fn __parse_pointer<'input>(__input: &'input str, __state: &mut ParseStat...
function __parse_pointer0 (line 10699) | fn __parse_pointer0<'input>(__input: &'input str, __state: &mut ParseSta...
function __parse_pointer_qualifier (line 10810) | fn __parse_pointer_qualifier<'input>(__input: &'input str, __state: &mut...
function __parse_ellipsis (line 10853) | fn __parse_ellipsis<'input>(__input: &'input str, __state: &mut ParseSta...
function __parse_parameter_declaration (line 10882) | fn __parse_parameter_declaration<'input>(__input: &'input str, __state: ...
function __parse_parameter_declaration0 (line 10905) | fn __parse_parameter_declaration0<'input>(__input: &'input str, __state:...
function __parse_parameter_declarator (line 10963) | fn __parse_parameter_declarator<'input>(__input: &'input str, __state: &...
function __parse_type_name (line 10995) | fn __parse_type_name<'input>(__input: &'input str, __state: &mut ParseSt...
function __parse_type_name0 (line 11018) | fn __parse_type_name0<'input>(__input: &'input str, __state: &mut ParseS...
function __parse_abstract_declarator (line 11044) | fn __parse_abstract_declarator<'input>(__input: &'input str, __state: &m...
function __parse_abstract_declarator0 (line 11067) | fn __parse_abstract_declarator0<'input>(__input: &'input str, __state: &...
function __parse_direct_abstract_declarator (line 11336) | fn __parse_direct_abstract_declarator<'input>(__input: &'input str, __st...
function __parse_derived_abstract_declarator (line 11371) | fn __parse_derived_abstract_declarator<'input>(__input: &'input str, __s...
function __parse_derived_abstract_declarator0 (line 11394) | fn __parse_derived_abstract_declarator0<'input>(__input: &'input str, __...
function __parse_abstract_array_declarator (line 11489) | fn __parse_abstract_array_declarator<'input>(__input: &'input str, __sta...
function __parse_abstract_function_declarator (line 11866) | fn __parse_abstract_function_declarator<'input>(__input: &'input str, __...
function __parse_typedef_name (line 11943) | fn __parse_typedef_name<'input>(__input: &'input str, __state: &mut Pars...
function __parse_typedef_name0 (line 11962) | fn __parse_typedef_name0<'input>(__input: &'input str, __state: &mut Par...
function __parse_initializer (line 11987) | fn __parse_initializer<'input>(__input: &'input str, __state: &mut Parse...
function __parse_initializer_list_item (line 12159) | fn __parse_initializer_list_item<'input>(__input: &'input str, __state: ...
function __parse_designation (line 12203) | fn __parse_designation<'input>(__input: &'input str, __state: &mut Parse...
function __parse_colon_designation (line 12380) | fn __parse_colon_designation<'input>(__input: &'input str, __state: &mut...
function __parse_designator (line 12403) | fn __parse_designator<'input>(__input: &'input str, __state: &mut ParseS...
function __parse_array_designator (line 12438) | fn __parse_array_designator<'input>(__input: &'input str, __state: &mut ...
function __parse_range_suffix (line 12528) | fn __parse_range_suffix<'input>(__input: &'input str, __state: &mut Pars...
function __parse_static_assert (line 12569) | fn __parse_static_assert<'input>(__input: &'input str, __state: &mut Par...
function __parse_static_assert0 (line 12592) | fn __parse_static_assert0<'input>(__input: &'input str, __state: &mut Pa...
function __parse_statement (line 12776) | fn __parse_statement<'input>(__input: &'input str, __state: &mut ParseSt...
function __parse_statement0 (line 12805) | fn __parse_statement0<'input>(__input: &'input str, __state: &mut ParseS...
function __parse_labeled_statement (line 12974) | fn __parse_labeled_statement<'input>(__input: &'input str, __state: &mut...
function __parse_label (line 13027) | fn __parse_label<'input>(__input: &'input str, __state: &mut ParseState<...
function __parse_compound_statement (line 13183) | fn __parse_compound_statement<'input>(__input: &'input str, __state: &mu...
function __parse_block_item (line 13268) | fn __parse_block_item<'input>(__input: &'input str, __state: &mut ParseS...
function __parse_expression_statement (line 13321) | fn __parse_expression_statement<'input>(__input: &'input str, __state: &...
function __parse_selection_statement (line 13347) | fn __parse_selection_statement<'input>(__input: &'input str, __state: &m...
function __parse_if_statement (line 13406) | fn __parse_if_statement<'input>(__input: &'input str, __state: &mut Pars...
function __parse_else_statement (line 13513) | fn __parse_else_statement<'input>(__input: &'input str, __state: &mut Pa...
function __parse_switch_statement (line 13569) | fn __parse_switch_statement<'input>(__input: &'input str, __state: &mut ...
function __parse_iteration_statement (line 13661) | fn __parse_iteration_statement<'input>(__input: &'input str, __state: &m...
function __parse_while_statement (line 13750) | fn __parse_while_statement<'input>(__input: &'input str, __state: &mut P...
function __parse_do_while_statement (line 13842) | fn __parse_do_while_statement<'input>(__input: &'input str, __state: &mu...
function __parse_for_statement (line 13991) | fn __parse_for_statement<'input>(__input: &'input str, __state: &mut Par...
function __parse_for_initializer (line 14143) | fn __parse_for_initializer<'input>(__input: &'input str, __state: &mut P...
function __parse_jump_statement (line 14202) | fn __parse_jump_statement<'input>(__input: &'input str, __state: &mut Pa...
function __parse_translation_unit (line 14456) | fn __parse_translation_unit<'input>(__input: &'input str, __state: &mut ...
function __parse_external_declaration (line 14538) | fn __parse_external_declaration<'input>(__input: &'input str, __state: &...
function __parse_external_declaration0 (line 14601) | fn __parse_external_declaration0<'input>(__input: &'input str, __state: ...
function __parse_function_definition (line 14682) | fn __parse_function_definition<'input>(__input: &'input str, __state: &m...
function __parse_gnu_guard (line 14847) | fn __parse_gnu_guard<'input>(__input: &'input str, __state: &mut ParseSt...
function __parse_attribute_specifier_list (line 14864) | fn __parse_attribute_specifier_list<'input>(__input: &'input str, __stat...
function __parse_attribute_specifier (line 14907) | fn __parse_attribute_specifier<'input>(__input: &'input str, __state: &m...
function __parse_attribute (line 15058) | fn __parse_attribute<'input>(__input: &'input str, __state: &mut ParseSt...
function __parse_attribute_name (line 15152) | fn __parse_attribute_name<'input>(__input: &'input str, __state: &mut Pa...
function __parse_attribute_parameters (line 15211) | fn __parse_attribute_parameters<'input>(__input: &'input str, __state: &...
function __parse_attr_availability (line 15308) | fn __parse_attr_availability<'input>(__input: &'input str, __state: &mut...
function __parse_attr_availability_clause (line 15478) | fn __parse_attr_availability_clause<'input>(__input: &'input str, __stat...
function __parse_attr_availability_version (line 15921) | fn __parse_attr_availability_version<'input>(__input: &'input str, __sta...
function __parse_asm_label (line 16043) | fn __parse_asm_label<'input>(__input: &'input str, __state: &mut ParseSt...
function __parse_asm_label0 (line 16066) | fn __parse_asm_label0<'input>(__input: &'input str, __state: &mut ParseS...
function __parse_asm_label_keyword (line 16113) | fn __parse_asm_label_keyword<'input>(__input: &'input str, __state: &mut...
function __parse_asm_statement (line 16213) | fn __parse_asm_statement<'input>(__input: &'input str, __state: &mut Par...
function __parse_asm_statement0 (line 16242) | fn __parse_asm_statement0<'input>(__input: &'input str, __state: &mut Pa...
function __parse_asm_operand_list (line 16528) | fn __parse_asm_operand_list<'input>(__input: &'input str, __state: &mut ...
function __parse_asm_operand (line 16595) | fn __parse_asm_operand<'input>(__input: &'input str, __state: &mut Parse...
function __parse_gnu_primary_expression (line 16705) | fn __parse_gnu_primary_expression<'input>(__input: &'input str, __state:...
function __parse_statement_expression (line 16728) | fn __parse_statement_expression<'input>(__input: &'input str, __state: &...
function __parse_va_arg_expression (line 16809) | fn __parse_va_arg_expression<'input>(__input: &'input str, __state: &mut...
function __parse_va_arg_expression_inner (line 16838) | fn __parse_va_arg_expression_inner<'input>(__input: &'input str, __state...
function __parse_keyword_expression (line 16942) | fn __parse_keyword_expression<'input>(__input: &'input str, __state: &mu...
function __parse_keyword_expression0 (line 16980) | fn __parse_keyword_expression0<'input>(__input: &'input str, __state: &m...
function __parse_offsetof_expression (line 17096) | fn __parse_offsetof_expression<'input>(__input: &'input str, __state: &m...
function __parse_offsetof_expression_inner (line 17125) | fn __parse_offsetof_expression_inner<'input>(__input: &'input str, __sta...
function __parse_offsetof_designator (line 17247) | fn __parse_offsetof_designator<'input>(__input: &'input str, __state: &m...
function __parse_offsetof_member (line 17320) | fn __parse_offsetof_member<'input>(__input: &'input str, __state: &mut P...
function __parse_typeof_specifier (line 17421) | fn __parse_typeof_specifier<'input>(__input: &'input str, __state: &mut ...
function __parse_typeof_specifier0 (line 17534) | fn __parse_typeof_specifier0<'input>(__input: &'input str, __state: &mut...
function __parse_ts18661_float_type_specifier (line 17575) | fn __parse_ts18661_float_type_specifier<'input>(__input: &'input str, __...
function __parse_ts18661_binary_float (line 17586) | fn __parse_ts18661_binary_float<'input>(__input: &'input str, __state: &...
function __parse_ts18661_binary_width (line 17612) | fn __parse_ts18661_binary_width<'input>(__input: &'input str, __state: &...
function __parse_ts18661_decimal_float (line 17647) | fn __parse_ts18661_decimal_float<'input>(__input: &'input str, __state: ...
function __parse_ts18661_decimal_width (line 17673) | fn __parse_ts18661_decimal_width<'input>(__input: &'input str, __state: ...
function __parse_ts18661_float_suffix (line 17702) | fn __parse_ts18661_float_suffix<'input>(__input: &'input str, __state: &...
function __parse_clang_guard (line 17825) | fn __parse_clang_guard<'input>(__input: &'input str, __state: &mut Parse...
function constant (line 17842) | pub fn constant<'input>(__input: &'input str, env: &mut Env) -> ParseRes...
function string_literal (line 17857) | pub fn string_literal<'input>(__input: &'input str, env: &mut Env) -> Pa...
function expression (line 17872) | pub fn expression<'input>(__input: &'input str, env: &mut Env) -> ParseR...
function declaration (line 17887) | pub fn declaration<'input>(__input: &'input str, env: &mut Env) -> Parse...
function statement (line 17902) | pub fn statement<'input>(__input: &'input str, env: &mut Env) -> ParseRe...
function translation_unit (line 17917) | pub fn translation_unit<'input>(__input: &'input str, env: &mut Env) -> ...
FILE: src/print.rs
type Printer (line 24) | pub struct Printer<'a> {
function new (line 30) | pub fn new(w: &mut fmt::Write) -> Printer {
function block (line 34) | fn block(&mut self) -> Printer {
function name (line 42) | fn name(&mut self, name: &str) {
function field (line 46) | fn field<T: fmt::Display>(&mut self, s: T) {
function field_str (line 50) | fn field_str(&mut self, s: &str) {
function field_str_ext (line 54) | fn field_str_ext(&mut self, prefix: &str, str: &str) {
function visit_identifier (line 60) | fn visit_identifier(&mut self, n: &'ast Identifier, span: &'ast Span) {
function visit_constant (line 65) | fn visit_constant(&mut self, n: &'ast Constant, span: &'ast Span) {
function visit_integer (line 77) | fn visit_integer(&mut self, n: &'ast Integer, span: &'ast Span) {
function visit_integer_base (line 82) | fn visit_integer_base(&mut self, n: &'ast IntegerBase, span: &'ast Span) {
function visit_integer_suffix (line 92) | fn visit_integer_suffix(&mut self, n: &'ast IntegerSuffix, span: &'ast S...
function visit_integer_size (line 98) | fn visit_integer_size(&mut self, n: &'ast IntegerSize, span: &'ast Span) {
function visit_float (line 107) | fn visit_float(&mut self, n: &'ast Float, span: &'ast Span) {
function visit_float_base (line 112) | fn visit_float_base(&mut self, n: &'ast FloatBase, span: &'ast Span) {
function visit_float_suffix (line 120) | fn visit_float_suffix(&mut self, n: &'ast FloatSuffix, span: &'ast Span) {
function visit_float_format (line 125) | fn visit_float_format(&mut self, n: &'ast FloatFormat, span: &'ast Span) {
function visit_string_literal (line 130) | fn visit_string_literal(&mut self, n: &'ast StringLiteral, span: &'ast S...
function visit_expression (line 143) | fn visit_expression(&mut self, n: &'ast Expression, span: &'ast Span) {
function visit_member_operator (line 147) | fn visit_member_operator(&mut self, n: &'ast MemberOperator, span: &'ast...
function visit_generic_selection (line 155) | fn visit_generic_selection(&mut self, n: &'ast GenericSelection, span: &...
function visit_generic_association (line 159) | fn visit_generic_association(&mut self, n: &'ast GenericAssociation, spa...
function visit_generic_association_type (line 163) | fn visit_generic_association_type(
function visit_member_expression (line 171) | fn visit_member_expression(&mut self, n: &'ast MemberExpression, span: &...
function visit_call_expression (line 175) | fn visit_call_expression(&mut self, n: &'ast CallExpression, span: &'ast...
function visit_compound_literal (line 179) | fn visit_compound_literal(&mut self, n: &'ast CompoundLiteral, span: &'a...
function visit_sizeofty (line 183) | fn visit_sizeofty(&mut self, n: &'ast SizeOfTy, span: &'ast Span) {
function visit_sizeofval (line 187) | fn visit_sizeofval(&mut self, n: &'ast SizeOfVal, span: &'ast Span) {
function visit_alignof (line 191) | fn visit_alignof(&mut self, n: &'ast AlignOf, span: &'ast Span) {
function visit_unary_operator (line 195) | fn visit_unary_operator(&mut self, n: &'ast UnaryOperator, span: &'ast S...
function visit_unary_operator_expression (line 211) | fn visit_unary_operator_expression(
function visit_cast_expression (line 219) | fn visit_cast_expression(&mut self, n: &'ast CastExpression, span: &'ast...
function visit_binary_operator (line 223) | fn visit_binary_operator(&mut self, n: &'ast BinaryOperator, span: &'ast...
function visit_binary_operator_expression (line 259) | fn visit_binary_operator_expression(
function visit_conditional_expression (line 267) | fn visit_conditional_expression(&mut self, n: &'ast ConditionalExpressio...
function visit_va_arg_expression (line 271) | fn visit_va_arg_expression(&mut self, n: &'ast VaArgExpression, span: &'...
function visit_offset_of_expression (line 275) | fn visit_offset_of_expression(&mut self, n: &'ast OffsetOfExpression, sp...
function visit_offset_designator (line 279) | fn visit_offset_designator(&mut self, n: &'ast OffsetDesignator, span: &...
function visit_offset_member (line 283) | fn visit_offset_member(&mut self, n: &'ast OffsetMember, span: &'ast Spa...
function visit_declaration (line 288) | fn visit_declaration(&mut self, n: &'ast Declaration, span: &'ast Span) {
function visit_declaration_specifier (line 292) | fn visit_declaration_specifier(&mut self, n: &'ast DeclarationSpecifier,...
function visit_init_declarator (line 296) | fn visit_init_declarator(&mut self, n: &'ast InitDeclarator, span: &'ast...
function visit_storage_class_specifier (line 300) | fn visit_storage_class_specifier(&mut self, n: &'ast StorageClassSpecifi...
function visit_type_specifier (line 312) | fn visit_type_specifier(&mut self, n: &'ast TypeSpecifier, span: &'ast S...
function visit_ts18661_float_type (line 317) | fn visit_ts18661_float_type(&mut self, n: &'ast TS18661FloatType, span: ...
function visit_ts18661_float_format (line 322) | fn visit_ts18661_float_format(&mut self, n: &'ast TS18661FloatFormat, sp...
function visit_struct_type (line 332) | fn visit_struct_type(&mut self, n: &'ast StructType, span: &'ast Span) {
function visit_struct_kind (line 336) | fn visit_struct_kind(&mut self, n: &'ast StructKind, span: &'ast Span) {
function visit_struct_declaration (line 344) | fn visit_struct_declaration(&mut self, n: &'ast StructDeclaration, span:...
function visit_struct_field (line 348) | fn visit_struct_field(&mut self, n: &'ast StructField, span: &'ast Span) {
function visit_specifier_qualifier (line 352) | fn visit_specifier_qualifier(&mut self, n: &'ast SpecifierQualifier, spa...
function visit_struct_declarator (line 356) | fn visit_struct_declarator(&mut self, n: &'ast StructDeclarator, span: &...
function visit_enum_type (line 360) | fn visit_enum_type(&mut self, n: &'ast EnumType, span: &'ast Span) {
function visit_enumerator (line 364) | fn visit_enumerator(&mut self, n: &'ast Enumerator, span: &'ast Span) {
function visit_type_qualifier (line 368) | fn visit_type_qualifier(&mut self, n: &'ast TypeQualifier, span: &'ast S...
function visit_function_specifier (line 381) | fn visit_function_specifier(&mut self, n: &'ast FunctionSpecifier, span:...
function visit_alignment_specifier (line 389) | fn visit_alignment_specifier(&mut self, n: &'ast AlignmentSpecifier, spa...
function visit_declarator (line 393) | fn visit_declarator(&mut self, n: &'ast Declarator, span: &'ast Span) {
function visit_declarator_kind (line 397) | fn visit_declarator_kind(&mut self, n: &'ast DeclaratorKind, span: &'ast...
function visit_derived_declarator (line 402) | fn visit_derived_declarator(&mut self, n: &'ast DerivedDeclarator, span:...
function visit_array_declarator (line 407) | fn visit_array_declarator(&mut self, n: &'ast ArrayDeclarator, span: &'a...
function visit_function_declarator (line 411) | fn visit_function_declarator(&mut self, n: &'ast FunctionDeclarator, spa...
function visit_pointer_qualifier (line 415) | fn visit_pointer_qualifier(&mut self, n: &'ast PointerQualifier, span: &...
function visit_array_size (line 419) | fn visit_array_size(&mut self, n: &'ast ArraySize, span: &'ast Span) {
function visit_parameter_declaration (line 424) | fn visit_parameter_declaration(&mut self, n: &'ast ParameterDeclaration,...
function visit_ellipsis (line 428) | fn visit_ellipsis(&mut self, n: &'ast Ellipsis, span: &'ast Span) {
function visit_type_name (line 436) | fn visit_type_name(&mut self, n: &'ast TypeName, span: &'ast Span) {
function visit_initializer (line 440) | fn visit_initializer(&mut self, n: &'ast Initializer, span: &'ast Span) {
function visit_initializer_list_item (line 444) | fn visit_initializer_list_item(&mut self, n: &'ast InitializerListItem, ...
function visit_designator (line 448) | fn visit_designator(&mut self, n: &'ast Designator, span: &'ast Span) {
function visit_range_designator (line 452) | fn visit_range_designator(&mut self, n: &'ast RangeDesignator, span: &'a...
function visit_static_assert (line 456) | fn visit_static_assert(&mut self, n: &'ast StaticAssert, span: &'ast Spa...
function visit_statement (line 460) | fn visit_statement(&mut self, n: &'ast Statement, span: &'ast Span) {
function visit_labeled_statement (line 465) | fn visit_labeled_statement(&mut self, n: &'ast LabeledStatement, span: &...
function visit_if_statement (line 469) | fn visit_if_statement(&mut self, n: &'ast IfStatement, span: &'ast Span) {
function visit_switch_statement (line 473) | fn visit_switch_statement(&mut self, n: &'ast SwitchStatement, span: &'a...
function visit_while_statement (line 477) | fn visit_while_statement(&mut self, n: &'ast WhileStatement, span: &'ast...
function visit_do_while_statement (line 481) | fn visit_do_while_statement(&mut self, n: &'ast DoWhileStatement, span: ...
function visit_for_statement (line 485) | fn visit_for_statement(&mut self, n: &'ast ForStatement, span: &'ast Spa...
function visit_label (line 489) | fn visit_label(&mut self, n: &'ast Label, span: &'ast Span) {
function visit_case_range (line 494) | fn visit_case_range(&mut self, n: &'ast CaseRange, span: &'ast Span) {
function visit_for_initializer (line 498) | fn visit_for_initializer(&mut self, n: &'ast ForInitializer, span: &'ast...
function visit_block_item (line 503) | fn visit_block_item(&mut self, n: &'ast BlockItem, span: &'ast Span) {
function visit_external_declaration (line 507) | fn visit_external_declaration(&mut self, n: &'ast ExternalDeclaration, s...
function visit_function_definition (line 511) | fn visit_function_definition(&mut self, n: &'ast FunctionDefinition, spa...
function visit_extension (line 515) | fn visit_extension(&mut self, n: &'ast Extension, span: &'ast Span) {
function visit_attribute (line 519) | fn visit_attribute(&mut self, n: &'ast Attribute, span: &'ast Span) {
function visit_asm_statement (line 524) | fn visit_asm_statement(&mut self, n: &'ast AsmStatement, span: &'ast Spa...
function visit_availability_attribute (line 528) | fn visit_availability_attribute(&mut self, n: &'ast AvailabilityAttribut...
function visit_gnu_extended_asm_statement (line 532) | fn visit_gnu_extended_asm_statement(
function visit_gnu_asm_operand (line 540) | fn visit_gnu_asm_operand(&mut self, n: &'ast GnuAsmOperand, span: &'ast ...
function visit_type_of (line 544) | fn visit_type_of(&mut self, n: &'ast TypeOf, span: &'ast Span) {
function visit_translation_unit (line 548) | fn visit_translation_unit(&mut self, translation_unit: &'ast Translation...
function print_float_format (line 554) | fn print_float_format<'ast>(p: &mut Printer, n: &'ast FloatFormat) {
function print_declarator_kind (line 562) | fn print_declarator_kind<'ast>(p: &mut Printer, n: &'ast DeclaratorKind) {
function print_derived_declarator (line 568) | fn print_derived_declarator<'ast>(p: &mut Printer, n: &'ast DerivedDecla...
function print_array_size (line 576) | fn print_array_size<'ast>(p: &mut Printer, n: &'ast ArraySize) {
function print_statement (line 584) | fn print_statement<'ast>(p: &mut Printer, n: &'ast Statement) {
function print_offset_member (line 594) | fn print_offset_member<'ast>(p: &mut Printer, n: &'ast OffsetMember) {
function print_label (line 601) | fn print_label<'ast>(p: &mut Printer, n: &'ast Label) {
function print_for_initializer (line 607) | fn print_for_initializer<'ast>(p: &mut Printer, n: &'ast ForInitializer) {
function print_type_specifier (line 613) | fn print_type_specifier<'ast>(p: &mut Printer, n: &'ast TypeSpecifier) {
type Escape (line 631) | struct Escape<'a>(&'a str);
function fmt (line 634) | fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
function test_escape (line 650) | fn test_escape() {
FILE: src/span.rs
type Span (line 7) | pub struct Span {
method span (line 14) | pub fn span(start: usize, end: usize) -> Span {
method none (line 22) | pub fn none() -> Span {
method is_none (line 30) | pub fn is_none(&self) -> bool {
method eq (line 36) | fn eq(&self, other: &Self) -> bool {
method fmt (line 42) | fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
type Node (line 53) | pub struct Node<T> {
function new (line 60) | pub fn new(node: T, span: Span) -> Node<T> {
FILE: src/strings.rs
constant RESERVED_C11 (line 1) | pub const RESERVED_C11: &'static [&'static str] = &[
constant RESERVED_GNU (line 62) | pub const RESERVED_GNU: &'static [&'static str] = &[
constant RESERVED_CLANG (line 97) | pub const RESERVED_CLANG: &'static [&'static str] = &[
FILE: src/tests.rs
type Case (line 18) | struct Case {
method from_path (line 31) | fn from_path(entry: &DirEntry) -> io::Result<Case> {
method run (line 73) | fn run(&self) -> bool {
method save (line 159) | fn save(&self, actual: &str) -> io::Result<()> {
constant OUTPUT_START (line 27) | const OUTPUT_START: &'static str = "/*===";
constant OUTPUT_END (line 28) | const OUTPUT_END: &'static str = "===*/";
type Kind (line 196) | enum Kind {
method from_str (line 205) | fn from_str(kind: &str) -> Option<Kind> {
method parse_and_print (line 216) | fn parse_and_print(&self, source: &str, env: &mut Env) -> Result<Strin...
type Pragma (line 251) | enum Pragma {
method from_str (line 263) | fn from_str(line: &str) -> Option<Pragma> {
function filter_entry (line 285) | fn filter_entry(a: &DirEntry, filter: Option<&OsString>) -> bool {
function reftest_main (line 302) | fn reftest_main() {
function marker_start (line 327) | pub fn marker_start(source: &str) {
function marker_stop (line 330) | pub fn marker_stop() {
function marker_start (line 337) | pub fn marker_start(_: &str) {}
function marker_stop (line 338) | pub fn marker_stop() {}
FILE: src/visit.rs
type Visit (line 24) | pub trait Visit<'ast> {
method visit_identifier (line 25) | fn visit_identifier(&mut self, identifier: &'ast Identifier, span: &'a...
method visit_constant (line 29) | fn visit_constant(&mut self, constant: &'ast Constant, span: &'ast Spa...
method visit_integer (line 33) | fn visit_integer(&mut self, integer: &'ast Integer, span: &'ast Span) {
method visit_integer_base (line 37) | fn visit_integer_base(&mut self, integer_base: &'ast IntegerBase, span...
method visit_integer_suffix (line 41) | fn visit_integer_suffix(&mut self, integer_suffix: &'ast IntegerSuffix...
method visit_integer_size (line 45) | fn visit_integer_size(&mut self, integer_size: &'ast IntegerSize, span...
method visit_float (line 49) | fn visit_float(&mut self, float: &'ast Float, span: &'ast Span) {
method visit_float_base (line 53) | fn visit_float_base(&mut self, float_base: &'ast FloatBase, span: &'as...
method visit_float_suffix (line 57) | fn visit_float_suffix(&mut self, float_suffix: &'ast FloatSuffix, span...
method visit_float_format (line 61) | fn visit_float_format(&mut self, float_format: &'ast FloatFormat, span...
method visit_string_literal (line 65) | fn visit_string_literal(&mut self, string_literal: &'ast StringLiteral...
method visit_expression (line 69) | fn visit_expression(&mut self, expression: &'ast Expression, span: &'a...
method visit_member_operator (line 73) | fn visit_member_operator(&mut self, member_operator: &'ast MemberOpera...
method visit_generic_selection (line 77) | fn visit_generic_selection(
method visit_generic_association (line 85) | fn visit_generic_association(
method visit_generic_association_type (line 93) | fn visit_generic_association_type(
method visit_member_expression (line 101) | fn visit_member_expression(
method visit_call_expression (line 109) | fn visit_call_expression(&mut self, call_expression: &'ast CallExpress...
method visit_compound_literal (line 113) | fn visit_compound_literal(
method visit_sizeofty (line 121) | fn visit_sizeofty(&mut self, sizeofty: &'ast SizeOfTy, span: &'ast Spa...
method visit_sizeofval (line 124) | fn visit_sizeofval(&mut self, sizeofval: &'ast SizeOfVal, span: &'ast ...
method visit_alignof (line 128) | fn visit_alignof(&mut self, alignofty: &'ast AlignOf, span: &'ast Span) {
method visit_unary_operator (line 132) | fn visit_unary_operator(&mut self, unary_operator: &'ast UnaryOperator...
method visit_unary_operator_expression (line 136) | fn visit_unary_operator_expression(
method visit_cast_expression (line 144) | fn visit_cast_expression(&mut self, cast_expression: &'ast CastExpress...
method visit_binary_operator (line 148) | fn visit_binary_operator(&mut self, binary_operator: &'ast BinaryOpera...
method visit_binary_operator_expression (line 152) | fn visit_binary_operator_expression(
method visit_conditional_expression (line 160) | fn visit_conditional_expression(
method visit_va_arg_expression (line 168) | fn visit_va_arg_expression(
method visit_offset_of_expression (line 176) | fn visit_offset_of_expression(
method visit_offset_designator (line 184) | fn visit_offset_designator(
method visit_offset_member (line 192) | fn visit_offset_member(&mut self, offset_member: &'ast OffsetMember, s...
method visit_declaration (line 196) | fn visit_declaration(&mut self, declaration: &'ast Declaration, span: ...
method visit_declaration_specifier (line 200) | fn visit_declaration_specifier(
method visit_init_declarator (line 208) | fn visit_init_declarator(&mut self, init_declarator: &'ast InitDeclara...
method visit_storage_class_specifier (line 212) | fn visit_storage_class_specifier(
method visit_type_specifier (line 220) | fn visit_type_specifier(&mut self, type_specifier: &'ast TypeSpecifier...
method visit_ts18661_float_type (line 224) | fn visit_ts18661_float_type(
method visit_ts18661_float_format (line 232) | fn visit_ts18661_float_format(
method visit_struct_type (line 240) | fn visit_struct_type(&mut self, struct_type: &'ast StructType, span: &...
method visit_struct_kind (line 244) | fn visit_struct_kind(&mut self, struct_kind: &'ast StructKind, span: &...
method visit_struct_declaration (line 248) | fn visit_struct_declaration(
method visit_struct_field (line 256) | fn visit_struct_field(&mut self, struct_field: &'ast StructField, span...
method visit_specifier_qualifier (line 260) | fn visit_specifier_qualifier(
method visit_struct_declarator (line 268) | fn visit_struct_declarator(
method visit_enum_type (line 276) | fn visit_enum_type(&mut self, enum_type: &'ast EnumType, span: &'ast S...
method visit_enumerator (line 280) | fn visit_enumerator(&mut self, enumerator: &'ast Enumerator, span: &'a...
method visit_type_qualifier (line 284) | fn visit_type_qualifier(&mut self, type_qualifier: &'ast TypeQualifier...
method visit_function_specifier (line 288) | fn visit_function_specifier(
method visit_alignment_specifier (line 296) | fn visit_alignment_specifier(
method visit_declarator (line 304) | fn visit_declarator(&mut self, declarator: &'ast Declarator, span: &'a...
method visit_declarator_kind (line 308) | fn visit_declarator_kind(&mut self, declarator_kind: &'ast DeclaratorK...
method visit_derived_declarator (line 312) | fn visit_derived_declarator(
method visit_array_declarator (line 320) | fn visit_array_declarator(
method visit_function_declarator (line 328) | fn visit_function_declarator(
method visit_pointer_qualifier (line 336) | fn visit_pointer_qualifier(
method visit_array_size (line 344) | fn visit_array_size(&mut self, array_size: &'ast ArraySize, span: &'as...
method visit_parameter_declaration (line 348) | fn visit_parameter_declaration(
method visit_ellipsis (line 356) | fn visit_ellipsis(&mut self, ellipsis: &'ast Ellipsis, span: &'ast Spa...
method visit_type_name (line 360) | fn visit_type_name(&mut self, type_name: &'ast TypeName, span: &'ast S...
method visit_initializer (line 364) | fn visit_initializer(&mut self, initializer: &'ast Initializer, span: ...
method visit_initializer_list_item (line 368) | fn visit_initializer_list_item(
method visit_designator (line 376) | fn visit_designator(&mut self, designator: &'ast Designator, span: &'a...
method visit_range_designator (line 380) | fn visit_range_designator(
method visit_static_assert (line 388) | fn visit_static_assert(&mut self, static_assert: &'ast StaticAssert, s...
method visit_statement (line 392) | fn visit_statement(&mut self, statement: &'ast Statement, span: &'ast ...
method visit_labeled_statement (line 396) | fn visit_labeled_statement(
method visit_if_statement (line 404) | fn visit_if_statement(&mut self, if_statement: &'ast IfStatement, span...
method visit_switch_statement (line 408) | fn visit_switch_statement(
method visit_while_statement (line 416) | fn visit_while_statement(&mut self, while_statement: &'ast WhileStatem...
method visit_do_while_statement (line 420) | fn visit_do_while_statement(
method visit_for_statement (line 428) | fn visit_for_statement(&mut self, for_statement: &'ast ForStatement, s...
method visit_label (line 432) | fn visit_label(&mut self, label: &'ast Label, span: &'ast Span) {
method visit_case_range (line 436) | fn visit_case_range(&mut self, range: &'ast CaseRange, span: &'ast Spa...
method visit_for_initializer (line 440) | fn visit_for_initializer(&mut self, for_initializer: &'ast ForInitiali...
method visit_block_item (line 444) | fn visit_block_item(&mut self, block_item: &'ast BlockItem, span: &'as...
method visit_translation_unit (line 448) | fn visit_translation_unit(&mut self, translation_unit: &'ast Translati...
method visit_external_declaration (line 452) | fn visit_external_declaration(
method visit_function_definition (line 460) | fn visit_function_definition(
method visit_extension (line 468) | fn visit_extension(&mut self, extension: &'ast Extension, span: &'ast ...
method visit_attribute (line 472) | fn visit_attribute(&mut self, attribute: &'ast Attribute, span: &'ast ...
method visit_asm_statement (line 476) | fn visit_asm_statement(&mut self, asm_statement: &'ast AsmStatement, s...
method visit_availability_attribute (line 480) | fn visit_availability_attribute(
method visit_availability_clause (line 488) | fn visit_availability_clause(&mut self, _clause: &'ast AvailabilityCla...
method visit_gnu_extended_asm_statement (line 490) | fn visit_gnu_extended_asm_statement(
method visit_gnu_asm_operand (line 498) | fn visit_gnu_asm_operand(&mut self, gnu_asm_operand: &'ast GnuAsmOpera...
method visit_type_of (line 502) | fn visit_type_of(&mut self, type_of: &'ast TypeOf, span: &'ast Span) {
function visit_identifier (line 507) | pub fn visit_identifier<'ast, V: Visit<'ast> + ?Sized>(
function visit_constant (line 514) | pub fn visit_constant<'ast, V: Visit<'ast> + ?Sized>(
function visit_integer (line 526) | pub fn visit_integer<'ast, V: Visit<'ast> + ?Sized>(
function visit_integer_base (line 535) | pub fn visit_integer_base<'ast, V: Visit<'ast> + ?Sized>(
function visit_integer_suffix (line 542) | pub fn visit_integer_suffix<'ast, V: Visit<'ast> + ?Sized>(
function visit_integer_size (line 550) | pub fn visit_integer_size<'ast, V: Visit<'ast> + ?Sized>(
function visit_float (line 557) | pub fn visit_float<'ast, V: Visit<'ast> + ?Sized>(
function visit_float_base (line 566) | pub fn visit_float_base<'ast, V: Visit<'ast> + ?Sized>(
function visit_float_suffix (line 573) | pub fn visit_float_suffix<'ast, V: Visit<'ast> + ?Sized>(
function visit_float_format (line 581) | pub fn visit_float_format<'ast, V: Visit<'ast> + ?Sized>(
function visit_string_literal (line 592) | pub fn visit_string_literal<'ast, V: Visit<'ast> + ?Sized>(
function visit_expression (line 599) | pub fn visit_expression<'ast, V: Visit<'ast> + ?Sized>(
function visit_member_operator (line 634) | pub fn visit_member_operator<'ast, V: Visit<'ast> + ?Sized>(
function visit_generic_selection (line 641) | pub fn visit_generic_selection<'ast, V: Visit<'ast> + ?Sized>(
function visit_generic_association (line 655) | pub fn visit_generic_association<'ast, V: Visit<'ast> + ?Sized>(
function visit_generic_association_type (line 666) | pub fn visit_generic_association_type<'ast, V: Visit<'ast> + ?Sized>(
function visit_member_expression (line 681) | pub fn visit_member_expression<'ast, V: Visit<'ast> + ?Sized>(
function visit_call_expression (line 700) | pub fn visit_call_expression<'ast, V: Visit<'ast> + ?Sized>(
function visit_compound_literal (line 711) | pub fn visit_compound_literal<'ast, V: Visit<'ast> + ?Sized>(
function visit_sizeofty (line 725) | pub fn visit_sizeofty<'ast, V: Visit<'ast> + ?Sized>(
function visit_sizeofval (line 733) | pub fn visit_sizeofval<'ast, V: Visit<'ast> + ?Sized>(
function visit_alignof (line 741) | pub fn visit_alignof<'ast, V: Visit<'ast> + ?Sized>(
function visit_unary_operator (line 749) | pub fn visit_unary_operator<'ast, V: Visit<'ast> + ?Sized>(
function visit_unary_operator_expression (line 756) | pub fn visit_unary_operator_expression<'ast, V: Visit<'ast> + ?Sized>(
function visit_cast_expression (line 785) | pub fn visit_cast_expression<'ast, V: Visit<'ast> + ?Sized>(
function visit_binary_operator (line 800) | pub fn visit_binary_operator<'ast, V: Visit<'ast> + ?Sized>(
function visit_binary_operator_expression (line 807) | pub fn visit_binary_operator_expression<'ast, V: Visit<'ast> + ?Sized>(
function visit_conditional_expression (line 826) | pub fn visit_conditional_expression<'ast, V: Visit<'ast> + ?Sized>(
function visit_va_arg_expression (line 845) | pub fn visit_va_arg_expression<'ast, V: Visit<'ast> + ?Sized>(
function visit_offset_of_expression (line 860) | pub fn visit_offset_of_expression<'ast, V: Visit<'ast> + ?Sized>(
function visit_offset_designator (line 875) | pub fn visit_offset_designator<'ast, V: Visit<'ast> + ?Sized>(
function visit_offset_member (line 886) | pub fn visit_offset_member<'ast, V: Visit<'ast> + ?Sized>(
function visit_declaration (line 898) | pub fn visit_declaration<'ast, V: Visit<'ast> + ?Sized>(
function visit_declaration_specifier (line 912) | pub fn visit_declaration_specifier<'ast, V: Visit<'ast> + ?Sized>(
function visit_init_declarator (line 939) | pub fn visit_init_declarator<'ast, V: Visit<'ast> + ?Sized>(
function visit_storage_class_specifier (line 953) | pub fn visit_storage_class_specifier<'ast, V: Visit<'ast> + ?Sized>(
function visit_type_specifier (line 960) | pub fn visit_type_specifier<'ast, V: Visit<'ast> + ?Sized>(
function visit_ts18661_float_type (line 976) | pub fn visit_ts18661_float_type<'ast, V: Visit<'ast> + ?Sized>(
function visit_ts18661_float_format (line 984) | pub fn visit_ts18661_float_format<'ast, V: Visit<'ast> + ?Sized>(
function visit_struct_type (line 991) | pub fn visit_struct_type<'ast, V: Visit<'ast> + ?Sized>(
function visit_struct_kind (line 1007) | pub fn visit_struct_kind<'ast, V: Visit<'ast> + ?Sized>(
function visit_struct_declaration (line 1014) | pub fn visit_struct_declaration<'ast, V: Visit<'ast> + ?Sized>(
function visit_struct_field (line 1025) | pub fn visit_struct_field<'ast, V: Visit<'ast> + ?Sized>(
function visit_specifier_qualifier (line 1038) | pub fn visit_specifier_qualifier<'ast, V: Visit<'ast> + ?Sized>(
function visit_struct_declarator (line 1054) | pub fn visit_struct_declarator<'ast, V: Visit<'ast> + ?Sized>(
function visit_enum_type (line 1067) | pub fn visit_enum_type<'ast, V: Visit<'ast> + ?Sized>(
function visit_enumerator (line 1080) | pub fn visit_enumerator<'ast, V: Visit<'ast> + ?Sized>(
function visit_type_qualifier (line 1094) | pub fn visit_type_qualifier<'ast, V: Visit<'ast> + ?Sized>(
function visit_function_specifier (line 1101) | pub fn visit_function_specifier<'ast, V: Visit<'ast> + ?Sized>(
function visit_alignment_specifier (line 1108) | pub fn visit_alignment_specifier<'ast, V: Visit<'ast> + ?Sized>(
function visit_declarator (line 1119) | pub fn visit_declarator<'ast, V: Visit<'ast> + ?Sized>(
function visit_declarator_kind (line 1133) | pub fn visit_declarator_kind<'ast, V: Visit<'ast> + ?Sized>(
function visit_derived_declarator (line 1145) | pub fn visit_derived_declarator<'ast, V: Visit<'ast> + ?Sized>(
function visit_array_declarator (line 1171) | pub fn visit_array_declarator<'ast, V: Visit<'ast> + ?Sized>(
function visit_function_declarator (line 1182) | pub fn visit_function_declarator<'ast, V: Visit<'ast> + ?Sized>(
function visit_pointer_qualifier (line 1193) | pub fn visit_pointer_qualifier<'ast, V: Visit<'ast> + ?Sized>(
function visit_array_size (line 1208) | pub fn visit_array_size<'ast, V: Visit<'ast> + ?Sized>(
function visit_parameter_declaration (line 1220) | pub fn visit_parameter_declaration<'ast, V: Visit<'ast> + ?Sized>(
function visit_ellipsis (line 1236) | pub fn visit_ellipsis<'ast, V: Visit<'ast> + ?Sized>(
function visit_type_name (line 1243) | pub fn visit_type_name<'ast, V: Visit<'ast> + ?Sized>(
function visit_initializer (line 1256) | pub fn visit_initializer<'ast, V: Visit<'ast> + ?Sized>(
function visit_initializer_list_item (line 1271) | pub fn visit_initializer_list_item<'ast, V: Visit<'ast> + ?Sized>(
function visit_designator (line 1285) | pub fn visit_designator<'ast, V: Visit<'ast> + ?Sized>(
function visit_range_designator (line 1297) | pub fn visit_range_designator<'ast, V: Visit<'ast> + ?Sized>(
function visit_static_assert (line 1306) | pub fn visit_static_assert<'ast, V: Visit<'ast> + ?Sized>(
function visit_statement (line 1318) | pub fn visit_statement<'ast, V: Visit<'ast> + ?Sized>(
function visit_labeled_statement (line 1347) | pub fn visit_labeled_statement<'ast, V: Visit<'ast> + ?Sized>(
function visit_if_statement (line 1359) | pub fn visit_if_statement<'ast, V: Visit<'ast> + ?Sized>(
function visit_switch_statement (line 1374) | pub fn visit_switch_statement<'ast, V: Visit<'ast> + ?Sized>(
function visit_while_statement (line 1389) | pub fn visit_while_statement<'ast, V: Visit<'ast> + ?Sized>(
function visit_do_while_statement (line 1404) | pub fn visit_do_while_statement<'ast, V: Visit<'ast> + ?Sized>(
function visit_for_statement (line 1419) | pub fn visit_for_statement<'ast, V: Visit<'ast> + ?Sized>(
function visit_label (line 1437) | pub fn visit_label<'ast, V: Visit<'ast> + ?Sized>(
function visit_case_range (line 1450) | pub fn visit_case_range<'ast, V: Visit<'ast> + ?Sized>(
function visit_for_initializer (line 1459) | pub fn visit_for_initializer<'ast, V: Visit<'ast> + ?Sized>(
function visit_block_item (line 1472) | pub fn visit_block_item<'ast, V: Visit<'ast> + ?Sized>(
function visit_translation_unit (line 1484) | pub fn visit_translation_unit<'ast, V: Visit<'ast> + ?Sized>(
function visit_external_declaration (line 1493) | pub fn visit_external_declaration<'ast, V: Visit<'ast> + ?Sized>(
function visit_function_definition (line 1507) | pub fn visit_function_definition<'ast, V: Visit<'ast> + ?Sized>(
function visit_extension (line 1528) | pub fn visit_extension<'ast, V: Visit<'ast> + ?Sized>(
function visit_attribute (line 1542) | pub fn visit_attribute<'ast, V: Visit<'ast> + ?Sized>(
function visit_asm_statement (line 1552) | pub fn visit_asm_statement<'ast, V: Visit<'ast> + ?Sized>(
function visit_availability_attribute (line 1563) | pub fn visit_availability_attribute<'ast, V: Visit<'ast> + ?Sized>(
function visit_gnu_extended_asm_statement (line 1573) | pub fn visit_gnu_extended_asm_statement<'ast, V: Visit<'ast> + ?Sized>(
function visit_gnu_asm_operand (line 1596) | pub fn visit_gnu_asm_operand<'ast, V: Visit<'ast> + ?Sized>(
function visit_type_of (line 1614) | pub fn visit_type_of<'ast, V: Visit<'ast> + ?Sized>(
Condensed preview — 164 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (1,351K chars).
[
{
"path": ".github/workflows/ci.yml",
"chars": 496,
"preview": "on: \n push:\n pull_request:\n schedule: [cron: \"40 6 10 1/2 *\"]\n\nname: Tests\n\njobs:\n test:\n name: test\n runs-on:"
},
{
"path": ".gitignore",
"chars": 32,
"preview": "/Cargo.lock\n/target/\n**/*.rs.bk\n"
},
{
"path": "Cargo.toml",
"chars": 531,
"preview": "[package]\nname = \"lang-c\"\nversion = \"0.15.1\"\nauthors = [\"Vickenty Fesunov <kent@setattr.net>\"]\nlicense = \"MIT/Apache-2.0"
},
{
"path": "LICENSE-APACHE",
"chars": 10847,
"preview": " Apache License\n Version 2.0, January 2004\n http"
},
{
"path": "LICENSE-MIT",
"chars": 1023,
"preview": "Permission is hereby granted, free of charge, to any\nperson obtaining a copy of this software and associated\ndocumentati"
},
{
"path": "Makefile",
"chars": 531,
"preview": ".PHONY: all lib\n\npeg?=rust-peg\n\nall: src/parser.rs\n\tcargo b --lib --features '$(features)'\n\tcargo t --features '$(featur"
},
{
"path": "README.md",
"chars": 1406,
"preview": "# Lang-C\n\n[](https://docs.rs/lang-c)\n\nLigtweight parser of C language "
},
{
"path": "grammar.header",
"chars": 106,
"preview": "#![cfg_attr(rustfmt, rustfmt_skip)]\n#![allow(unknown_lints)]\n#![allow(ellipsis_inclusive_range_patterns)]\n"
},
{
"path": "grammar.rustfmt",
"chars": 33,
"preview": "max_width = 10000\ntab_spaces = 4\n"
},
{
"path": "grammar.rustpeg",
"chars": 42895,
"preview": "// Written for peg 0.5.4\n\n#![arguments(env: &mut Env)]\n\nuse ast::*;\nuse astutil::*;\nuse env::{Env, Symbol};\nuse span::{N"
},
{
"path": "reftests/constant-322.c",
"chars": 142,
"preview": "#pragma gnu\n0\n\n/*===\nConstant\n Integer \"0\"\n IntegerBase Decimal\n IntegerSuffix false false\n "
},
{
"path": "reftests/constant-323.c",
"chars": 142,
"preview": "#pragma gnu\n1\n\n/*===\nConstant\n Integer \"1\"\n IntegerBase Decimal\n IntegerSuffix false false\n "
},
{
"path": "reftests/constant-324.c",
"chars": 160,
"preview": "#pragma gnu\n1234567890\n\n/*===\nConstant\n Integer \"1234567890\"\n IntegerBase Decimal\n IntegerSuffix false "
},
{
"path": "reftests/constant-328.c",
"chars": 153,
"preview": "#pragma gnu\n01234567\n\n/*===\nConstant\n Integer \"1234567\"\n IntegerBase Octal\n IntegerSuffix false false\n "
},
{
"path": "reftests/constant-332.c",
"chars": 188,
"preview": "#pragma gnu\n0x1234567890abdefABCDEF\n\n/*===\nConstant\n Integer \"1234567890abdefABCDEF\"\n IntegerBase Hexadecimal\n"
},
{
"path": "reftests/constant-336.c",
"chars": 173,
"preview": "#pragma gnu\n0b0001001000110100\n\n/*===\nConstant\n Integer \"0001001000110100\"\n IntegerBase Binary\n Integer"
},
{
"path": "reftests/constant-340.c",
"chars": 145,
"preview": "#pragma gnu\n042lu\n\n/*===\nConstant\n Integer \"42\"\n IntegerBase Octal\n IntegerSuffix true false\n "
},
{
"path": "reftests/constant-341.c",
"chars": 145,
"preview": "#pragma gnu\n042ul\n\n/*===\nConstant\n Integer \"42\"\n IntegerBase Octal\n IntegerSuffix true false\n "
},
{
"path": "reftests/constant-342.c",
"chars": 145,
"preview": "#pragma gnu\n042uL\n\n/*===\nConstant\n Integer \"42\"\n IntegerBase Octal\n IntegerSuffix true false\n "
},
{
"path": "reftests/constant-344.c",
"chars": 35,
"preview": "#pragma gnu\n1a\n\n/*===\n~ERROR\n===*/\n"
},
{
"path": "reftests/constant-345.c",
"chars": 35,
"preview": "#pragma gnu\n08\n\n/*===\n~ERROR\n===*/\n"
},
{
"path": "reftests/constant-346.c",
"chars": 36,
"preview": "#pragma gnu\n0xX\n\n/*===\n~ERROR\n===*/\n"
},
{
"path": "reftests/constant-347.c",
"chars": 37,
"preview": "#pragma gnu\n1lul\n\n/*===\n~ERROR\n===*/\n"
},
{
"path": "reftests/constant-348.c",
"chars": 36,
"preview": "#pragma gnu\n2lL\n\n/*===\n~ERROR\n===*/\n"
},
{
"path": "reftests/constant-349.c",
"chars": 36,
"preview": "#pragma gnu\n0b2\n\n/*===\n~ERROR\n===*/\n"
},
{
"path": "reftests/constant-370.c",
"chars": 135,
"preview": "#pragma gnu\n2.\n\n/*===\nConstant\n Float \"2.\"\n FloatBase Decimal\n FloatSuffix false\n FloatForma"
},
{
"path": "reftests/constant-371.c",
"chars": 139,
"preview": "#pragma gnu\n2.e2\n\n/*===\nConstant\n Float \"2.e2\"\n FloatBase Decimal\n FloatSuffix false\n FloatF"
},
{
"path": "reftests/constant-375.c",
"chars": 135,
"preview": "#pragma gnu\n.2\n\n/*===\nConstant\n Float \".2\"\n FloatBase Decimal\n FloatSuffix false\n FloatForma"
},
{
"path": "reftests/constant-376.c",
"chars": 139,
"preview": "#pragma gnu\n.2e2\n\n/*===\nConstant\n Float \".2e2\"\n FloatBase Decimal\n FloatSuffix false\n FloatF"
},
{
"path": "reftests/constant-380.c",
"chars": 137,
"preview": "#pragma gnu\n2.0\n\n/*===\nConstant\n Float \"2.0\"\n FloatBase Decimal\n FloatSuffix false\n FloatFor"
},
{
"path": "reftests/constant-381.c",
"chars": 137,
"preview": "#pragma gnu\n2.0f\n\n/*===\nConstant\n Float \"2.0\"\n FloatBase Decimal\n FloatSuffix false\n FloatFo"
},
{
"path": "reftests/constant-383.c",
"chars": 149,
"preview": "#pragma gnu\n24.01e100\n\n/*===\nConstant\n Float \"24.01e100\"\n FloatBase Decimal\n FloatSuffix false\n "
},
{
"path": "reftests/constant-387.c",
"chars": 151,
"preview": "#pragma gnu\n24.01e+100\n\n/*===\nConstant\n Float \"24.01e+100\"\n FloatBase Decimal\n FloatSuffix false\n "
},
{
"path": "reftests/constant-391.c",
"chars": 151,
"preview": "#pragma gnu\n24.01e-100\n\n/*===\nConstant\n Float \"24.01e-100\"\n FloatBase Decimal\n FloatSuffix false\n "
},
{
"path": "reftests/constant-395.c",
"chars": 149,
"preview": "#pragma gnu\n24.01e100f\n\n/*===\nConstant\n Float \"24.01e100\"\n FloatBase Decimal\n FloatSuffix false\n "
},
{
"path": "reftests/constant-400.c",
"chars": 152,
"preview": "#pragma gnu\n0x2Ap19L\n\n/*===\nConstant\n Float \"2Ap19\"\n FloatBase Hexadecimal\n FloatSuffix false\n "
},
{
"path": "reftests/constant-404.c",
"chars": 154,
"preview": "#pragma gnu\n0x2A.p19L\n\n/*===\nConstant\n Float \"2A.p19\"\n FloatBase Hexadecimal\n FloatSuffix false\n "
},
{
"path": "reftests/constant-408.c",
"chars": 154,
"preview": "#pragma gnu\n0x.DEp19L\n\n/*===\nConstant\n Float \".DEp19\"\n FloatBase Hexadecimal\n FloatSuffix false\n "
},
{
"path": "reftests/constant-412.c",
"chars": 158,
"preview": "#pragma gnu\n0x2A.DEp19L\n\n/*===\nConstant\n Float \"2A.DEp19\"\n FloatBase Hexadecimal\n FloatSuffix false\n "
},
{
"path": "reftests/constant-442.c",
"chars": 226,
"preview": "#pragma gnu\n1.0f64\n\n/*===\nConstant\n Float \"1.0\"\n FloatBase Decimal\n FloatSuffix false\n Float"
},
{
"path": "reftests/constant-446.c",
"chars": 232,
"preview": "#pragma gnu\n0xAp1f16\n\n/*===\nConstant\n Float \"Ap1\"\n FloatBase Hexadecimal\n FloatSuffix false\n "
},
{
"path": "reftests/constant-458.c",
"chars": 52,
"preview": "#pragma gnu\n'a'\n\n/*===\nConstant Character 'a'\n===*/\n"
},
{
"path": "reftests/constant-459.c",
"chars": 54,
"preview": "#pragma gnu\n'\\n'\n\n/*===\nConstant Character '\\n'\n===*/\n"
},
{
"path": "reftests/constant-460.c",
"chars": 54,
"preview": "#pragma gnu\n'\\\\'\n\n/*===\nConstant Character '\\\\'\n===*/\n"
},
{
"path": "reftests/constant-461.c",
"chars": 54,
"preview": "#pragma gnu\n'\\''\n\n/*===\nConstant Character '\\''\n===*/\n"
},
{
"path": "reftests/constant-462.c",
"chars": 54,
"preview": "#pragma gnu\n'\\1'\n\n/*===\nConstant Character '\\1'\n===*/\n"
},
{
"path": "reftests/constant-463.c",
"chars": 56,
"preview": "#pragma gnu\n'\\02'\n\n/*===\nConstant Character '\\02'\n===*/\n"
},
{
"path": "reftests/constant-464.c",
"chars": 58,
"preview": "#pragma gnu\n'\\027'\n\n/*===\nConstant Character '\\027'\n===*/\n"
},
{
"path": "reftests/constant-465.c",
"chars": 58,
"preview": "#pragma gnu\n'\\xde'\n\n/*===\nConstant Character '\\xde'\n===*/\n"
},
{
"path": "reftests/constant-466.c",
"chars": 24,
"preview": "'\\c'\n/*===\n~ERROR\n===*/\n"
},
{
"path": "reftests/declaration-1080.c",
"chars": 2165,
"preview": "#pragma gnu\n__attribute__((noreturn)) void d0 (void),\n__attribute__((format(printf, 1, 2))) d1 (const char *, ...),\nd2 ("
},
{
"path": "reftests/declaration-1443.c",
"chars": 1857,
"preview": "#pragma gnu\nunion { long double __l; int __i[3]; } __u = { __l: __x };\n\n/*===\nDeclaration\n DeclarationSpecifier\n "
},
{
"path": "reftests/declaration-1610.c",
"chars": 840,
"preview": "#pragma gnu\n__typeof__(foo(bar, baz)) ook = foo(bar, baz);\n\n/*===\nDeclaration\n DeclarationSpecifier\n TypeSpeci"
},
{
"path": "reftests/declaration-1847.c",
"chars": 2490,
"preview": "#pragma gnu\ntypedef struct {\nlong long __max_align_ll __attribute__((__aligned__(__alignof__(long long))));\nlong double "
},
{
"path": "reftests/declaration-2243.c",
"chars": 518,
"preview": "#pragma gnu\n_Float64 foo = 1.5;\n\n/*===\nDeclaration\n DeclarationSpecifier\n TypeSpecifier\n TS18661Flo"
},
{
"path": "reftests/declaration-2321.c",
"chars": 923,
"preview": "// This is the first Clang-specific declaration you'll encounter in macOS\n// if you #include <stdio.h>.\n\n#pragma gnu\n#pr"
},
{
"path": "reftests/declaration-2429.c",
"chars": 439,
"preview": "#pragma gnu\n#pragma clang\nint f __attribute__((availability(p1,introduced=1.2.3))) __attribute__((availability(p2,unavai"
},
{
"path": "reftests/declaration-2477.c",
"chars": 284,
"preview": "#pragma gnu\nstruct foo S;\n\n/*===\nDeclaration\n DeclarationSpecifier\n TypeSpecifier\n StructType\n "
},
{
"path": "reftests/declaration-2508.c",
"chars": 38,
"preview": "struct foo { } S;\n\n/*===\n~ERROR\n===*/\n"
},
{
"path": "reftests/declaration-2512.c",
"chars": 288,
"preview": "#pragma gnu\nstruct foo { } S;\n\n/*===\nDeclaration\n DeclarationSpecifier\n TypeSpecifier\n StructType\n "
},
{
"path": "reftests/declaration-2594.c",
"chars": 321,
"preview": "// #23\n\ntypedef const int foo;\n\n/*===\nDeclaration\n DeclarationSpecifier\n StorageClassSpecifier Typedef\n Dec"
},
{
"path": "reftests/declaration-31-field-semicolon.c",
"chars": 533,
"preview": "#pragma gnu\n\nstruct s {\n int i;;\n};\n\n\n/*===\nDeclaration\n DeclarationSpecifier\n TypeSpecifier\n St"
},
{
"path": "reftests/declaration-31-ty-attr1.c",
"chars": 1358,
"preview": "#pragma gnu\n\n// #31\n\nstruct s {\n struct t {\n int i;\n } __attribute((packed)) v;\n};\n\n/*===\nDeclaration\n D"
},
{
"path": "reftests/declaration-31-ty-attr2.c",
"chars": 1472,
"preview": "#pragma gnu\n\nstruct s {\n union { int i; } __attribute__((aligned(8)));\n};\n\n/*===\nDeclaration\n DeclarationSpecifier"
},
{
"path": "reftests/declaration-31-ty-attr3.c",
"chars": 1114,
"preview": "#pragma gnu\n\nstruct s {\n int __attribute__((aligned(8))) *i;\n};\n\n\n/*===\nDeclaration\n DeclarationSpecifier\n "
},
{
"path": "reftests/declaration-659.c",
"chars": 1025,
"preview": "#pragma gnu\nint typedef * foo, baz[static 10][const *];\n\n#pragma is_typename foo\n#pragma is_typename baz\n/*===\nDeclarati"
},
{
"path": "reftests/declaration-714.c",
"chars": 847,
"preview": "#pragma gnu\ntypedef enum { FOO, BAR = 1 } * const foobar;\n\n#pragma is_typename foobar\n/*===\nDeclaration\n DeclarationS"
},
{
"path": "reftests/declaration-760.c",
"chars": 1116,
"preview": "#pragma gnu\nstruct { int a, b; float c; } S;\n\n/*===\nDeclaration\n DeclarationSpecifier\n TypeSpecifier\n "
},
{
"path": "reftests/declaration-837.c",
"chars": 201,
"preview": "int __restrict__;\n\n/*===\nDeclaration\n DeclarationSpecifier\n TypeSpecifier Int\n InitDeclarator\n Decla"
},
{
"path": "reftests/declaration-855.c",
"chars": 162,
"preview": "#pragma gnu\nint __restrict__;\n\n/*===\nDeclaration\n DeclarationSpecifier\n TypeSpecifier Int\n DeclarationSpeci"
},
{
"path": "reftests/declaration-880.c",
"chars": 2424,
"preview": "#pragma gnu\n#pragma typedef FILE\n#pragma typedef size_t\nchar *fparseln(FILE *, size_t *, size_t *, const char[3], int);\n"
},
{
"path": "reftests/declaration-983.c",
"chars": 1991,
"preview": "#pragma gnu\n#pragma typedef size_t\nextern int strerror_r (int __errnum, char *__buf, size_t __buflen)\n__asm__ (\"\" \"__xp"
},
{
"path": "reftests/declaration-block-2.c",
"chars": 645,
"preview": "#pragma clang\n\nvoid (^ const p)(int);\n\n/*===\nDeclaration\n DeclarationSpecifier\n TypeSpecifier Void\n InitDec"
},
{
"path": "reftests/declaration-block-3.c",
"chars": 3887,
"preview": "#pragma clang\n#pragma typedef size_t\n\nvoid *bsearch_b(const void *__key, const void *__base, size_t __nel,\n size_t _"
},
{
"path": "reftests/declaration-block-4.c",
"chars": 31,
"preview": "int ^none;\n\n/*===\n~ERROR\n===*/\n"
},
{
"path": "reftests/declaration-block-5.c",
"chars": 35,
"preview": "int (^p)(int);\n\n/*===\n~ERROR\n===*/\n"
},
{
"path": "reftests/declaration-block.c",
"chars": 239,
"preview": "#pragma clang\n\nint ^block;\n\n/*===\nDeclaration\n DeclarationSpecifier\n TypeSpecifier Int\n InitDeclarator\n "
},
{
"path": "reftests/declaration-enum-attr.c",
"chars": 1292,
"preview": "#pragma gnu\n\nenum {\n SOME_THING = 0,\n OTHER_THING = 1,\n OLD_THING __attribute__((deprecated)) = 2,\n};\n\n/*===\nDe"
},
{
"path": "reftests/declaration-ptr-attr1.c",
"chars": 777,
"preview": "#pragma gnu\n\nvoid (****f)(void) __attribute__((noreturn));\n\n/*===\nDeclaration\n DeclarationSpecifier\n TypeSpeci"
},
{
"path": "reftests/declaration-ptr-attr2.c",
"chars": 794,
"preview": "#pragma gnu\n\nvoid (__attribute__((noreturn)) ****f) (void);\n\n/*===\nDeclaration\n DeclarationSpecifier\n TypeSpec"
},
{
"path": "reftests/declaration-ptr-attr3.c",
"chars": 720,
"preview": "#pragma gnu\n\nchar *__attribute__((aligned(8))) *f;\n/*===\nDeclaration\n DeclarationSpecifier\n TypeSpecifier Char"
},
{
"path": "reftests/declaration-struct.c",
"chars": 518,
"preview": "struct foo {\nint x;\n};\n\n/*===\nDeclaration\n DeclarationSpecifier\n TypeSpecifier\n StructType\n "
},
{
"path": "reftests/declaration-typedef.c",
"chars": 691,
"preview": "typedef struct foo {\nint x;\n} bar;\n\n/*===\nDeclaration\n DeclarationSpecifier\n StorageClassSpecifier Typedef\n "
},
{
"path": "reftests/expression-1295.c",
"chars": 217,
"preview": "#pragma gnu\n_Alignof(long long)\n\n/*===\nExpression\n AlignOf\n TypeName\n SpecifierQualifier\n "
},
{
"path": "reftests/expression-1307.c",
"chars": 218,
"preview": "#pragma gnu\n__alignof(long long)\n\n/*===\nExpression\n AlignOf\n TypeName\n SpecifierQualifier\n "
},
{
"path": "reftests/expression-1319.c",
"chars": 220,
"preview": "#pragma gnu\n__alignof__(long long)\n\n/*===\nExpression\n AlignOf\n TypeName\n SpecifierQualifier\n "
},
{
"path": "reftests/expression-1338.c",
"chars": 764,
"preview": "#pragma gnu\n({ int p = 0; p; })\n\n/*===\nExpression\n Statement Compound\n BlockItem\n Declaration\n "
},
{
"path": "reftests/expression-1370.c",
"chars": 259,
"preview": "#pragma gnu\n#pragma typedef U64\n(U64)foo\n\n/*===\nExpression\n CastExpression\n TypeName\n SpecifierQual"
},
{
"path": "reftests/expression-1523.c",
"chars": 2110,
"preview": "#pragma gnu\n__builtin_offsetof(struct { struct { int b; } a[2]; }, a->b)\n\n/*===\nExpression\n OffsetOfExpression\n "
},
{
"path": "reftests/expression-1595.c",
"chars": 213,
"preview": "#pragma gnu\nfoo(bar, baz)\n\n/*===\nExpression\n CallExpression\n Expression\n Identifier \"foo\"\n E"
},
{
"path": "reftests/expression-2224.c",
"chars": 71,
"preview": "#pragma gnu\n__func__\n\n/*===\nExpression\n Identifier \"__func__\"\n===*/\n"
},
{
"path": "reftests/expression-2229.c",
"chars": 79,
"preview": "#pragma gnu\n__FUNCTION__\n\n/*===\nExpression\n Identifier \"__FUNCTION__\"\n===*/\n"
},
{
"path": "reftests/expression-2234.c",
"chars": 93,
"preview": "#pragma gnu\n__PRETTY_FUNCTION__\n\n/*===\nExpression\n Identifier \"__PRETTY_FUNCTION__\"\n===*/\n"
},
{
"path": "reftests/expression-2546.c",
"chars": 1230,
"preview": "#pragma gnu\n(struct test_struct) { 1, .x = 2, 3 }\n\n/*===\nExpression\n CompoundLiteral\n TypeName\n Spe"
},
{
"path": "reftests/expression-475.c",
"chars": 72,
"preview": "#pragma gnu\n\"foo\"\n\n/*===\nExpression\n StringLiteral [\"\\\"foo\\\"\"]\n===*/\n"
},
{
"path": "reftests/expression-476.c",
"chars": 77,
"preview": "#pragma gnu\n\"foo\\n\"\n\n/*===\nExpression\n StringLiteral [\"\\\"foo\\\\n\\\"\"]\n===*/\n"
},
{
"path": "reftests/expression-477.c",
"chars": 78,
"preview": "#pragma gnu\n\"\\'\\\"\"\n\n/*===\nExpression\n StringLiteral [\"\\\"\\\\\\'\\\\\\\"\\\"\"]\n===*/\n"
},
{
"path": "reftests/expression-478.c",
"chars": 75,
"preview": "#pragma gnu\n\"\\xaf\"\n\n/*===\nExpression\n StringLiteral [\"\\\"\\\\xaf\\\"\"]\n===*/\n"
},
{
"path": "reftests/expression-491.c",
"chars": 152,
"preview": "#pragma gnu\na ++\n\n/*===\nExpression\n UnaryOperatorExpression\n Expression\n Identifier \"a\"\n Un"
},
{
"path": "reftests/expression-495.c",
"chars": 912,
"preview": "#pragma gnu\na.b->c[ d[ e ] ] ++\n\n/*===\nExpression\n UnaryOperatorExpression\n Expression\n BinaryOpera"
},
{
"path": "reftests/expression-517.c",
"chars": 652,
"preview": "#pragma gnu\na-- * ++b / c\n\n/*===\nExpression\n BinaryOperatorExpression\n Expression\n BinaryOperatorEx"
},
{
"path": "reftests/expression-538.c",
"chars": 198,
"preview": "#pragma gnu\na && b\n\n/*===\nExpression\n BinaryOperatorExpression\n Expression\n Identifier \"a\"\n "
},
{
"path": "reftests/expression-551.c",
"chars": 379,
"preview": "#pragma gnu\na && b && c\n\n/*===\nExpression\n BinaryOperatorExpression\n Expression\n BinaryOperatorExpr"
},
{
"path": "reftests/expression-567.c",
"chars": 377,
"preview": "#pragma gnu\na || b || c\n\n/*===\nExpression\n BinaryOperatorExpression\n Expression\n BinaryOperatorExpr"
},
{
"path": "reftests/expression-583.c",
"chars": 377,
"preview": "#pragma gnu\na << b << c\n\n/*===\nExpression\n BinaryOperatorExpression\n Expression\n BinaryOperatorExpr"
},
{
"path": "reftests/expression-599.c",
"chars": 379,
"preview": "#pragma gnu\na >> b >> c\n\n/*===\nExpression\n BinaryOperatorExpression\n Expression\n BinaryOperatorExpr"
},
{
"path": "reftests/expression-616.c",
"chars": 57,
"preview": "#pragma gnu\na\n\n/*===\nExpression\n Identifier \"a\"\n===*/\n"
},
{
"path": "reftests/expression-617.c",
"chars": 239,
"preview": "#pragma gnu\na, a, a,a\n,a\n\n/*===\nExpression\n Expression\n Identifier \"a\"\n Expression\n Identifier \"a\"\n "
},
{
"path": "reftests/expression-632.c",
"chars": 339,
"preview": "#pragma gnu\n(int) 1\n\n/*===\nExpression\n CastExpression\n TypeName\n SpecifierQualifier\n "
},
{
"path": "reftests/expression-645.c",
"chars": 40,
"preview": "#pragma gnu\n(foo) 1\n\n/*===\n~ERROR\n===*/\n"
},
{
"path": "reftests/expression-ident-const.c",
"chars": 634,
"preview": "uident, Uident, Lident, u8ident,\nu\"str\", U\"str\", L\"str\", u8\"str\",\nu'chr', U'chr', L'chr'\n\n/*===\nExpression\n Expressio"
},
{
"path": "reftests/expression-sizeof.c",
"chars": 1136,
"preview": "#pragma typedef a\nsizeof(a) + sizeof b + sizeof(c*10)\n/*===\nExpression\n BinaryOperatorExpression\n Expression\n "
},
{
"path": "reftests/expression-string-1.c",
"chars": 59,
"preview": "L\"..\"\n/*===\nExpression\n StringLiteral [\"L\\\"..\\\"\"]\n===*/\n"
},
{
"path": "reftests/expression-string-2.c",
"chars": 61,
"preview": "u8\"..\"\n/*===\nExpression\n StringLiteral [\"u8\\\"..\\\"\"]\n===*/\n"
},
{
"path": "reftests/statement-1408.c",
"chars": 447,
"preview": "#pragma gnu\n__asm (\"pmovmskb %1, %0\" : \"=r\" (__m) : \"x\" (__x));\n\n/*===\nStatement\n AsmStatement\n GnuExtendedAsm"
},
{
"path": "reftests/statement-1650.c",
"chars": 416,
"preview": "#pragma gnu\nif (x) do {} while(y); else z();\n\n/*===\nStatement\n IfStatement\n Expression\n Identifier "
},
{
"path": "reftests/statement-2625.c",
"chars": 1331,
"preview": "// #27\n#pragma gnu\n#pragma typedef test_t\nreturn (test_t) { 1, .x = 2, 3 };\n\n/*===\nStatement Return\n Expression\n "
},
{
"path": "reftests/statement-2669.c",
"chars": 716,
"preview": "// #27 - make sure expressions starting with a type name in parens still work\n#pragma gnu\n#pragma typedef test_t\nreturn "
},
{
"path": "reftests/statement-case.c",
"chars": 303,
"preview": "case 1: ;\n/*===\nStatement\n LabeledStatement\n Label\n Expression\n Constant\n "
},
{
"path": "reftests/statement-case2.c",
"chars": 723,
"preview": "case 1+2: ;\n/*===\nStatement\n LabeledStatement\n Label\n Expression\n BinaryOperatorExpr"
},
{
"path": "reftests/statement-caserange.c",
"chars": 35,
"preview": "case 1 ... 2: ;\n/*===\n~ERROR\n===*/\n"
},
{
"path": "reftests/statement-caserange2.c",
"chars": 609,
"preview": "#pragma gnu\ncase 1 ... 2: ;\n/*===\nStatement\n LabeledStatement\n Label\n CaseRange\n Exp"
},
{
"path": "reftests/statement-caserange3.c",
"chars": 266,
"preview": "#pragma gnu\ncase 'a'...'z':;\n/*===\nStatement\n LabeledStatement\n Label\n CaseRange\n Ex"
},
{
"path": "reftests/statement-caserange4.c",
"chars": 1612,
"preview": "#pragma gnu\nswitch(num) {\n for(;;) {\n\tcase 1 ... 10:\n\treturn;\n\tbreak;\n }\n}\n/*===\nStatement\n SwitchStatement\n "
},
{
"path": "reftests/statement-caserange5.c",
"chars": 45,
"preview": "#pragma gnu\ncase 1...3:;\n\n/*===\n~ERROR\n===*/\n"
},
{
"path": "reftests/statement-default.c",
"chars": 93,
"preview": "default:;\n/*===\nStatement\n LabeledStatement\n Label Default\n Statement\n===*/\n"
},
{
"path": "reftests/statement-label.c",
"chars": 121,
"preview": "foo: {}\n/*===\nStatement\n LabeledStatement\n Label\n Identifier \"foo\"\n Statement Compound\n===*/"
},
{
"path": "reftests/translation_unit-1183.c",
"chars": 2401,
"preview": "#pragma gnu\nextern __inline __attribute__ ((__always_inline__)) __attribute__\n((__artificial__)) __attribute__ ((__warn_"
},
{
"path": "reftests/translation_unit-1388.c",
"chars": 192,
"preview": "#pragma gnu\n# 1 \"<stdin>\"\n# 1 \"<built-in>\"\n# 1 \"<command-line>\"\n# 31 \"<command-line>\"\n# 1 \"/usr/include/stdc-predef.h\" 1"
},
{
"path": "reftests/translation_unit-1692.c",
"chars": 2107,
"preview": "// Check that a typedef that can be mistaken for a K&R-style argument declaration is correctly\n// parsed as an external "
},
{
"path": "reftests/translation_unit-1781.c",
"chars": 1205,
"preview": "#pragma gnu\nint foo(int a __attribute__((unused)), int b __attribute__((unused))) {}\n\n/*===\nTranslationUnit\n External"
},
{
"path": "reftests/translation_unit-1961.c",
"chars": 1006,
"preview": "#pragma gnu\n\ntypedef int a;\nint foo() {\nint a;\n}\n\n/*===\nTranslationUnit\n ExternalDeclaration\n Declaration\n "
},
{
"path": "reftests/translation_unit-1993.c",
"chars": 2605,
"preview": "#pragma gnu\n\ntypedef int a;\nvoid foo() {\nunsigned int;\nconst a;\na x;\nunsigned a;\na = 1;\n}\n\n/*===\nTranslationUnit\n Ext"
},
{
"path": "reftests/translation_unit-2015.c",
"chars": 165,
"preview": "// If parameter list treated \"a\" as a type specifier instead of identifier, this would succeed.\n#pragma gnu\n\ntypedef int"
},
{
"path": "reftests/translation_unit-2029.c",
"chars": 1381,
"preview": "// If struct field treated \"a\" as a type specifier instead of identifier, this would succeed.\n\n#pragma gnu\n\ntypedef int "
},
{
"path": "reftests/translation_unit-2045.c",
"chars": 1576,
"preview": "// Struct fields maintain a separate\n\n#pragma gnu\n\ntypedef int a;\nstruct a { a a; a b; };\n\n/*===\nTranslationUnit\n Ext"
},
{
"path": "reftests/translation_unit-2060.c",
"chars": 83,
"preview": "#pragma gnu\n\ntypedef int a;\nvoid foo() {\na a;\n_Atomic (a) b;\n}\n\n/*===\n~ERROR\n===*/\n"
},
{
"path": "reftests/translation_unit-2070.c",
"chars": 82,
"preview": "#pragma gnu\n\ntypedef int a;\nvoid foo(int a, _Atomic (a) b) {}\n\n/*===\n~ERROR\n===*/\n"
},
{
"path": "reftests/translation_unit-2086.c",
"chars": 187,
"preview": "// Technically, \"a\" is defined as a symbol before the \"= ..\" part of the initializer is parsed.\n\n#pragma gnu\n\ntypedef in"
},
{
"path": "reftests/translation_unit-2103.c",
"chars": 195,
"preview": "// enum {a} defines a new variable \"a\" into the current scope. So the next _Atomic(a) must fail.\n\n#pragma gnu\n\ntypedef i"
},
{
"path": "reftests/translation_unit-2114.c",
"chars": 190,
"preview": "// enum {a} defines a new variable \"a\" into the current scope immediately after its declaration.\n#pragma gnu\n\ntypedef in"
},
{
"path": "reftests/translation_unit-2129.c",
"chars": 2198,
"preview": "#pragma gnu\n\ntypedef int a;\nint foo(a a) {}\nint bar(int a);\n_Atomic (a) b;\n\n\n/*===\nTranslationUnit\n ExternalDeclarati"
},
{
"path": "reftests/translation_unit-2147.c",
"chars": 1876,
"preview": "#pragma gnu\n\nvoid foo() {\ntypedef int a;\n{\na a;\n}\n_Atomic (a) b;\n}\n\n/*===\nTranslationUnit\n ExternalDeclaration\n "
},
{
"path": "reftests/translation_unit-2167.c",
"chars": 3688,
"preview": "#pragma gnu\n\ntypedef int a;\nvoid foo() {\nfor (a a;;)\na = a;\nwhile (true) {int a;}\ndo { int a; } while(true);\n_Atomic (a)"
},
{
"path": "reftests/translation_unit-2190.c",
"chars": 5080,
"preview": "// Test that scope of \"if\" condition and statement is cleaned up.\n#pragma gnu\n\ntypedef int a, b;\nint x;\nvoid foo() {\nif "
},
{
"path": "reftests/translation_unit-2208.c",
"chars": 185,
"preview": "// Test that \"if\" condition enum constants are defined within its scope.\n\n#pragma gnu\n\ntypedef int a;\nvoid foo() {\nint x"
},
{
"path": "reftests/translation_unit-2270.c",
"chars": 651,
"preview": "#pragma gnu\n__extension__ union { long l; };\n\n/*===\nTranslationUnit\n ExternalDeclaration\n Declaration\n "
},
{
"path": "reftests/translation_unit-2300.c",
"chars": 381,
"preview": "#pragma gnu\n__extension__ _Static_assert(1,\"ERR\");\n\n/*===\nTranslationUnit\n ExternalDeclaration\n StaticAssert\n "
},
{
"path": "reftests/translation_unit-2373.c",
"chars": 1044,
"preview": "#pragma gnu\nint main(argc, argv) int argc; char **argv; { }\n\n/*===\nTranslationUnit\n ExternalDeclaration\n Funct"
},
{
"path": "reftests/translation_unit-31-semicolon.c",
"chars": 556,
"preview": "#pragma gnu\n\nvoid f(void) {\n};\n\n\n/*===\nTranslationUnit\n ExternalDeclaration\n FunctionDefinition\n De"
},
{
"path": "src/ast.rs",
"chars": 31709,
"preview": "//! Abstract syntax tree\n//!\n//! Types in this module represent various pieces a C program can\n//! contain after preproc"
},
{
"path": "src/astutil.rs",
"chars": 3776,
"preview": "use ast::*;\nuse span::{Node, Span};\n\n#[cfg_attr(test, derive(Debug, PartialEq, Clone))]\npub enum Operation {\n Member("
},
{
"path": "src/bin/dump.rs",
"chars": 1530,
"preview": "//! Parse a C file and dump the AST.\n\nextern crate lang_c;\n\nuse std::process::exit;\n\nuse lang_c::driver::{Config, Flavor"
},
{
"path": "src/bin/meminfo.rs",
"chars": 1251,
"preview": "extern crate lang_c;\nuse lang_c::ast::*;\nuse std::mem::size_of;\n\nmacro_rules! ps {\n ($( $i:ident )+) => ({ $(println!"
},
{
"path": "src/driver.rs",
"chars": 5718,
"preview": "//! Preprocess and parse C source file into an abstract syntax tree\n\nuse std::collections::HashSet;\nuse std::error;\nuse "
},
{
"path": "src/env.rs",
"chars": 2991,
"preview": "use std::collections::{HashMap, HashSet};\n\nuse ast::*;\nuse span::Node;\nuse strings;\n\n#[derive(Clone, Copy, Debug, Partia"
},
{
"path": "src/lib.rs",
"chars": 457,
"preview": "//! C language parser and abstract syntax tree\n//!\n//! ```\n//! use lang_c::driver::{Config, parse};\n//!\n//! fn main() {\n"
},
{
"path": "src/loc.rs",
"chars": 4341,
"preview": "//! Convert byte offsets into line numbers\nconst F_NEW: u32 = 1;\nconst F_RET: u32 = 2;\n\n#[derive(Debug, Clone, Copy, Par"
},
{
"path": "src/parser.rs",
"chars": 1024915,
"preview": "#![cfg_attr(rustfmt, rustfmt_skip)]\n#![allow(unknown_lints)]\n#![allow(ellipsis_inclusive_range_patterns)]\n// Generated b"
},
{
"path": "src/print.rs",
"chars": 26853,
"preview": "#![allow(unknown_lints)]\n#![allow(bare_trait_objects)]\n\n//! Debug printer for abstract syntax tree\n//!\n//! ```no_run\n//!"
},
{
"path": "src/span.rs",
"chars": 1453,
"preview": "//! Source text location tracking\nuse std::usize::MAX;\nuse std::{cmp, fmt};\n\n/// Byte offset of a node start and end pos"
},
{
"path": "src/strings.rs",
"chars": 2057,
"preview": "pub const RESERVED_C11: &'static [&'static str] = &[\n \"auto\",\n \"break\",\n \"case\",\n \"char\",\n \"const\",\n \""
},
{
"path": "src/tests.rs",
"chars": 9683,
"preview": "use std::env;\nuse std::ffi::{OsStr, OsString};\nuse std::fs;\nuse std::fs::DirEntry;\nuse std::fs::File;\nuse std::io;\nuse s"
},
{
"path": "src/visit.rs",
"chars": 51597,
"preview": "//! Recursive abstract syntax tree traversal\n//!\n//! ```rust\n//! # use lang_c::{ast, span, visit};\n//! struct ExprCount("
}
]
About this extraction
This page contains the full source code of the vickenty/lang-c GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 164 files (1.2 MB), approximately 210.5k tokens, and a symbol index with 726 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.