GithubHelp home page GithubHelp logo

lharri73 / dbc-language-syntax Goto Github PK

View Code? Open in Web Editor NEW
12.0 5.0 6.0 2.5 MB

VS Code extension providing syntax highlighting for CAN DBC files.

Home Page: https://marketplace.visualstudio.com/items?itemName=lharri73.dbc

License: GNU General Public License v2.0

Makefile 2.13% TypeScript 67.59% Yacc 16.84% Lex 3.98% Shell 0.01% HTML 2.10% JavaScript 4.21% CSS 3.13%
vscode vscode-extension can-bus dbc textmate-grammar

dbc-language-syntax's Introduction

DBC Language Syntax

Visual Studio Marketplace Version GitHub Workflow Status

This extension provides basic syntax highlighting, bracket completion, code snippets, lexer/parser errors, and a preview window for the Vector DBC file format. This is created to work with version 2 of the Vector DBC file format.

Although DBC files are often programmatically generated, it can be useful to more easily read the DBC file itself in a plaintext format. Syntax highlighting is handled locally through VSCode's integrated TextMates language parsing engine, using PCRE regular expressions to match syntax.

This extension also provides a sidebar to preview messages in the current, open DBC file. While this doesn't allow editing, it takes information from various parts of the DBC and makes it easily readable and searchable.

The preview window is still a work in progress!

Syntax Highlighting

Message and Signal Preview

Lexicographic and Parser Errors

Commonly Used Snippets

Known Issues

  1. Attribute definitions that wrap lines may not be highlighted on the following lines.
  2. Signals that are multiplexed will not be recognized

Todo items

  • Include debugging (invalid offset, start bit, min, max, etc)
  • Show more information about each signal (val tables, comments, etc.)
  • Show the byte structure of the message

Organization

  • server
    • Contains the language server and parser for the dbc language sytax
  • client
    • Contains the editor and viewer
  • dbcLib
    • basic type descriptions of each element/class of the dbc language

3rd Party Libraries

  • Vector DBC file format.
    • Although no code from this repository is used in this extension, this served as a reference for the DBC format and syntax.
  • jison
    • The parser and lexer used on the server side to parse dbc files
  • React.js
    • Used to display the parsed message/signal data in the vscode browser panel.
  • MessagePack
    • Serializes the parsed DBC file's intermediate representation into a packed binary before sending to the browser panel.

License

GNU General Public License v2.0 only

dbc-language-syntax's People

Contributors

dependabot[bot] avatar lharri73 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

dbc-language-syntax's Issues

Attribute and comment definitions that wrap lines are not recognized

This is caused by the 'end' environment being keyed on the end of line character rather than the semicolon. The problem then becomes dealing with strings that are also able to wrap lines, but currently would have to be covered under the '(.*)' pattern which only matches a single line.

[Bug] Inline File Comments

So this issue is going to be really nit-picky and is certainly not a must-have for this project. But if you have bandwidth to tackle it, it might be beneficial to have.

File only, single line comments are technically supported in DBC files. These comments are typically not parsed by most commercial applications and more so for documentation purposes inside the DBC file. They are C style comments, so as an example:


// This is a file only comment
BO_ 1234 CANMessage: 8 Node0
    SG_ Signal0 : 0|32@1- (1,0) [0|0] "" Node1 Node2
    SG_ Signal1 : 32|32@1+ (100,0) [0|100] "%" Node1 Node2

BO_ 4321 CANMultiplexed: 2 Node0
    SG_ Multiplexer M : 0|8@1+ (1,0) [0|0] "" Node1
    SG_ Value0 m0 : 8|8@1+ (1,0) [0|0] "" Node1 // I can even do comments after definitions
    SG_ Value1 m1 : 8|8@1+ (1,0) [0|0] "" Node1

CM_ "DBC Template with multiline description";
CM_ BU_ Node0 "The 0th Node";
CM_ BO_ 4321 "Multiplexed CAN-Message";
CM_ SG_ 1234 Signal0 "First signal in this message";

To be very clear when I say 'supported', I mean in an undocumented way. The official Vector DBC specifications don't really outline that file only inline comments are a thing. However, when loading DBC files into Vector's own tool (CANdb++), it will ignore those inline comments and not throw any parsing errors. If you've ever tried to load a malformed DBC into CANdb++, you'll know that it's extremely picky about how items in the file are formatted. Even a minor typo will prevent the file from being parsed and loaded. This leads me to believe that inline comments are intended to be supported for this file format. (note that while // is a supported comment /* is not */

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.