Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 58 lines (48 sloc) 2.491 kB
9d64d20 @colomon Directories.
authored
1 use v6;
2
3 grammar ISO_10303_21::Grammar
4 {
5 token space { " " }
6 token digit { <[0..9]> }
7 token lower { <[a..z]> }
f64f79a @colomon Add some of the higher level things.
authored
8 token upper { <[A..Z]> | '_' }
9d64d20 @colomon Directories.
authored
9 token special { '!' | '"' | '*' | '$' | '%' | '&' | '.' | '#'
10 | '+' | ',' | '-' | '(' | ')' | '?' | '/' | ':'
11 | ';' | '<' | '=' | '>' | '@' | '[' | ']' | '{'
12 | '|' | '}' | '^' | '`' | '~' }
13 token reverse_solidus { '\\' }
14 token apostrophe { "'" }
15 token character { <space> | <digit> | <lower> | <upper> | <special> | <reverse_solidus> | <apostrophe> }
f0797bf @colomon Some tokens!
authored
16
17 token standard_keyword { <upper> [ <upper> | <digit> ]* }
18 token user_defined_keyword { '!' <upper> [ <upper> | <digit> ]* }
19 token keyword { <user_defined_keyword> | <standard_keyword> }
20
21 token sign { '+' | '-' }
fde2d1f @colomon Lots of tokens!
authored
22 token integer { <sign>? <digit> <digit>* }
23 token real { <sign>? <digit>+ '.' <digit>* [ 'E' <sign>? <digit>+ ]? }
24
25 token non_q_char { <special> | <digit> | <space> | <lower> | <upper> }
26 # next one needs control directive too.
27 token string { "'" [ <non_q_char> | [<apostrophe> ** 2] | [<reverse_solidus> ** 2] ]* "'" }
28
29 token entity_instance_name { '#' <digit>+ }
30 token enumeration { '.' <upper> [ <upper> | <digit> ]* '.' }
31
32 token hex { <[0..9]> | <[A..F]> }
33 token binary { '"' <[0..3]> <hex>* '"' }
f64f79a @colomon Add some of the higher level things.
authored
34
35 token parameter { <typed_parameter> | <untyped_parameter> | <omitted_parameter> }
36 token omitted_parameter { '*' }
37 token untyped_parameter { '$' | <real> | <integer> | <string>
38 | <entity_instance_name> | <enumeration> | <binary> | <list_of_parameters> }
39 rule typed_parameter { <keyword> '(' <parameter> ')' }
40 rule list_of_parameters { '(' [ <parameter> ]* % [ ',' ] ')' }
41 rule parameter_list { [ <parameter> ]+ % [ ',' ] }
42
43 rule header_entity { <keyword> '(' <parameter_list> ')' ';' }
44 rule header_entity_list { <header_entity>+ }
45 rule header_section {
46 "HEADER;"
47 <header_entity> <header_entity> <header_entity>
48 <header_entity_list>?
49 "ENDSEC;"
50 }
f56b998 @colomon Rules and tests for recognizing entities.
authored
51
52 rule simple_record { <keyword> '(' <parameter_list>? ')' }
53 rule subsuper_record { '(' <simple_record>+ ')' }
54 rule simple_entity_instance { <entity_instance_name> '=' <simple_record> ';' }
55 rule complex_entity_instance { <entity_instance_name> '=' <subsuper_record> ';' }
56 rule entity_instance { <simple_entity_instance> | <complex_entity_instance> }
57
9d64d20 @colomon Directories.
authored
58 }
Something went wrong with that request. Please try again.