Skip to content

Commit 25643cc

Browse files
committed
feat: update the generative grammars
1 parent f14069e commit 25643cc

File tree

4 files changed

+152
-26
lines changed

4 files changed

+152
-26
lines changed

packages/keybr-code/lib/syntax/lang_cpp.g

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ start_stmt ->
1616

1717
c_func -> c_func_proto " " c_func_body ;
1818

19-
c_func_proto -> c_type " " c_func_id "(" c_param_list ")";
19+
c_func_proto -> c_type " " c_func_id "(" c_param_list ")" ;
2020

2121
c_type -> ( "char" | "int" | "long" | "short" | "void" ) [ "*" [ "*" ] ] ;
2222

@@ -52,6 +52,8 @@ c_binary_exp -> "(" c_unary_exp ")"
5252
| " / " c_var_id
5353
| " | " c_var_id
5454
| " & " c_var_id
55+
| " << " c_var_id
56+
| " >> " c_var_id
5557
| " == " c_var_id
5658
| " != " c_var_id
5759
| " >= " c_var_id

packages/keybr-code/lib/syntax/lang_cpp.ts

+16
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,22 @@ export default {
362362
},
363363
],
364364
},
365+
{
366+
seq: [
367+
" << ",
368+
{
369+
ref: "c_var_id",
370+
},
371+
],
372+
},
373+
{
374+
seq: [
375+
" >> ",
376+
{
377+
ref: "c_var_id",
378+
},
379+
],
380+
},
365381
{
366382
seq: [
367383
" == ",

packages/keybr-code/lib/syntax/lang_html_css.g

+16-12
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,14 @@ css_property -> css_property_name ": " css_property_value ;
5151
css_property_name ->
5252
"color"
5353
| "box-sizing"
54-
| "width"
55-
| "min-width"
56-
| "max-width"
57-
| "inline-size"
58-
| "min-inline-size"
59-
| "max-inline-size"
60-
| "height"
61-
| "min-height"
62-
| "max-height"
63-
| "block-size"
64-
| "min-block-size"
65-
| "max-block-size"
54+
| [ ( "min" | "max" ) "-" ] ( "width" | "height" )
55+
| [ ( "min" | "max" ) "-" ] ( "inline" | "block" ) "-" "size"
56+
| "left"
57+
| "right"
58+
| "top"
59+
| "bottom"
60+
| "inset" [ "-" ( "inline" | "block" ) [ "-" ( "start" | "end" ) ] ]
61+
| "flex" [ "-" ( "direction" | "grow" | "shrink" | "basis" | "flow" | "wrap" ) ]
6662
;
6763

6864
css_property_value ->
@@ -107,4 +103,12 @@ css_class_id ->
107103
| "footer"
108104
| "aside"
109105
| "article"
106+
| ( "row" | "col" ) "-" ( "sm" | "md" | "lg" )
107+
| ( "bg" | "color" ) "-" css_named_color
108+
;
109+
110+
css_named_color ->
111+
"black"
112+
| "gray"
113+
| "white"
110114
;

packages/keybr-code/lib/syntax/lang_html_css.ts

+117-13
Original file line numberDiff line numberDiff line change
@@ -222,18 +222,90 @@ export default {
222222
alt: [
223223
"color",
224224
"box-sizing",
225-
"width",
226-
"min-width",
227-
"max-width",
228-
"inline-size",
229-
"min-inline-size",
230-
"max-inline-size",
231-
"height",
232-
"min-height",
233-
"max-height",
234-
"block-size",
235-
"min-block-size",
236-
"max-block-size",
225+
{
226+
seq: [
227+
{
228+
f: 0.5,
229+
opt: {
230+
seq: [
231+
{
232+
alt: ["min", "max"],
233+
},
234+
"-",
235+
],
236+
},
237+
},
238+
{
239+
alt: ["width", "height"],
240+
},
241+
],
242+
},
243+
{
244+
seq: [
245+
{
246+
f: 0.5,
247+
opt: {
248+
seq: [
249+
{
250+
alt: ["min", "max"],
251+
},
252+
"-",
253+
],
254+
},
255+
},
256+
{
257+
alt: ["inline", "block"],
258+
},
259+
"-size",
260+
],
261+
},
262+
"left",
263+
"right",
264+
"top",
265+
"bottom",
266+
{
267+
seq: [
268+
"inset",
269+
{
270+
f: 0.5,
271+
opt: {
272+
seq: [
273+
"-",
274+
{
275+
alt: ["inline", "block"],
276+
},
277+
{
278+
f: 0.5,
279+
opt: {
280+
seq: [
281+
"-",
282+
{
283+
alt: ["start", "end"],
284+
},
285+
],
286+
},
287+
},
288+
],
289+
},
290+
},
291+
],
292+
},
293+
{
294+
seq: [
295+
"flex",
296+
{
297+
f: 0.5,
298+
opt: {
299+
seq: [
300+
"-",
301+
{
302+
alt: ["direction", "grow", "shrink", "basis", "flow", "wrap"],
303+
},
304+
],
305+
},
306+
},
307+
],
308+
},
237309
],
238310
},
239311
css_property_value: {
@@ -288,6 +360,38 @@ export default {
288360
alt: ["#aaa", "#bbb", "#ccc", "#ddd", "#eee", "#fff"],
289361
},
290362
css_class_id: {
291-
alt: ["main", "nav", "header", "footer", "aside", "article"],
363+
alt: [
364+
"main",
365+
"nav",
366+
"header",
367+
"footer",
368+
"aside",
369+
"article",
370+
{
371+
seq: [
372+
{
373+
alt: ["row", "col"],
374+
},
375+
"-",
376+
{
377+
alt: ["sm", "md", "lg"],
378+
},
379+
],
380+
},
381+
{
382+
seq: [
383+
{
384+
alt: ["bg", "color"],
385+
},
386+
"-",
387+
{
388+
ref: "css_named_color",
389+
},
390+
],
391+
},
392+
],
393+
},
394+
css_named_color: {
395+
alt: ["black", "gray", "white"],
292396
},
293397
} as Rules;

0 commit comments

Comments
 (0)