Skip to content

Commit 9d8318a

Browse files
committed
update tvkl.gram
1 parent d83a5cd commit 9d8318a

1 file changed

Lines changed: 36 additions & 25 deletions

File tree

tvkl/grammar/tvkl.gram

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,40 @@
11
# =============================================================================
2-
# TVKL GRAMMAR SPECIFICATION
3-
#
4-
# This document defines the formal EBNF for the Terminal Virtual Keyboard Layout.
5-
#
6-
# SYMBOLS:
7-
# ::= Production
8-
# | Alternation (OR)
9-
# [] Optional (0 or 1)
10-
# {}* Zero or more repetitions
11-
# {}+ One or more repetitions
12-
# "" Literal string
2+
# TVKL — Terminal Virtual Keyboard Layout
3+
# =============================================================================
4+
#
5+
# -----------------------------------------------------------------------------
6+
# SYMBOL LEGEND (EBNF META-SYNTAX)
7+
# -----------------------------------------------------------------------------
8+
#
9+
# ::= Production rule definition
10+
# | Alternation (logical OR)
11+
# {} Zero or more repetitions
12+
# [] Optional (0 or 1 occurrence)
13+
# "" Literal terminal string
14+
#
15+
# =============================================================================
16+
# FORMAL GRAMMAR
1317
# =============================================================================
1418

15-
tvkl ::= declaration* EOF
16-
declaration ::= assign | line*
17-
assign ::= ident "=" value
18-
ident ::= "#" name
19-
value ::= number | rgb
20-
rgb ::= "rgb(" num "," num "," num ")"
21-
line ::= ":" "|" { item (, item)* "|" }* "-"
22-
item ::= ( quoted_name | name ) [ attr_decl ]
23-
quoted_name ::= ( "'" name "'" ) | ( '"' name '"' )
24-
attr_decl ::= "[" { attr }+ "]"
19+
tvkl ::= { declaration } EOF ;
20+
declaration ::= assign
21+
| line ;
22+
assign ::= ident "=" value ;
23+
ident ::= "#" name ;
24+
value ::= number
25+
| color ;
26+
color ::= "@" "(" number "," number "," number ")" ;
27+
line ::= ":" "|" { item "|" } "-" ;
28+
item ::= key_name [ attr_decl ] ;
29+
key_name ::= quoted_name
30+
| name ;
31+
quoted_name ::= "'" name "'"
32+
| '"' name '"' ;
33+
attr_decl ::= "[" attr { "," attr } "]" ;
2534
attr ::= number
26-
name ::= { ? any character ? }+ ;
27-
number ::= "$" num
28-
num ::= [0-9]+
29-
35+
name ::= name_char { name_char } ;
36+
name_char ::= ? any character except whitespace,
37+
number ::= "$" num ;
38+
num ::= digit { digit } ;
39+
digit ::= "0" | "1" | "2" | "3" | "4"
40+
| "5" | "6" | "7" | "8" | "9" ;

0 commit comments

Comments
 (0)