mirror of https://github.com/Wilfred/difftastic/
Add 'vendored_parsers/tree-sitter-devicetree/' from commit '2087a5b965db2a9efabab958a27fd8ddf43038a2'
git-subtree-dir: vendored_parsers/tree-sitter-devicetree git-subtree-mainline:pull/642/head1b2099d7a4git-subtree-split:2087a5b965
commit
dee4c9bdbc
@ -0,0 +1,6 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*.js]
|
||||||
|
charset = utf-8
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 4
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"env": {
|
||||||
|
"commonjs": true,
|
||||||
|
"es2021": true
|
||||||
|
},
|
||||||
|
"extends": ["eslint:recommended", "prettier"],
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": "latest",
|
||||||
|
"sourceType": "module"
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
"no-undef": "off",
|
||||||
|
"no-unused-vars": ["error", { "args": "none" }]
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
* text=auto
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
name: CI
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- '**'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: true
|
||||||
|
matrix:
|
||||||
|
os: [macos-latest, ubuntu-latest, windows-latest]
|
||||||
|
node-version: [lts/*]
|
||||||
|
steps:
|
||||||
|
# https://github.com/nodejs/node-gyp/issues/2869
|
||||||
|
- name: Install distutils
|
||||||
|
run: python3 -m pip install setuptools
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
- run: npm install
|
||||||
|
- run: npm test
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
name: Lint
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- '**'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Install modules
|
||||||
|
run: npm install
|
||||||
|
- name: Run Prettier
|
||||||
|
run: npm run prettier:check
|
||||||
|
- name: Run ESLint
|
||||||
|
run: npm run lint
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
node-version: [lts/*]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
|
||||||
|
- run: npm ci
|
||||||
|
|
||||||
|
- name: build
|
||||||
|
run: npm run build:wasm
|
||||||
|
|
||||||
|
- name: release
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
|
with:
|
||||||
|
fail_on_unmatched_files: true
|
||||||
|
generate_release_notes: true
|
||||||
|
files: |
|
||||||
|
*.wasm
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
build
|
||||||
|
node_modules
|
||||||
|
target
|
||||||
|
|
||||||
|
Cargo.lock
|
||||||
|
parser.exp
|
||||||
|
parser.lib
|
||||||
|
parser.obj
|
||||||
|
*.log
|
||||||
|
*.html
|
||||||
|
*.wasm
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
/build
|
||||||
|
/examples
|
||||||
|
/test
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
# Generated files
|
||||||
|
bindings
|
||||||
|
src
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"trailingComma": "es5",
|
||||||
|
"tabWidth": 4,
|
||||||
|
"semi": true,
|
||||||
|
"singleQuote": true,
|
||||||
|
"endOfLine": "auto",
|
||||||
|
"overrides": [
|
||||||
|
{
|
||||||
|
"files": ["*.json", "*.yml", "*.yaml"],
|
||||||
|
"options": {
|
||||||
|
"tabWidth": 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"recommendations": ["esbenp.prettier-vscode"]
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"[javascript]": {
|
||||||
|
"editor.formatOnSave": true,
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[json][jsonc]": {
|
||||||
|
"editor.formatOnSave": true,
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[markdown]": {
|
||||||
|
"editor.formatOnSave": true,
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[yml][github-actions-workflow]": {
|
||||||
|
"editor.formatOnSave": true,
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"type": "npm",
|
||||||
|
"script": "build",
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
|
},
|
||||||
|
"problemMatcher": [],
|
||||||
|
"label": "npm: build",
|
||||||
|
"detail": "tree-sitter generate"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## v0.8.0
|
||||||
|
|
||||||
|
- Added `name` property to `/delete-node/` and `/delete-property/`.
|
||||||
|
- Added support for preprocessor commands inside nodes.
|
||||||
|
|
||||||
|
## v0.7.1
|
||||||
|
|
||||||
|
- Updated to tree-sitter v0.20.8.
|
||||||
|
|
||||||
|
## v0.6.0
|
||||||
|
|
||||||
|
- Updated to tree-sitter v0.20.7
|
||||||
|
- `property` node's `value` field no longer includes the `=` token.
|
||||||
|
- Added support for more devicetree features:
|
||||||
|
- `/plugin/`
|
||||||
|
- `/omit-if-no-ref/`
|
||||||
|
- `/bits/`
|
||||||
|
- `/incbin/`
|
||||||
|
|
||||||
|
## v0.5.0
|
||||||
|
|
||||||
|
- Updated to tree-sitter v0.20.6
|
||||||
|
|
||||||
|
## v0.4.0
|
||||||
|
|
||||||
|
- Updated to tree-sitter v0.19.4
|
||||||
|
|
||||||
|
## v0.3.0
|
||||||
|
|
||||||
|
- Fixed commas not being allowed in node addresses.
|
||||||
|
|
||||||
|
## v0.2.0
|
||||||
|
|
||||||
|
- Fixed references not being allowed as node names.
|
||||||
|
|
||||||
|
## v0.1.0
|
||||||
|
|
||||||
|
- Initial release
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
[package]
|
||||||
|
name = "tree-sitter-devicetree"
|
||||||
|
description = "devicetree grammar for the tree-sitter parsing library"
|
||||||
|
version = "0.4.0"
|
||||||
|
keywords = ["incremental", "parsing", "devicetree"]
|
||||||
|
categories = ["parsing", "text-editors"]
|
||||||
|
repository = "https://github.com/joelspadin/tree-sitter-devicetree"
|
||||||
|
edition = "2018"
|
||||||
|
license = "MIT"
|
||||||
|
|
||||||
|
build = "bindings/rust/build.rs"
|
||||||
|
include = [
|
||||||
|
"bindings/rust/*",
|
||||||
|
"grammar.js",
|
||||||
|
"queries/*",
|
||||||
|
"src/*",
|
||||||
|
]
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "bindings/rust/lib.rs"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
tree-sitter = ">= 0.19, < 0.21"
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
cc = "1.0"
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2020 Joel Spadin
|
||||||
|
|
||||||
|
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.
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
# tree-sitter-devicetree
|
||||||
|
|
||||||
|
A [tree-sitter](https://github.com/tree-sitter/tree-sitter) grammar for Devicetree
|
||||||
|
with support for [Zephyr's](https://github.com/zephyrproject-rtos/zephyr)
|
||||||
|
superset of Devicetree syntax.
|
||||||
|
|
||||||
|
Some parts of the grammar are adapted from [tree-sitter-c](https://github.com/tree-sitter/tree-sitter-c).
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"target_name": "tree_sitter_devicetree_binding",
|
||||||
|
"include_dirs": [
|
||||||
|
"<!(node -e \"require('nan')\")",
|
||||||
|
"src"
|
||||||
|
],
|
||||||
|
"sources": [
|
||||||
|
"src/parser.c",
|
||||||
|
"bindings/node/binding.cc"
|
||||||
|
],
|
||||||
|
"cflags_c": [
|
||||||
|
"-std=c99",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
#include "tree_sitter/parser.h"
|
||||||
|
#include <node.h>
|
||||||
|
#include "nan.h"
|
||||||
|
|
||||||
|
using namespace v8;
|
||||||
|
|
||||||
|
extern "C" TSLanguage * tree_sitter_devicetree();
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
NAN_METHOD(New) {}
|
||||||
|
|
||||||
|
void Init(Local<Object> exports, Local<Object> module) {
|
||||||
|
Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
|
||||||
|
tpl->SetClassName(Nan::New("Language").ToLocalChecked());
|
||||||
|
tpl->InstanceTemplate()->SetInternalFieldCount(1);
|
||||||
|
|
||||||
|
Local<Function> constructor = Nan::GetFunction(tpl).ToLocalChecked();
|
||||||
|
Local<Object> instance = constructor->NewInstance(Nan::GetCurrentContext()).ToLocalChecked();
|
||||||
|
Nan::SetInternalFieldPointer(instance, 0, tree_sitter_devicetree());
|
||||||
|
|
||||||
|
Nan::Set(instance, Nan::New("name").ToLocalChecked(), Nan::New("devicetree").ToLocalChecked());
|
||||||
|
Nan::Set(module, Nan::New("exports").ToLocalChecked(), instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
NODE_MODULE(tree_sitter_devicetree_binding, Init)
|
||||||
|
|
||||||
|
} // namespace
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
try {
|
||||||
|
module.exports = require("../../build/Release/tree_sitter_devicetree_binding");
|
||||||
|
} catch (error1) {
|
||||||
|
if (error1.code !== 'MODULE_NOT_FOUND') {
|
||||||
|
throw error1;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
module.exports = require("../../build/Debug/tree_sitter_devicetree_binding");
|
||||||
|
} catch (error2) {
|
||||||
|
if (error2.code !== 'MODULE_NOT_FOUND') {
|
||||||
|
throw error2;
|
||||||
|
}
|
||||||
|
throw error1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
module.exports.nodeTypeInfo = require("../../src/node-types.json");
|
||||||
|
} catch (_) {}
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
fn main() {
|
||||||
|
let src_dir = std::path::Path::new("src");
|
||||||
|
|
||||||
|
let mut c_config = cc::Build::new();
|
||||||
|
c_config.include(&src_dir);
|
||||||
|
c_config
|
||||||
|
.flag_if_supported("-Wno-unused-parameter")
|
||||||
|
.flag_if_supported("-Wno-unused-but-set-variable")
|
||||||
|
.flag_if_supported("-Wno-trigraphs");
|
||||||
|
let parser_path = src_dir.join("parser.c");
|
||||||
|
c_config.file(&parser_path);
|
||||||
|
|
||||||
|
// If your language uses an external scanner written in C,
|
||||||
|
// then include this block of code:
|
||||||
|
|
||||||
|
/*
|
||||||
|
let scanner_path = src_dir.join("scanner.c");
|
||||||
|
c_config.file(&scanner_path);
|
||||||
|
println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap());
|
||||||
|
*/
|
||||||
|
|
||||||
|
c_config.compile("parser");
|
||||||
|
println!("cargo:rerun-if-changed={}", parser_path.to_str().unwrap());
|
||||||
|
|
||||||
|
// If your language uses an external scanner written in C++,
|
||||||
|
// then include this block of code:
|
||||||
|
|
||||||
|
/*
|
||||||
|
let mut cpp_config = cc::Build::new();
|
||||||
|
cpp_config.cpp(true);
|
||||||
|
cpp_config.include(&src_dir);
|
||||||
|
cpp_config
|
||||||
|
.flag_if_supported("-Wno-unused-parameter")
|
||||||
|
.flag_if_supported("-Wno-unused-but-set-variable");
|
||||||
|
let scanner_path = src_dir.join("scanner.cc");
|
||||||
|
cpp_config.file(&scanner_path);
|
||||||
|
cpp_config.compile("scanner");
|
||||||
|
println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap());
|
||||||
|
*/
|
||||||
|
}
|
||||||
@ -0,0 +1,52 @@
|
|||||||
|
//! This crate provides devicetree language support for the [tree-sitter][] parsing library.
|
||||||
|
//!
|
||||||
|
//! Typically, you will use the [language][language func] function to add this language to a
|
||||||
|
//! tree-sitter [Parser][], and then use the parser to parse some code:
|
||||||
|
//!
|
||||||
|
//! ```
|
||||||
|
//! let code = "";
|
||||||
|
//! let mut parser = tree_sitter::Parser::new();
|
||||||
|
//! parser.set_language(tree_sitter_devicetree::language()).expect("Error loading devicetree grammar");
|
||||||
|
//! let tree = parser.parse(code, None).unwrap();
|
||||||
|
//! ```
|
||||||
|
//!
|
||||||
|
//! [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html
|
||||||
|
//! [language func]: fn.language.html
|
||||||
|
//! [Parser]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Parser.html
|
||||||
|
//! [tree-sitter]: https://tree-sitter.github.io/
|
||||||
|
|
||||||
|
use tree_sitter::Language;
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
fn tree_sitter_devicetree() -> Language;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get the tree-sitter [Language][] for this grammar.
|
||||||
|
///
|
||||||
|
/// [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html
|
||||||
|
pub fn language() -> Language {
|
||||||
|
unsafe { tree_sitter_devicetree() }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The content of the [`node-types.json`][] file for this grammar.
|
||||||
|
///
|
||||||
|
/// [`node-types.json`]: https://tree-sitter.github.io/tree-sitter/using-parsers#static-node-types
|
||||||
|
pub const NODE_TYPES: &'static str = include_str!("../../src/node-types.json");
|
||||||
|
|
||||||
|
// Uncomment these to include any queries that this grammar contains
|
||||||
|
|
||||||
|
// pub const HIGHLIGHTS_QUERY: &'static str = include_str!("../../queries/highlights.scm");
|
||||||
|
// pub const INJECTIONS_QUERY: &'static str = include_str!("../../queries/injections.scm");
|
||||||
|
// pub const LOCALS_QUERY: &'static str = include_str!("../../queries/locals.scm");
|
||||||
|
// pub const TAGS_QUERY: &'static str = include_str!("../../queries/tags.scm");
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
#[test]
|
||||||
|
fn test_can_load_grammar() {
|
||||||
|
let mut parser = tree_sitter::Parser::new();
|
||||||
|
parser
|
||||||
|
.set_language(super::language())
|
||||||
|
.expect("Error loading devicetree language");
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,592 @@
|
|||||||
|
/**
|
||||||
|
* Based in part on:
|
||||||
|
*
|
||||||
|
* https://github.com/tree-sitter/tree-sitter-c
|
||||||
|
* MIT license, Copyright (c) 2014 Max Brunsfeld
|
||||||
|
*
|
||||||
|
* https://github.com/zephyrproject-rtos/python-devicetree/tree/main
|
||||||
|
* BSD 3-Clause license, Copyright (c) 2019, Nordic Semiconductor
|
||||||
|
*/
|
||||||
|
|
||||||
|
/// <reference types="tree-sitter-cli/dsl" />
|
||||||
|
// @ts-check
|
||||||
|
|
||||||
|
const PREC = {
|
||||||
|
PAREN_DECLARATOR: -10,
|
||||||
|
ASSIGNMENT: -1,
|
||||||
|
CONDITIONAL: -2,
|
||||||
|
DEFAULT: 0,
|
||||||
|
LOGICAL_OR: 1,
|
||||||
|
LOGICAL_AND: 2,
|
||||||
|
INCLUSIVE_OR: 3,
|
||||||
|
EXCLUSIVE_OR: 4,
|
||||||
|
BITWISE_AND: 5,
|
||||||
|
EQUAL: 6,
|
||||||
|
RELATIONAL: 7,
|
||||||
|
SIZEOF: 8,
|
||||||
|
SHIFT: 9,
|
||||||
|
ADD: 10,
|
||||||
|
MULTIPLY: 11,
|
||||||
|
CAST: 12,
|
||||||
|
UNARY: 13,
|
||||||
|
CALL: 14,
|
||||||
|
FIELD: 15,
|
||||||
|
SUBSCRIPT: 16,
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = grammar({
|
||||||
|
name: 'devicetree',
|
||||||
|
|
||||||
|
extras: ($) => [/\s|\\\r?\n/, $.comment],
|
||||||
|
|
||||||
|
inline: ($) => [
|
||||||
|
$.node_identifier,
|
||||||
|
$.label_identifier,
|
||||||
|
$.property_identifier,
|
||||||
|
$.parenthesized_expression,
|
||||||
|
],
|
||||||
|
|
||||||
|
rules: {
|
||||||
|
document: ($) => repeat($._top_level_item),
|
||||||
|
|
||||||
|
_top_level_item: ($) =>
|
||||||
|
choice(
|
||||||
|
$.file_version,
|
||||||
|
$.plugin,
|
||||||
|
$.memory_reservation,
|
||||||
|
$.omit_if_no_ref,
|
||||||
|
$.node,
|
||||||
|
$.dtsi_include,
|
||||||
|
$.preproc_include,
|
||||||
|
$.preproc_def,
|
||||||
|
$.preproc_function_def,
|
||||||
|
$.preproc_if,
|
||||||
|
$.preproc_ifdef,
|
||||||
|
$.preproc_undef
|
||||||
|
),
|
||||||
|
|
||||||
|
_label: ($) => seq(field('label', $.label_identifier), ':'),
|
||||||
|
|
||||||
|
file_version: ($) => seq('/dts-v1/', ';'),
|
||||||
|
plugin: ($) => seq('/plugin/', ';'),
|
||||||
|
|
||||||
|
memory_reservation: ($) =>
|
||||||
|
seq(
|
||||||
|
repeat($._label),
|
||||||
|
'/memreserve/',
|
||||||
|
field('address', $.integer_literal),
|
||||||
|
field('length', $.integer_literal),
|
||||||
|
';'
|
||||||
|
),
|
||||||
|
|
||||||
|
// http://stackoverflow.com/questions/13014947/regex-to-match-a-c-style-multiline-comment/36328890#36328890
|
||||||
|
comment: ($) =>
|
||||||
|
token(
|
||||||
|
choice(
|
||||||
|
seq('//', /(\\(.|\r?\n)|[^\\\n])*/),
|
||||||
|
seq('/*', /[^*]*\*+([^/*][^*]*\*+)*/, '/')
|
||||||
|
)
|
||||||
|
),
|
||||||
|
|
||||||
|
_label_name: ($) => /[a-zA-Z_][0-9a-zA-Z_]*/,
|
||||||
|
_node_path: ($) => /\/[0-9a-zA-Z/,._+-]*/,
|
||||||
|
_node_or_property: ($) => /[a-zA-Z][0-9a-zA-Z,._+-]*/,
|
||||||
|
_property_with_hash: ($) => /[#0-9a-zA-Z,._+-]*#[#0-9a-zA-Z,._+-]*/,
|
||||||
|
_property_starts_with_number: ($) => /[0-9][#0-9a-zA-Z,._+-]*/,
|
||||||
|
|
||||||
|
unit_address: ($) => /[0-9a-zA-Z,._+-]+/,
|
||||||
|
|
||||||
|
label_identifier: ($) => alias($._label_name, $.identifier),
|
||||||
|
|
||||||
|
node_identifier: ($) =>
|
||||||
|
alias(
|
||||||
|
choice($._node_or_property, $._node_path, $._label_name),
|
||||||
|
$.identifier
|
||||||
|
),
|
||||||
|
|
||||||
|
property_identifier: ($) =>
|
||||||
|
alias(
|
||||||
|
choice(
|
||||||
|
$._node_or_property,
|
||||||
|
$._property_with_hash,
|
||||||
|
$._property_starts_with_number,
|
||||||
|
$._label_name
|
||||||
|
),
|
||||||
|
$.identifier
|
||||||
|
),
|
||||||
|
|
||||||
|
reference: ($) => choice($._label_reference, $._node_reference),
|
||||||
|
|
||||||
|
_label_reference: ($) => seq('&', field('label', $.label_identifier)),
|
||||||
|
|
||||||
|
_node_reference: ($) =>
|
||||||
|
seq(
|
||||||
|
'&{',
|
||||||
|
field('path', $.node_identifier),
|
||||||
|
field('address', optional(seq('@', $.unit_address))),
|
||||||
|
'}'
|
||||||
|
),
|
||||||
|
|
||||||
|
omit_if_no_ref: ($) =>
|
||||||
|
seq('/omit-if-no-ref/', choice($.node, seq($.reference, ';'))),
|
||||||
|
|
||||||
|
node: ($) =>
|
||||||
|
seq(
|
||||||
|
repeat($._label),
|
||||||
|
choice(
|
||||||
|
field('name', $.reference),
|
||||||
|
seq(
|
||||||
|
field('name', $.node_identifier),
|
||||||
|
field('address', optional(seq('@', $.unit_address)))
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'{',
|
||||||
|
repeat($._node_members),
|
||||||
|
'}',
|
||||||
|
';'
|
||||||
|
),
|
||||||
|
|
||||||
|
_bits: ($) => seq('/bits/', $.integer_literal),
|
||||||
|
|
||||||
|
property: ($) =>
|
||||||
|
seq(
|
||||||
|
repeat($._label),
|
||||||
|
field('name', $.property_identifier),
|
||||||
|
optional(
|
||||||
|
seq(
|
||||||
|
'=',
|
||||||
|
field('bits', optional($._bits)),
|
||||||
|
field('value', commaSep($._property_value))
|
||||||
|
)
|
||||||
|
),
|
||||||
|
';'
|
||||||
|
),
|
||||||
|
|
||||||
|
_node_members: ($) =>
|
||||||
|
choice(
|
||||||
|
$.delete_property,
|
||||||
|
$.delete_node,
|
||||||
|
$.omit_if_no_ref,
|
||||||
|
$.node,
|
||||||
|
$.property,
|
||||||
|
$.preproc_include,
|
||||||
|
$.preproc_def,
|
||||||
|
$.preproc_function_def,
|
||||||
|
alias($.preproc_if_in_node, $.preproc_if),
|
||||||
|
alias($.preproc_ifdef_in_node, $.preproc_ifdef),
|
||||||
|
$.preproc_undef
|
||||||
|
),
|
||||||
|
|
||||||
|
// TODO: is delete-node allowed at top level?
|
||||||
|
delete_node: ($) =>
|
||||||
|
seq(
|
||||||
|
'/delete-node/',
|
||||||
|
field('name', choice($.node_identifier, $.reference)),
|
||||||
|
';'
|
||||||
|
),
|
||||||
|
|
||||||
|
delete_property: ($) =>
|
||||||
|
seq('/delete-property/', field('name', $.property_identifier), ';'),
|
||||||
|
|
||||||
|
incbin: ($) =>
|
||||||
|
seq(
|
||||||
|
'/incbin/',
|
||||||
|
'(',
|
||||||
|
field('filename', $.string_literal),
|
||||||
|
optional(
|
||||||
|
seq(
|
||||||
|
',',
|
||||||
|
field('offset', $._integer_cell_items),
|
||||||
|
',',
|
||||||
|
field('size', $._integer_cell_items)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
')'
|
||||||
|
),
|
||||||
|
|
||||||
|
// TODO: labels can appear before or after any component of a property value,
|
||||||
|
// or between cells of a cell array, or between bytes of a bytestring.
|
||||||
|
_property_value: ($) =>
|
||||||
|
choice(
|
||||||
|
$.integer_cells,
|
||||||
|
$.string_literal,
|
||||||
|
$.byte_string_literal,
|
||||||
|
$.reference,
|
||||||
|
$.incbin
|
||||||
|
),
|
||||||
|
|
||||||
|
integer_cells: ($) => seq('<', repeat($._integer_cell_items), '>'),
|
||||||
|
|
||||||
|
_integer_cell_items: ($) =>
|
||||||
|
choice(
|
||||||
|
$.integer_literal,
|
||||||
|
$.reference,
|
||||||
|
$.parenthesized_expression,
|
||||||
|
$.identifier,
|
||||||
|
$.call_expression
|
||||||
|
),
|
||||||
|
|
||||||
|
string_literal: ($) =>
|
||||||
|
seq(
|
||||||
|
'"',
|
||||||
|
repeat(
|
||||||
|
choice(
|
||||||
|
token.immediate(prec(1, /[^\\"\n]+/)),
|
||||||
|
$.escape_sequence
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'"'
|
||||||
|
),
|
||||||
|
|
||||||
|
escape_sequence: ($) =>
|
||||||
|
token(
|
||||||
|
prec(
|
||||||
|
1,
|
||||||
|
seq(
|
||||||
|
'\\',
|
||||||
|
choice(
|
||||||
|
/[^xuU]/,
|
||||||
|
/\d{2,3}/,
|
||||||
|
/x[0-9a-fA-F]{2,}/,
|
||||||
|
/u[0-9a-fA-F]{4}/,
|
||||||
|
/U[0-9a-fA-F]{8}/
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
|
||||||
|
system_lib_string: ($) =>
|
||||||
|
token(seq('<', repeat(choice(/[^>\n]/, '\\>')), '>')),
|
||||||
|
|
||||||
|
byte_string_literal: ($) => seq('[', repeat($._byte_string_item), ']'),
|
||||||
|
|
||||||
|
_byte_string_item: ($) => /[0-9a-fA-F]+/,
|
||||||
|
|
||||||
|
integer_literal: ($) => {
|
||||||
|
const separator = "'";
|
||||||
|
const hex = /[0-9a-fA-F]/;
|
||||||
|
const decimal = /[0-9]/;
|
||||||
|
const hexDigits = seq(
|
||||||
|
repeat1(hex),
|
||||||
|
repeat(seq(separator, repeat1(hex)))
|
||||||
|
);
|
||||||
|
const decimalDigits = seq(
|
||||||
|
repeat1(decimal),
|
||||||
|
repeat(seq(separator, repeat1(decimal)))
|
||||||
|
);
|
||||||
|
return token(
|
||||||
|
choice(
|
||||||
|
decimalDigits,
|
||||||
|
seq('0b', decimalDigits),
|
||||||
|
seq('0x', hexDigits)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
identifier: ($) => /[a-zA-Z_]\w*/,
|
||||||
|
|
||||||
|
_expression: ($) =>
|
||||||
|
choice(
|
||||||
|
$.conditional_expression,
|
||||||
|
$.binary_expression,
|
||||||
|
$.unary_expression,
|
||||||
|
$.call_expression,
|
||||||
|
$.identifier,
|
||||||
|
$.integer_literal,
|
||||||
|
$.parenthesized_expression
|
||||||
|
),
|
||||||
|
|
||||||
|
parenthesized_expression: ($) => seq('(', $._expression, ')'),
|
||||||
|
|
||||||
|
call_expression: ($) =>
|
||||||
|
prec(
|
||||||
|
PREC.CALL,
|
||||||
|
seq(
|
||||||
|
field('function', $.identifier),
|
||||||
|
field('arguments', $.argument_list)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
|
||||||
|
argument_list: ($) => seq('(', commaSep($._expression), ')'),
|
||||||
|
|
||||||
|
conditional_expression: ($) =>
|
||||||
|
prec.right(
|
||||||
|
PREC.CONDITIONAL,
|
||||||
|
seq(
|
||||||
|
field('condition', $._expression),
|
||||||
|
'?',
|
||||||
|
field('consequence', $._expression),
|
||||||
|
':',
|
||||||
|
field('alternative', $._expression)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
|
||||||
|
unary_expression: ($) =>
|
||||||
|
prec.left(
|
||||||
|
PREC.UNARY,
|
||||||
|
seq(
|
||||||
|
field('operator', choice('!', '~', '-', '+')),
|
||||||
|
field('argument', $._expression)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
|
||||||
|
binary_expression: ($) => {
|
||||||
|
/** @type {[string, number][]} */
|
||||||
|
const table = [
|
||||||
|
['+', PREC.ADD],
|
||||||
|
['-', PREC.ADD],
|
||||||
|
['*', PREC.MULTIPLY],
|
||||||
|
['/', PREC.MULTIPLY],
|
||||||
|
['%', PREC.MULTIPLY],
|
||||||
|
['||', PREC.LOGICAL_OR],
|
||||||
|
['&&', PREC.LOGICAL_AND],
|
||||||
|
['|', PREC.INCLUSIVE_OR],
|
||||||
|
['^', PREC.EXCLUSIVE_OR],
|
||||||
|
['&', PREC.BITWISE_AND],
|
||||||
|
['==', PREC.EQUAL],
|
||||||
|
['!=', PREC.EQUAL],
|
||||||
|
['>', PREC.RELATIONAL],
|
||||||
|
['>=', PREC.RELATIONAL],
|
||||||
|
['<=', PREC.RELATIONAL],
|
||||||
|
['<', PREC.RELATIONAL],
|
||||||
|
['<<', PREC.SHIFT],
|
||||||
|
['>>', PREC.SHIFT],
|
||||||
|
];
|
||||||
|
|
||||||
|
return choice(
|
||||||
|
...table.map(([operator, precedence]) => {
|
||||||
|
return prec.left(
|
||||||
|
precedence,
|
||||||
|
seq(
|
||||||
|
field('left', $._expression),
|
||||||
|
field('operator', operator),
|
||||||
|
field('right', $._expression)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
dtsi_include: ($) => seq('/include/', field('path', $.string_literal)),
|
||||||
|
|
||||||
|
preproc_include: ($) =>
|
||||||
|
seq(
|
||||||
|
preprocessor('include'),
|
||||||
|
field(
|
||||||
|
'path',
|
||||||
|
choice($.string_literal, $.system_lib_string, $.identifier)
|
||||||
|
),
|
||||||
|
token.immediate(/\r?\n/)
|
||||||
|
),
|
||||||
|
|
||||||
|
preproc_def: ($) =>
|
||||||
|
seq(
|
||||||
|
preprocessor('define'),
|
||||||
|
field('name', $.identifier),
|
||||||
|
field('value', optional($.preproc_arg)),
|
||||||
|
token.immediate(/\r?\n/)
|
||||||
|
),
|
||||||
|
|
||||||
|
preproc_function_def: ($) =>
|
||||||
|
seq(
|
||||||
|
preprocessor('define'),
|
||||||
|
field('name', $.identifier),
|
||||||
|
field('parameters', $.preproc_params),
|
||||||
|
field('value', optional($.preproc_arg)),
|
||||||
|
token.immediate(/\r?\n/)
|
||||||
|
),
|
||||||
|
|
||||||
|
preproc_params: ($) =>
|
||||||
|
seq(
|
||||||
|
token.immediate('('),
|
||||||
|
commaSep(choice($.identifier, '...')),
|
||||||
|
')'
|
||||||
|
),
|
||||||
|
|
||||||
|
preproc_undef: ($) =>
|
||||||
|
seq(
|
||||||
|
preprocessor('undef'),
|
||||||
|
field('name', $.identifier),
|
||||||
|
token.immediate(/\r?\n/)
|
||||||
|
),
|
||||||
|
|
||||||
|
preproc_arg: ($) => token(prec(-1, repeat1(/.|\\\r?\n/))),
|
||||||
|
|
||||||
|
...preprocIf('', ($) => $._top_level_item),
|
||||||
|
...preprocIf('_in_node', ($) => $._node_members),
|
||||||
|
|
||||||
|
_preproc_expression: ($) =>
|
||||||
|
choice(
|
||||||
|
$.identifier,
|
||||||
|
alias($.preproc_call_expression, $.call_expression),
|
||||||
|
$.integer_literal,
|
||||||
|
$.preproc_defined,
|
||||||
|
alias($.preproc_unary_expression, $.unary_expression),
|
||||||
|
alias($.preproc_binary_expression, $.binary_expression),
|
||||||
|
alias(
|
||||||
|
$.preproc_parenthesized_expression,
|
||||||
|
$.parenthesized_expression
|
||||||
|
)
|
||||||
|
),
|
||||||
|
|
||||||
|
preproc_parenthesized_expression: ($) =>
|
||||||
|
seq('(', $._preproc_expression, ')'),
|
||||||
|
|
||||||
|
preproc_defined: ($) =>
|
||||||
|
choice(
|
||||||
|
prec(PREC.CALL, seq('defined', '(', $.identifier, ')')),
|
||||||
|
seq('defined', $.identifier)
|
||||||
|
),
|
||||||
|
|
||||||
|
preproc_unary_expression: ($) =>
|
||||||
|
prec.left(
|
||||||
|
PREC.UNARY,
|
||||||
|
seq(
|
||||||
|
field('operator', choice('!', '~', '-', '+')),
|
||||||
|
field('argument', $._preproc_expression)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
|
||||||
|
preproc_call_expression: ($) =>
|
||||||
|
prec(
|
||||||
|
PREC.CALL,
|
||||||
|
seq(
|
||||||
|
field('function', $.identifier),
|
||||||
|
field(
|
||||||
|
'arguments',
|
||||||
|
alias($.preproc_argument_list, $.argument_list)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
|
||||||
|
preproc_argument_list: ($) =>
|
||||||
|
seq('(', commaSep($._preproc_expression), ')'),
|
||||||
|
|
||||||
|
preproc_binary_expression: ($) => {
|
||||||
|
const table = [
|
||||||
|
['+', PREC.ADD],
|
||||||
|
['-', PREC.ADD],
|
||||||
|
['*', PREC.MULTIPLY],
|
||||||
|
['/', PREC.MULTIPLY],
|
||||||
|
['%', PREC.MULTIPLY],
|
||||||
|
['||', PREC.LOGICAL_OR],
|
||||||
|
['&&', PREC.LOGICAL_AND],
|
||||||
|
['|', PREC.INCLUSIVE_OR],
|
||||||
|
['^', PREC.EXCLUSIVE_OR],
|
||||||
|
['&', PREC.BITWISE_AND],
|
||||||
|
['==', PREC.EQUAL],
|
||||||
|
['!=', PREC.EQUAL],
|
||||||
|
['>', PREC.RELATIONAL],
|
||||||
|
['>=', PREC.RELATIONAL],
|
||||||
|
['<=', PREC.RELATIONAL],
|
||||||
|
['<', PREC.RELATIONAL],
|
||||||
|
['<<', PREC.SHIFT],
|
||||||
|
['>>', PREC.SHIFT],
|
||||||
|
];
|
||||||
|
|
||||||
|
return choice(
|
||||||
|
...table.map(([operator, precedence]) => {
|
||||||
|
return prec.left(
|
||||||
|
precedence,
|
||||||
|
seq(
|
||||||
|
field('left', $._preproc_expression),
|
||||||
|
// @ts-ignore
|
||||||
|
field('operator', operator),
|
||||||
|
field('right', $._preproc_expression)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} command
|
||||||
|
*/
|
||||||
|
function preprocessor(command) {
|
||||||
|
return alias(
|
||||||
|
token(prec(2, new RegExp('#[ \t]*' + command))),
|
||||||
|
'#' + command
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {RuleOrLiteral} rule
|
||||||
|
*/
|
||||||
|
function commaSep(rule) {
|
||||||
|
return optional(commaSep1(rule));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {RuleOrLiteral} rule
|
||||||
|
*/
|
||||||
|
function commaSep1(rule) {
|
||||||
|
return seq(rule, repeat(seq(',', rule)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} suffix
|
||||||
|
* @param {RuleBuilder<string>} content
|
||||||
|
* @returns {RuleBuilders<string, string>}
|
||||||
|
*/
|
||||||
|
function preprocIf(suffix, content) {
|
||||||
|
/**
|
||||||
|
* @param {GrammarSymbols<string>} $
|
||||||
|
* @returns {ChoiceRule}
|
||||||
|
*/
|
||||||
|
function elseBlock($) {
|
||||||
|
return choice(
|
||||||
|
suffix
|
||||||
|
? alias($['preproc_else' + suffix], $.preproc_else)
|
||||||
|
: $.preproc_else,
|
||||||
|
suffix
|
||||||
|
? alias($['preproc_elif' + suffix], $.preproc_elif)
|
||||||
|
: $.preproc_elif
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
['preproc_if' + suffix]: ($) =>
|
||||||
|
seq(
|
||||||
|
preprocessor('if'),
|
||||||
|
field('condition', $._preproc_expression),
|
||||||
|
'\n',
|
||||||
|
repeat(content($)),
|
||||||
|
field('alternative', optional(elseBlock($))),
|
||||||
|
preprocessor('endif')
|
||||||
|
),
|
||||||
|
|
||||||
|
['preproc_ifdef' + suffix]: ($) =>
|
||||||
|
seq(
|
||||||
|
choice(preprocessor('ifdef'), preprocessor('ifndef')),
|
||||||
|
field('name', $.identifier),
|
||||||
|
repeat(content($)),
|
||||||
|
field(
|
||||||
|
'alternative',
|
||||||
|
optional(choice(elseBlock($), $.preproc_elifdef))
|
||||||
|
),
|
||||||
|
preprocessor('endif')
|
||||||
|
),
|
||||||
|
|
||||||
|
['preproc_else' + suffix]: ($) =>
|
||||||
|
seq(preprocessor('else'), repeat(content($))),
|
||||||
|
|
||||||
|
['preproc_elif' + suffix]: ($) =>
|
||||||
|
seq(
|
||||||
|
preprocessor('elif'),
|
||||||
|
field('condition', $._preproc_expression),
|
||||||
|
'\n',
|
||||||
|
repeat(content($)),
|
||||||
|
field('alternative', optional(elseBlock($)))
|
||||||
|
),
|
||||||
|
|
||||||
|
['preproc_elifdef' + suffix]: ($) =>
|
||||||
|
seq(
|
||||||
|
choice(preprocessor('elifdef'), preprocessor('elifndef')),
|
||||||
|
field('name', $.identifier),
|
||||||
|
repeat(content($)),
|
||||||
|
field('alternative', optional(elseBlock($)))
|
||||||
|
),
|
||||||
|
};
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"name": "tree-sitter-devicetree",
|
||||||
|
"version": "0.9.0",
|
||||||
|
"description": "Tree-sitter parser for Devicetree files, with support for Zephyr's superset of Devicetree syntax.",
|
||||||
|
"main": "bindings/node",
|
||||||
|
"scripts": {
|
||||||
|
"build": "tree-sitter generate && node-gyp build",
|
||||||
|
"test": "tree-sitter test",
|
||||||
|
"lint": "eslint grammar.js",
|
||||||
|
"build:wasm": "tree-sitter build-wasm",
|
||||||
|
"prettier:check": "prettier --check .",
|
||||||
|
"prettier:format": "prettier --write ."
|
||||||
|
},
|
||||||
|
"author": "Joel Spadin",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"nan": "^2.18.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"eslint": "^8.54.0",
|
||||||
|
"eslint-config-prettier": "^9.0.0",
|
||||||
|
"prettier": "^3.1.0",
|
||||||
|
"tree-sitter-cli": "^0.20.8"
|
||||||
|
},
|
||||||
|
"tree-sitter": [
|
||||||
|
{
|
||||||
|
"scope": "source.devicetree",
|
||||||
|
"file-types": [
|
||||||
|
"dts",
|
||||||
|
"dtsi",
|
||||||
|
"overlay"
|
||||||
|
],
|
||||||
|
"injection-regex": "^(dts|devicetree)$"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -0,0 +1,78 @@
|
|||||||
|
[
|
||||||
|
"/delete-node/"
|
||||||
|
"/delete-property/"
|
||||||
|
"/dts-v1/"
|
||||||
|
"/incbin/"
|
||||||
|
"/include/"
|
||||||
|
"/memreserve/"
|
||||||
|
"/omit-if-no-ref/"
|
||||||
|
"#define"
|
||||||
|
"#undef"
|
||||||
|
"#include"
|
||||||
|
"#if"
|
||||||
|
"#elif"
|
||||||
|
"#else"
|
||||||
|
"#endif"
|
||||||
|
"#ifdef"
|
||||||
|
"#ifndef"
|
||||||
|
] @keyword
|
||||||
|
|
||||||
|
[
|
||||||
|
"!"
|
||||||
|
"~"
|
||||||
|
"-"
|
||||||
|
"+"
|
||||||
|
"*"
|
||||||
|
"/"
|
||||||
|
"%"
|
||||||
|
"||"
|
||||||
|
"&&"
|
||||||
|
"|"
|
||||||
|
"^"
|
||||||
|
"&"
|
||||||
|
"=="
|
||||||
|
"!="
|
||||||
|
">"
|
||||||
|
">="
|
||||||
|
"<="
|
||||||
|
">"
|
||||||
|
"<<"
|
||||||
|
">>"
|
||||||
|
] @operator
|
||||||
|
|
||||||
|
[
|
||||||
|
","
|
||||||
|
";"
|
||||||
|
] @punctuation.delimiter
|
||||||
|
|
||||||
|
[
|
||||||
|
"("
|
||||||
|
")"
|
||||||
|
"{"
|
||||||
|
"}"
|
||||||
|
"<"
|
||||||
|
">"
|
||||||
|
] @punctuation.bracket
|
||||||
|
|
||||||
|
(call_expression
|
||||||
|
function: (identifier) @function)
|
||||||
|
|
||||||
|
(node
|
||||||
|
label: (identifier) @label)
|
||||||
|
|
||||||
|
(property
|
||||||
|
label: (identifier) @label)
|
||||||
|
|
||||||
|
(memory_reservation
|
||||||
|
label: (identifier) @label)
|
||||||
|
|
||||||
|
(property
|
||||||
|
name: (identifier) @property)
|
||||||
|
|
||||||
|
(identifier) @variable
|
||||||
|
|
||||||
|
(unit_address) @tag
|
||||||
|
|
||||||
|
(reference) @constant
|
||||||
|
|
||||||
|
(comment) @comment
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,224 @@
|
|||||||
|
#ifndef TREE_SITTER_PARSER_H_
|
||||||
|
#define TREE_SITTER_PARSER_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#define ts_builtin_sym_error ((TSSymbol)-1)
|
||||||
|
#define ts_builtin_sym_end 0
|
||||||
|
#define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024
|
||||||
|
|
||||||
|
typedef uint16_t TSStateId;
|
||||||
|
|
||||||
|
#ifndef TREE_SITTER_API_H_
|
||||||
|
typedef uint16_t TSSymbol;
|
||||||
|
typedef uint16_t TSFieldId;
|
||||||
|
typedef struct TSLanguage TSLanguage;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
TSFieldId field_id;
|
||||||
|
uint8_t child_index;
|
||||||
|
bool inherited;
|
||||||
|
} TSFieldMapEntry;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint16_t index;
|
||||||
|
uint16_t length;
|
||||||
|
} TSFieldMapSlice;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
bool visible;
|
||||||
|
bool named;
|
||||||
|
bool supertype;
|
||||||
|
} TSSymbolMetadata;
|
||||||
|
|
||||||
|
typedef struct TSLexer TSLexer;
|
||||||
|
|
||||||
|
struct TSLexer {
|
||||||
|
int32_t lookahead;
|
||||||
|
TSSymbol result_symbol;
|
||||||
|
void (*advance)(TSLexer *, bool);
|
||||||
|
void (*mark_end)(TSLexer *);
|
||||||
|
uint32_t (*get_column)(TSLexer *);
|
||||||
|
bool (*is_at_included_range_start)(const TSLexer *);
|
||||||
|
bool (*eof)(const TSLexer *);
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
TSParseActionTypeShift,
|
||||||
|
TSParseActionTypeReduce,
|
||||||
|
TSParseActionTypeAccept,
|
||||||
|
TSParseActionTypeRecover,
|
||||||
|
} TSParseActionType;
|
||||||
|
|
||||||
|
typedef union {
|
||||||
|
struct {
|
||||||
|
uint8_t type;
|
||||||
|
TSStateId state;
|
||||||
|
bool extra;
|
||||||
|
bool repetition;
|
||||||
|
} shift;
|
||||||
|
struct {
|
||||||
|
uint8_t type;
|
||||||
|
uint8_t child_count;
|
||||||
|
TSSymbol symbol;
|
||||||
|
int16_t dynamic_precedence;
|
||||||
|
uint16_t production_id;
|
||||||
|
} reduce;
|
||||||
|
uint8_t type;
|
||||||
|
} TSParseAction;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint16_t lex_state;
|
||||||
|
uint16_t external_lex_state;
|
||||||
|
} TSLexMode;
|
||||||
|
|
||||||
|
typedef union {
|
||||||
|
TSParseAction action;
|
||||||
|
struct {
|
||||||
|
uint8_t count;
|
||||||
|
bool reusable;
|
||||||
|
} entry;
|
||||||
|
} TSParseActionEntry;
|
||||||
|
|
||||||
|
struct TSLanguage {
|
||||||
|
uint32_t version;
|
||||||
|
uint32_t symbol_count;
|
||||||
|
uint32_t alias_count;
|
||||||
|
uint32_t token_count;
|
||||||
|
uint32_t external_token_count;
|
||||||
|
uint32_t state_count;
|
||||||
|
uint32_t large_state_count;
|
||||||
|
uint32_t production_id_count;
|
||||||
|
uint32_t field_count;
|
||||||
|
uint16_t max_alias_sequence_length;
|
||||||
|
const uint16_t *parse_table;
|
||||||
|
const uint16_t *small_parse_table;
|
||||||
|
const uint32_t *small_parse_table_map;
|
||||||
|
const TSParseActionEntry *parse_actions;
|
||||||
|
const char * const *symbol_names;
|
||||||
|
const char * const *field_names;
|
||||||
|
const TSFieldMapSlice *field_map_slices;
|
||||||
|
const TSFieldMapEntry *field_map_entries;
|
||||||
|
const TSSymbolMetadata *symbol_metadata;
|
||||||
|
const TSSymbol *public_symbol_map;
|
||||||
|
const uint16_t *alias_map;
|
||||||
|
const TSSymbol *alias_sequences;
|
||||||
|
const TSLexMode *lex_modes;
|
||||||
|
bool (*lex_fn)(TSLexer *, TSStateId);
|
||||||
|
bool (*keyword_lex_fn)(TSLexer *, TSStateId);
|
||||||
|
TSSymbol keyword_capture_token;
|
||||||
|
struct {
|
||||||
|
const bool *states;
|
||||||
|
const TSSymbol *symbol_map;
|
||||||
|
void *(*create)(void);
|
||||||
|
void (*destroy)(void *);
|
||||||
|
bool (*scan)(void *, TSLexer *, const bool *symbol_whitelist);
|
||||||
|
unsigned (*serialize)(void *, char *);
|
||||||
|
void (*deserialize)(void *, const char *, unsigned);
|
||||||
|
} external_scanner;
|
||||||
|
const TSStateId *primary_state_ids;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Lexer Macros
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define START_LEXER() \
|
||||||
|
bool result = false; \
|
||||||
|
bool skip = false; \
|
||||||
|
bool eof = false; \
|
||||||
|
int32_t lookahead; \
|
||||||
|
goto start; \
|
||||||
|
next_state: \
|
||||||
|
lexer->advance(lexer, skip); \
|
||||||
|
start: \
|
||||||
|
skip = false; \
|
||||||
|
lookahead = lexer->lookahead;
|
||||||
|
|
||||||
|
#define ADVANCE(state_value) \
|
||||||
|
{ \
|
||||||
|
state = state_value; \
|
||||||
|
goto next_state; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define SKIP(state_value) \
|
||||||
|
{ \
|
||||||
|
skip = true; \
|
||||||
|
state = state_value; \
|
||||||
|
goto next_state; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define ACCEPT_TOKEN(symbol_value) \
|
||||||
|
result = true; \
|
||||||
|
lexer->result_symbol = symbol_value; \
|
||||||
|
lexer->mark_end(lexer);
|
||||||
|
|
||||||
|
#define END_STATE() return result;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Parse Table Macros
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define SMALL_STATE(id) id - LARGE_STATE_COUNT
|
||||||
|
|
||||||
|
#define STATE(id) id
|
||||||
|
|
||||||
|
#define ACTIONS(id) id
|
||||||
|
|
||||||
|
#define SHIFT(state_value) \
|
||||||
|
{{ \
|
||||||
|
.shift = { \
|
||||||
|
.type = TSParseActionTypeShift, \
|
||||||
|
.state = state_value \
|
||||||
|
} \
|
||||||
|
}}
|
||||||
|
|
||||||
|
#define SHIFT_REPEAT(state_value) \
|
||||||
|
{{ \
|
||||||
|
.shift = { \
|
||||||
|
.type = TSParseActionTypeShift, \
|
||||||
|
.state = state_value, \
|
||||||
|
.repetition = true \
|
||||||
|
} \
|
||||||
|
}}
|
||||||
|
|
||||||
|
#define SHIFT_EXTRA() \
|
||||||
|
{{ \
|
||||||
|
.shift = { \
|
||||||
|
.type = TSParseActionTypeShift, \
|
||||||
|
.extra = true \
|
||||||
|
} \
|
||||||
|
}}
|
||||||
|
|
||||||
|
#define REDUCE(symbol_val, child_count_val, ...) \
|
||||||
|
{{ \
|
||||||
|
.reduce = { \
|
||||||
|
.type = TSParseActionTypeReduce, \
|
||||||
|
.symbol = symbol_val, \
|
||||||
|
.child_count = child_count_val, \
|
||||||
|
__VA_ARGS__ \
|
||||||
|
}, \
|
||||||
|
}}
|
||||||
|
|
||||||
|
#define RECOVER() \
|
||||||
|
{{ \
|
||||||
|
.type = TSParseActionTypeRecover \
|
||||||
|
}}
|
||||||
|
|
||||||
|
#define ACCEPT_INPUT() \
|
||||||
|
{{ \
|
||||||
|
.type = TSParseActionTypeAccept \
|
||||||
|
}}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // TREE_SITTER_PARSER_H_
|
||||||
@ -0,0 +1,41 @@
|
|||||||
|
========================================================================
|
||||||
|
Node addresses
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
/ {
|
||||||
|
foo@0123456789 {};
|
||||||
|
bar@abcdef {};
|
||||||
|
baz@ABCDEF {};
|
||||||
|
fred@1,0 {};
|
||||||
|
|
||||||
|
prop = <&{/bar@abcdef}>;
|
||||||
|
};
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
address: (unit_address))
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
address: (unit_address))
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
address: (unit_address))
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
address: (unit_address))
|
||||||
|
(property
|
||||||
|
name: (identifier)
|
||||||
|
value: (integer_cells
|
||||||
|
(reference
|
||||||
|
path: (identifier)
|
||||||
|
address: (unit_address)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
@ -0,0 +1,48 @@
|
|||||||
|
|
||||||
|
========================================================================
|
||||||
|
Delete nodes
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
/ {
|
||||||
|
foo: bar {};
|
||||||
|
/delete-node/ bar;
|
||||||
|
/delete-node/ &foo;
|
||||||
|
};
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
(node
|
||||||
|
label: (identifier)
|
||||||
|
name: (identifier)
|
||||||
|
)
|
||||||
|
(delete_node
|
||||||
|
name: (identifier))
|
||||||
|
(delete_node
|
||||||
|
name: (reference label: (identifier)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
========================================================================
|
||||||
|
Delete properties
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
/ {
|
||||||
|
baz = "baz";
|
||||||
|
/delete-property/ baz;
|
||||||
|
};
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
(property
|
||||||
|
name: (identifier)
|
||||||
|
value: (string_literal))
|
||||||
|
(delete_property
|
||||||
|
name: (identifier))
|
||||||
|
)
|
||||||
|
)
|
||||||
@ -0,0 +1,65 @@
|
|||||||
|
========================================================================
|
||||||
|
Document Version
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
/dts-v1/;
|
||||||
|
|
||||||
|
/ {};
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(file_version)
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
========================================================================
|
||||||
|
Plugin
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
/dts-v1/;
|
||||||
|
/plugin/;
|
||||||
|
|
||||||
|
/ {};
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(file_version)
|
||||||
|
(plugin)
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
========================================================================
|
||||||
|
Include
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
/include/ "file.dtsi"
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(dtsi_include
|
||||||
|
path: (string_literal)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
========================================================================
|
||||||
|
Memreserve
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
/memreserve/ 0x0000 0x1000;
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(memory_reservation
|
||||||
|
address: (integer_literal)
|
||||||
|
length: (integer_literal)
|
||||||
|
)
|
||||||
|
)
|
||||||
@ -0,0 +1,67 @@
|
|||||||
|
========================================================================
|
||||||
|
Property value expressions
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
/ {
|
||||||
|
a = <17 0xc>;
|
||||||
|
b = <(1 + 2) (3 - 4 * 5) (6 / 7 % 8)>;
|
||||||
|
c = <((4 ^ ~5) << 5)>;
|
||||||
|
f = <(8 ? 9 : 10)>;
|
||||||
|
};
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
(property
|
||||||
|
name: (identifier)
|
||||||
|
value: (integer_cells (integer_literal) (integer_literal))
|
||||||
|
)
|
||||||
|
(property
|
||||||
|
name: (identifier)
|
||||||
|
value: (integer_cells
|
||||||
|
(binary_expression
|
||||||
|
left: (integer_literal)
|
||||||
|
right: (integer_literal)
|
||||||
|
)
|
||||||
|
(binary_expression
|
||||||
|
left: (integer_literal)
|
||||||
|
right: (binary_expression
|
||||||
|
left: (integer_literal)
|
||||||
|
right: (integer_literal)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(binary_expression
|
||||||
|
left: (binary_expression
|
||||||
|
left: (integer_literal)
|
||||||
|
right: (integer_literal)
|
||||||
|
)
|
||||||
|
right: (integer_literal)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(property
|
||||||
|
name: (identifier)
|
||||||
|
value: (integer_cells
|
||||||
|
(binary_expression
|
||||||
|
left: (binary_expression
|
||||||
|
left: (integer_literal)
|
||||||
|
right: (unary_expression argument: (integer_literal))
|
||||||
|
)
|
||||||
|
right: (integer_literal)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(property
|
||||||
|
name: (identifier)
|
||||||
|
value: (integer_cells
|
||||||
|
(conditional_expression
|
||||||
|
condition: (integer_literal)
|
||||||
|
consequence: (integer_literal)
|
||||||
|
alternative: (integer_literal)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
@ -0,0 +1,123 @@
|
|||||||
|
========================================================================
|
||||||
|
ZMK keymap
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
//https://github.com/zmkfirmware/zmk/blob/main/app/boards/shields/kyria/kyria.keymap
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 The ZMK Contributors
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <behaviors.dtsi>
|
||||||
|
#include <dt-bindings/zmk/keys.h>
|
||||||
|
|
||||||
|
/ {
|
||||||
|
keymap {
|
||||||
|
compatible = "zmk,keymap";
|
||||||
|
|
||||||
|
default_layer {
|
||||||
|
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
// | ESC | Q | W | E | R | T | | Y | U | I | O | P | \ |
|
||||||
|
// | TAB | A | S | D | F | G | | H | J | K | L | ; | ' |
|
||||||
|
// | SHIFT | Z | X | C | V | B | L SHIFT | L SHIFT | | L SHIFT | L SHIFT | N | M | , | . | / | CTRL |
|
||||||
|
// | GUI | DEL | RET | SPACE | ESC | | RET | SPACE | TAB | BSPC | R-ALT |
|
||||||
|
bindings = <
|
||||||
|
&kp ESC &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp BSLH
|
||||||
|
&kp TAB &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SCLN &kp QUOT
|
||||||
|
&kp LSFT &kp Z &kp X &kp C &kp V &kp B &kp LSFT &kp LSFT &kp LSFT &kp LSFT &kp N &kp M &kp CMMA &kp DOT &kp FSLH &kp RCTL
|
||||||
|
&kp LGUI &kp DEL &kp RET &kp SPC &kp ESC &kp RET &kp SPC &kp TAB &kp BKSP &kp RALT
|
||||||
|
>;
|
||||||
|
|
||||||
|
sensor-bindings = <&inc_dec_kp M_VOLU M_VOLD &inc_dec_kp PGUP PGDN>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(comment)
|
||||||
|
(comment)
|
||||||
|
(preproc_include path: (system_lib_string))
|
||||||
|
(preproc_include path: (system_lib_string))
|
||||||
|
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
(property name: (identifier) value: (string_literal))
|
||||||
|
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
(comment)
|
||||||
|
(comment)
|
||||||
|
(comment)
|
||||||
|
(comment)
|
||||||
|
(comment)
|
||||||
|
(property
|
||||||
|
name: (identifier)
|
||||||
|
value: (integer_cells
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(property
|
||||||
|
name: (identifier)
|
||||||
|
value: (integer_cells
|
||||||
|
(reference label: (identifier)) (identifier) (identifier)
|
||||||
|
(reference label: (identifier)) (identifier) (identifier)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
@ -0,0 +1,122 @@
|
|||||||
|
========================================================================
|
||||||
|
Top-level label
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
label: node {};
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(node
|
||||||
|
label: (identifier)
|
||||||
|
name: (identifier)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
========================================================================
|
||||||
|
Multiple labels
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
foo: bar: baz: qux: node {};
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(node
|
||||||
|
label: (identifier)
|
||||||
|
label: (identifier)
|
||||||
|
label: (identifier)
|
||||||
|
label: (identifier)
|
||||||
|
name: (identifier)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
========================================================================
|
||||||
|
Labeled child node
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
/ {
|
||||||
|
label: node-name@deadbeef {};
|
||||||
|
};
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
(node
|
||||||
|
label: (identifier)
|
||||||
|
name: (identifier)
|
||||||
|
address: (unit_address)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
========================================================================
|
||||||
|
Labeled node reference
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
foo: &bar {};
|
||||||
|
|
||||||
|
foo: &{/bar@deadbeef} {};
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(node
|
||||||
|
label: (identifier)
|
||||||
|
name: (reference
|
||||||
|
label: (identifier)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(node
|
||||||
|
label: (identifier)
|
||||||
|
name: (reference
|
||||||
|
path: (identifier)
|
||||||
|
address: (unit_address)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
========================================================================
|
||||||
|
Labeled property
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
/ {
|
||||||
|
foo: foo = <1>;
|
||||||
|
bar: bar;
|
||||||
|
};
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
(property
|
||||||
|
label: (identifier)
|
||||||
|
name: (identifier)
|
||||||
|
value: (integer_cells (integer_literal))
|
||||||
|
)
|
||||||
|
(property
|
||||||
|
label: (identifier)
|
||||||
|
name: (identifier)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
========================================================================
|
||||||
|
Labeled memreserve
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
mem1: mem2: /memreserve/ 0x0000 0x1000;
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(memory_reservation
|
||||||
|
label: (identifier)
|
||||||
|
label: (identifier)
|
||||||
|
address: (integer_literal)
|
||||||
|
length: (integer_literal)
|
||||||
|
)
|
||||||
|
)
|
||||||
@ -0,0 +1,65 @@
|
|||||||
|
========================================================================
|
||||||
|
Top-level nodes
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
/ {};
|
||||||
|
|
||||||
|
&foo {};
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(node name: (identifier))
|
||||||
|
(node name: (reference label: (identifier)))
|
||||||
|
)
|
||||||
|
|
||||||
|
========================================================================
|
||||||
|
Child nodes
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
/ {
|
||||||
|
foo {
|
||||||
|
bar {};
|
||||||
|
};
|
||||||
|
baz {};
|
||||||
|
};
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(node name: (identifier)
|
||||||
|
(node name: (identifier)
|
||||||
|
(node name: (identifier))
|
||||||
|
)
|
||||||
|
(node name: (identifier))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
========================================================================
|
||||||
|
Node addresses
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
/ {
|
||||||
|
foo@12345678 {};
|
||||||
|
bar@deadbeef,abcd1234 {};
|
||||||
|
baz@xyz-abc_123+456.789 {};
|
||||||
|
};
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(node name: (identifier)
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
address: (unit_address)
|
||||||
|
)
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
address: (unit_address)
|
||||||
|
)
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
address: (unit_address)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
@ -0,0 +1,56 @@
|
|||||||
|
========================================================================
|
||||||
|
Omit Node
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
/ {
|
||||||
|
/omit-if-no-ref/ child {};
|
||||||
|
};
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
(omit_if_no_ref
|
||||||
|
(node name: (identifier))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
========================================================================
|
||||||
|
Omit Labeled Node
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
/ {
|
||||||
|
/omit-if-no-ref/ label: child {};
|
||||||
|
};
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
(omit_if_no_ref
|
||||||
|
(node
|
||||||
|
label: (identifier)
|
||||||
|
name: (identifier)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
========================================================================
|
||||||
|
Omit Reference
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
/omit-if-no-ref/ &node;
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(omit_if_no_ref
|
||||||
|
(reference
|
||||||
|
label: (identifier)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
@ -0,0 +1,340 @@
|
|||||||
|
========================================================================
|
||||||
|
Preprocessor include
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
#include "foo.h"
|
||||||
|
#include <bar.h>
|
||||||
|
# include "baz.dtsi"
|
||||||
|
# include <baz.dtsi>
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(preproc_include path: (string_literal))
|
||||||
|
(preproc_include path: (system_lib_string))
|
||||||
|
(preproc_include path: (string_literal))
|
||||||
|
(preproc_include path: (system_lib_string))
|
||||||
|
)
|
||||||
|
|
||||||
|
========================================================================
|
||||||
|
Preprocessor define
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
#define FOO 0
|
||||||
|
#define BAR(x) (x & 0x01)
|
||||||
|
#undef FOO
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(preproc_def
|
||||||
|
name: (identifier)
|
||||||
|
value: (preproc_arg)
|
||||||
|
)
|
||||||
|
(preproc_function_def
|
||||||
|
name: (identifier)
|
||||||
|
parameters: (preproc_params
|
||||||
|
(identifier)
|
||||||
|
)
|
||||||
|
value: (preproc_arg)
|
||||||
|
)
|
||||||
|
(preproc_undef
|
||||||
|
name: (identifier)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
Ifdefs
|
||||||
|
================================================================================
|
||||||
|
|
||||||
|
#ifndef DEFINE1
|
||||||
|
/ {};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DEFINE2
|
||||||
|
/ {};
|
||||||
|
#define c 32
|
||||||
|
#elif defined DEFINE3
|
||||||
|
#else
|
||||||
|
/ {};
|
||||||
|
#define c 16
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DEFINE2
|
||||||
|
#else
|
||||||
|
# ifdef DEFINE3
|
||||||
|
# else
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(preproc_ifdef
|
||||||
|
name: (identifier)
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(preproc_ifdef
|
||||||
|
name: (identifier)
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
)
|
||||||
|
(preproc_def
|
||||||
|
name: (identifier)
|
||||||
|
value: (preproc_arg)
|
||||||
|
)
|
||||||
|
alternative: (preproc_elif
|
||||||
|
condition: (preproc_defined
|
||||||
|
(identifier)
|
||||||
|
)
|
||||||
|
alternative: (preproc_else
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
)
|
||||||
|
(preproc_def
|
||||||
|
name: (identifier)
|
||||||
|
value: (preproc_arg)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(preproc_ifdef
|
||||||
|
name: (identifier)
|
||||||
|
alternative: (preproc_else
|
||||||
|
(preproc_ifdef
|
||||||
|
name: (identifier)
|
||||||
|
alternative: (preproc_else)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
Elifdefs
|
||||||
|
================================================================================
|
||||||
|
|
||||||
|
#ifndef DEFINE1
|
||||||
|
/ {};
|
||||||
|
#elifndef DEFINE2
|
||||||
|
/ {};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DEFINE2
|
||||||
|
/ {};
|
||||||
|
#elifdef DEFINE3
|
||||||
|
/ {};
|
||||||
|
#else
|
||||||
|
/ {};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(preproc_ifdef
|
||||||
|
(identifier)
|
||||||
|
(node (identifier))
|
||||||
|
(preproc_elifdef
|
||||||
|
(identifier)
|
||||||
|
(node (identifier))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(preproc_ifdef
|
||||||
|
(identifier)
|
||||||
|
(node (identifier))
|
||||||
|
(preproc_elifdef
|
||||||
|
(identifier)
|
||||||
|
(node (identifier))
|
||||||
|
(preproc_else
|
||||||
|
(node (identifier))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
========================================================================
|
||||||
|
Macro expressions
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
/ {
|
||||||
|
value = <FOO FUNC(FOO, BAR) LS(LC(A))>;
|
||||||
|
};
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
(property
|
||||||
|
name: (identifier)
|
||||||
|
value: (integer_cells
|
||||||
|
(identifier)
|
||||||
|
(call_expression
|
||||||
|
function: (identifier)
|
||||||
|
arguments: (argument_list
|
||||||
|
(identifier)
|
||||||
|
(identifier)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(call_expression
|
||||||
|
function: (identifier)
|
||||||
|
arguments: (argument_list (call_expression
|
||||||
|
function: (identifier)
|
||||||
|
arguments: (argument_list (identifier))
|
||||||
|
))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
========================================================================
|
||||||
|
Preprocessor directives in node
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
/ {
|
||||||
|
#include "macros.dtsi"
|
||||||
|
#define FOO 0
|
||||||
|
#ifdef FOO
|
||||||
|
value = <FOO>;
|
||||||
|
#endif
|
||||||
|
#ifndef BAR
|
||||||
|
value = <BAR>;
|
||||||
|
#endif
|
||||||
|
#undef FOO
|
||||||
|
};
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
(preproc_include path: (string_literal))
|
||||||
|
(preproc_def
|
||||||
|
name: (identifier)
|
||||||
|
value: (preproc_arg))
|
||||||
|
(preproc_ifdef
|
||||||
|
name: (identifier)
|
||||||
|
(property
|
||||||
|
name: (identifier)
|
||||||
|
value: (integer_cells
|
||||||
|
(identifier)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(preproc_ifdef
|
||||||
|
name: (identifier)
|
||||||
|
(property
|
||||||
|
name: (identifier)
|
||||||
|
value: (integer_cells
|
||||||
|
(identifier)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(preproc_undef
|
||||||
|
name: (identifier)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
Preprocessor conditionals in functions
|
||||||
|
================================================================================
|
||||||
|
|
||||||
|
/ {
|
||||||
|
#if d
|
||||||
|
foo = "foo";
|
||||||
|
#else
|
||||||
|
bar = "bar";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if a
|
||||||
|
baz = "baz";
|
||||||
|
#elif b
|
||||||
|
spam = "spam";
|
||||||
|
#else
|
||||||
|
eggs = "eggs";
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(node
|
||||||
|
(identifier)
|
||||||
|
(preproc_if
|
||||||
|
(identifier)
|
||||||
|
(property
|
||||||
|
(identifier)
|
||||||
|
(string_literal)
|
||||||
|
)
|
||||||
|
(preproc_else
|
||||||
|
(property
|
||||||
|
(identifier)
|
||||||
|
(string_literal)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(preproc_if
|
||||||
|
(identifier)
|
||||||
|
(property
|
||||||
|
(identifier)
|
||||||
|
(string_literal)
|
||||||
|
)
|
||||||
|
(preproc_elif
|
||||||
|
(identifier)
|
||||||
|
(property
|
||||||
|
(identifier)
|
||||||
|
(string_literal)
|
||||||
|
)
|
||||||
|
(preproc_else
|
||||||
|
(property
|
||||||
|
(identifier)
|
||||||
|
(string_literal)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
Preprocessor expressions
|
||||||
|
================================================================================
|
||||||
|
|
||||||
|
#if A(B || C) && \
|
||||||
|
!D(F)
|
||||||
|
|
||||||
|
/ {};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(preproc_if
|
||||||
|
(binary_expression
|
||||||
|
(call_expression
|
||||||
|
(identifier)
|
||||||
|
(argument_list
|
||||||
|
(binary_expression
|
||||||
|
(identifier)
|
||||||
|
(identifier)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(unary_expression
|
||||||
|
(call_expression
|
||||||
|
(identifier)
|
||||||
|
(argument_list
|
||||||
|
(identifier)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(node
|
||||||
|
(identifier)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
@ -0,0 +1,293 @@
|
|||||||
|
========================================================================
|
||||||
|
Name with hyphen
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
/ {
|
||||||
|
hyphenated-name = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
(property name: (identifier) value: (string_literal))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
========================================================================
|
||||||
|
Name with hash
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
/ {
|
||||||
|
#startswithhash = "";
|
||||||
|
hash#inmiddle = "";
|
||||||
|
endswithhash# = "";
|
||||||
|
#multiple#hashes# = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
(property name: (identifier) value: (string_literal))
|
||||||
|
(property name: (identifier) value: (string_literal))
|
||||||
|
(property name: (identifier) value: (string_literal))
|
||||||
|
(property name: (identifier) value: (string_literal))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
========================================================================
|
||||||
|
Name with comma
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
/ {
|
||||||
|
comma,separated = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
(property name: (identifier) value: (string_literal))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
========================================================================
|
||||||
|
Name with number
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
/ {
|
||||||
|
0startswithnumber = "";
|
||||||
|
number0inmiddle = "";
|
||||||
|
endswithnumber0 ="";
|
||||||
|
};
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
(property name: (identifier) value: (string_literal))
|
||||||
|
(property name: (identifier) value: (string_literal))
|
||||||
|
(property name: (identifier) value: (string_literal))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
========================================================================
|
||||||
|
Empty
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
/ {
|
||||||
|
empty;
|
||||||
|
};
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
(property name: (identifier))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
========================================================================
|
||||||
|
Integers
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
/ {
|
||||||
|
int = <0>;
|
||||||
|
list = <0 1 2>;
|
||||||
|
list_bits = /bits/ 8 <0x12 0x34>;
|
||||||
|
};
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
(property
|
||||||
|
name: (identifier)
|
||||||
|
value: (integer_cells (integer_literal))
|
||||||
|
)
|
||||||
|
(property
|
||||||
|
name: (identifier)
|
||||||
|
value: (integer_cells
|
||||||
|
(integer_literal) (integer_literal) (integer_literal)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(property
|
||||||
|
name: (identifier)
|
||||||
|
bits: (integer_literal)
|
||||||
|
value: (integer_cells
|
||||||
|
(integer_literal) (integer_literal)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
========================================================================
|
||||||
|
Strings
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
/ {
|
||||||
|
string = "foo";
|
||||||
|
strings = "foo", "bar";
|
||||||
|
};
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
(property name: (identifier) value: (string_literal))
|
||||||
|
(property
|
||||||
|
name: (identifier)
|
||||||
|
value: (string_literal)
|
||||||
|
value: (string_literal)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
========================================================================
|
||||||
|
Byte strings
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
/ {
|
||||||
|
bytes = [00 12 34];
|
||||||
|
bytes2 = [001234];
|
||||||
|
empty = [];
|
||||||
|
};
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
(property
|
||||||
|
name: (identifier)
|
||||||
|
value: (byte_string_literal)
|
||||||
|
)
|
||||||
|
(property
|
||||||
|
name: (identifier)
|
||||||
|
value: (byte_string_literal)
|
||||||
|
)
|
||||||
|
(property
|
||||||
|
name: (identifier)
|
||||||
|
value: (byte_string_literal)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
========================================================================
|
||||||
|
References
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
/ {
|
||||||
|
ref = &foo;
|
||||||
|
phandle = <&foo>;
|
||||||
|
node = <&{/foo/bar/baz@40000}>;
|
||||||
|
};
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
(property
|
||||||
|
name: (identifier)
|
||||||
|
value: (reference label: (identifier))
|
||||||
|
)
|
||||||
|
(property
|
||||||
|
name: (identifier)
|
||||||
|
value: (integer_cells
|
||||||
|
(reference label: (identifier))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(property
|
||||||
|
name: (identifier)
|
||||||
|
value: (integer_cells
|
||||||
|
(reference
|
||||||
|
path: (identifier)
|
||||||
|
address: (unit_address)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
========================================================================
|
||||||
|
Mixed values
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
/ {
|
||||||
|
mixed = <0 &foo>, [12 34], "baz";
|
||||||
|
};
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
(property
|
||||||
|
name: (identifier)
|
||||||
|
value: (integer_cells (integer_literal) (reference label: (identifier)))
|
||||||
|
value: (byte_string_literal)
|
||||||
|
value: (string_literal)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
========================================================================
|
||||||
|
Incbin
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
/ {
|
||||||
|
data = /incbin/ ("file.bin");
|
||||||
|
data2 = /incbin/ ("file.bin", 0x10, 64);
|
||||||
|
data3 = /incbin/ ("file.bin", (1 + 2), MACRO(1, 2 + 3));
|
||||||
|
};
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
(property
|
||||||
|
name: (identifier)
|
||||||
|
value: (incbin
|
||||||
|
filename: (string_literal)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(property
|
||||||
|
name: (identifier)
|
||||||
|
value: (incbin
|
||||||
|
filename: (string_literal)
|
||||||
|
offset: (integer_literal)
|
||||||
|
size: (integer_literal)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(property
|
||||||
|
name: (identifier)
|
||||||
|
value: (incbin
|
||||||
|
filename: (string_literal)
|
||||||
|
offset: (binary_expression
|
||||||
|
left: (integer_literal)
|
||||||
|
right: (integer_literal)
|
||||||
|
)
|
||||||
|
size: (call_expression
|
||||||
|
function: (identifier)
|
||||||
|
arguments: (argument_list
|
||||||
|
(integer_literal)
|
||||||
|
(binary_expression
|
||||||
|
left: (integer_literal)
|
||||||
|
right: (integer_literal)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
@ -0,0 +1,91 @@
|
|||||||
|
========================================================================
|
||||||
|
Zephyr armv6-m.dtsi
|
||||||
|
========================================================================
|
||||||
|
/* https://github.com/zephyrproject-rtos/zephyr/blob/master/dts/arm/armv6-m.dtsi */
|
||||||
|
/* SPDX-License-Identifier: Apache-2.0 */
|
||||||
|
|
||||||
|
#include "skeleton.dtsi"
|
||||||
|
|
||||||
|
/ {
|
||||||
|
soc {
|
||||||
|
#address-cells = <1>;
|
||||||
|
#size-cells = <1>;
|
||||||
|
compatible = "simple-bus";
|
||||||
|
interrupt-parent = <&nvic>;
|
||||||
|
ranges;
|
||||||
|
|
||||||
|
nvic: interrupt-controller@e000e100 {
|
||||||
|
compatible = "arm,v6m-nvic";
|
||||||
|
reg = <0xe000e100 0xc00>;
|
||||||
|
interrupt-controller;
|
||||||
|
#interrupt-cells = <2>;
|
||||||
|
};
|
||||||
|
|
||||||
|
systick: timer@e000e010 {
|
||||||
|
compatible = "arm,armv6m-systick";
|
||||||
|
reg = <0xe000e010 0x10>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(document
|
||||||
|
(comment)
|
||||||
|
(comment)
|
||||||
|
(preproc_include path: (string_literal))
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
(node
|
||||||
|
name: (identifier)
|
||||||
|
(property
|
||||||
|
name: (identifier)
|
||||||
|
value: (integer_cells (integer_literal))
|
||||||
|
)
|
||||||
|
(property
|
||||||
|
name: (identifier)
|
||||||
|
value: (integer_cells (integer_literal))
|
||||||
|
)
|
||||||
|
(property
|
||||||
|
name: (identifier)
|
||||||
|
value: (string_literal)
|
||||||
|
)
|
||||||
|
(property
|
||||||
|
name: (identifier)
|
||||||
|
value: (integer_cells (reference label: (identifier)))
|
||||||
|
)
|
||||||
|
(property name: (identifier))
|
||||||
|
(node
|
||||||
|
label: (identifier)
|
||||||
|
name: (identifier)
|
||||||
|
address: (unit_address)
|
||||||
|
(property
|
||||||
|
name: (identifier)
|
||||||
|
value: (string_literal)
|
||||||
|
)
|
||||||
|
(property
|
||||||
|
name: (identifier)
|
||||||
|
value: (integer_cells (integer_literal) (integer_literal))
|
||||||
|
)
|
||||||
|
(property name: (identifier))
|
||||||
|
(property
|
||||||
|
name: (identifier)
|
||||||
|
value: (integer_cells (integer_literal))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(node
|
||||||
|
label: (identifier)
|
||||||
|
name: (identifier)
|
||||||
|
address: (unit_address)
|
||||||
|
(property
|
||||||
|
name: (identifier)
|
||||||
|
value: (string_literal)
|
||||||
|
)
|
||||||
|
(property
|
||||||
|
name: (identifier)
|
||||||
|
value: (integer_cells (integer_literal) (integer_literal))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
Loading…
Reference in New Issue