Skip to content
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 note support #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ local mainkey = "(" * blank0 * C((word ^ 0)) * blank0 * ")"
local decimal = "(" * blank0 * C(tag) * blank0 * ")"

local function multipat(pat)
return Ct(blank0 * (pat * blank0) ^ 0)
return Ct(blank0 * (pat * (blank - P"#[") ^0) ^ 0)
end

local function metapatt(name, idx)
Expand All @@ -85,7 +85,8 @@ end
local function namedpat(name, pat)
local type = Cg(Cc(name), "type")
local meta = Cg(metapatt(name, idx), "meta")
return Ct(type * meta * Cg(pat))
local note_patt = Cg(field_note, "note")
return Ct(type * meta * note_patt^-1 * Cg(pat))
end

local function namedfield(field_patt)
Expand All @@ -112,7 +113,7 @@ local proto = blank0 * typedef * blank0
local convert = {}

function convert.protocol(all, obj, namespace)
local result = { tag = obj[2], meta=obj.meta, name = obj[1]}
local result = { tag = obj[2], meta=obj.meta, name = obj[1], note = obj.note}
local ex = namespace and namespace.."." or ""

for order, p in ipairs(obj[3]) do
Expand Down