-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add "Require"s for importing Message Definitions into WireShark #13
Comments
Looks like there's way to load an ENBF grammar during the script: local ebnf = require("lua-ebnf")
local grammarFile = "dsdl.enbf"
local grammarENBF = io.open(grammarfile):read("*a")
-- Generate the grammar from the ENBF
local grammar = enbf.parse(grammarENBF)
-- Generate the parser from the EBNF grammar
local parser = ebnf.generate(grammar)
-- Find all the local .dsdl files and parse them
local dsdl = io.open("434.GetTransportStatistics.0.1.dsdl"):read("*a") It doesn't crash with a fault when it loads this but I'm not convinced it's running on Mac yet. |
It's definite not working. There's no EBNF parser that is open to use. We may have to go down the LPEG route which is a different parser. |
Using a PEG parser in python I played with getting very small grammar working:
Then I asked Chat to convert it to LPEG format. I haven't tried this yet but I'm capturing it here in case Chat forgets our conversations again. local lpeg = require "lpeg"
local P, R, S, C, Ct = lpeg.P, lpeg.R, lpeg.S, lpeg.C, lpeg.Ct
local grammar = {
statement = P("pragma" + "comment" + "assignment" + "declaration"),
assignment = Ct("type" * S(" \t\r\n")^0 * C("identifier") * S(" \t\r\n")^0 * "=" * S(" \t\r\n")^0 * "expression"),
declaration = Ct("type" * S(" \t\r\n")^0 * C("identifier")),
type = P("int" + "float" + "string" + "bool"),
expression = P("literal" + "identifier"),
literal = P("hex" + "floating_point" + "integer" + "string" + "boolean"),
integer = R("09")^1,
floating_point = R("09")^1 * "." * R("09")^1,
hex = "0x" * R("09", "af", "AF")^1,
string = '"' * ((1 - S('\\"')) + "\\" * 1)^0 * '"',
boolean = P("true" + "false"),
identifier = R("az", "AZ") * R("az", "AZ", "09", "_")^0,
comment = "#" * (1 - P("\n"))^0,
keyword = P("sealed" + "extent"),
pragma = "@" * C("keyword")
}
return grammar |
Also dropping a link to https://bford.info/packrat/ and for Lua's LPEG https://www.inf.puc-rio.br/~roberto/lpeg/ |
Lua can "import" other lua files (which are in the same folder) by calling
require "somefile"
which will importsomefile.lua
.Using this method we could import the Cyphal Heartbeat and GetInfo defintions (and in the future, others).
The text was updated successfully, but these errors were encountered: