Skip to content

Commit ac73963

Browse files
committed
feat(parser): support argument attributes
1 parent 0e6894d commit ac73963

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

arkdoc/parser/documentation.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,17 @@ class Documentation:
3030

3131
macro_keywords = ("$", "macro")
3232

33-
def _token_format(self, token: Token):
34-
return token.value
35-
3633
def signature(self):
3734
def transform(L):
38-
return list(map(lambda t: t.value, deep_flatten(L)))
35+
out = []
36+
for t in L:
37+
if isinstance(t, list) and len(t) == 1 and isinstance(t[0], list) and len(t[0]) == 2:
38+
out.append(f"({t[0][0].value} {t[0][1].value})")
39+
elif not isinstance(t, list):
40+
out.append(t.value)
41+
else:
42+
raise NotImplementedError(f"token not parsed correctly in arglist: {t}")
43+
return out
3944

4045
top = self.target[:]
4146

@@ -48,7 +53,10 @@ def transform(L):
4853
kw, name = top[:2]
4954

5055
if isinstance(top[2], list) and len(top[2][0]) >= 2:
51-
args = transform(top[2][0][1]) if kw.value not in self.macro_keywords else transform(top[2][0])
56+
if kw.value not in self.macro_keywords:
57+
args = transform(top[2][0][1][0])
58+
else:
59+
args = transform(top[2][0])
5260
return [kw.value, name.value, args]
5361
else:
5462
return [kw.value, name.value, None]

templates/html/assets/js/languages/arkscript.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Rainbow.extend('arkscript', [
3535
matches: {
3636
1: 'keyword'
3737
},
38-
pattern: /\(\s*(begin|if|fun|quote|set|while|let|mut|del|import)(?=[\]()\s#])/g
38+
pattern: /\(\s*(begin|if|fun|quote|set|while|let|mut|ref|del|import)(?=[\]()\s#])/g
3939
},
4040
{
4141
matches: {

0 commit comments

Comments
 (0)