Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 85 lines (71 sloc) 3.651 kb
9d64d20b »
2012-09-03 Directories.
1 use v6;
f7b55cde »
2012-10-05 Make the file-reading tests (and new script) remove comments before p…
2 # use Grammar::Tracer;
9d64d20b »
2012-09-03 Directories.
3
4 grammar ISO_10303_21::Grammar
5 {
6 token space { " " }
7 token digit { <[0..9]> }
8 token lower { <[a..z]> }
f64f79a1 »
2012-09-03 Add some of the higher level things.
9 token upper { <[A..Z]> | '_' }
9d64d20b »
2012-09-03 Directories.
10 token special { '!' | '"' | '*' | '$' | '%' | '&' | '.' | '#'
11 | '+' | ',' | '-' | '(' | ')' | '?' | '/' | ':'
12 | ';' | '<' | '=' | '>' | '@' | '[' | ']' | '{'
13 | '|' | '}' | '^' | '`' | '~' }
14 token reverse_solidus { '\\' }
15 token apostrophe { "'" }
bf7d340a »
2012-10-09 Change many uses of eg, <digit> to <.digit> so that we aren't saving …
16 token character { <.space> | <.digit> | <.lower> | <.upper> | <.special> | <.reverse_solidus> | <.apostrophe> }
f0797bfc »
2012-09-03 Some tokens!
17
bf7d340a »
2012-10-09 Change many uses of eg, <digit> to <.digit> so that we aren't saving …
18 token standard_keyword { <.upper> [ <.upper> | <.digit> ]* }
19 token user_defined_keyword { '!' <.upper> [ <.upper> | <.digit> ]* }
f0797bfc »
2012-09-03 Some tokens!
20 token keyword { <user_defined_keyword> | <standard_keyword> }
21
22 token sign { '+' | '-' }
bf7d340a »
2012-10-09 Change many uses of eg, <digit> to <.digit> so that we aren't saving …
23 token integer { <.sign>? <.digit> <.digit>* }
24 token real { <.sign>? <.digit>+ '.' <.digit>* [ 'E' <.sign>? <.digit>+ ]? }
fde2d1f0 »
2012-09-03 Lots of tokens!
25
ff14d08f »
2012-09-04 Add the control directives to strings.
26 token hex_one { <hex> <hex> }
27 token hex_two { <hex_one> <hex_one> }
28 token hex_four { <hex_two> <hex_two> }
bf7d340a »
2012-10-09 Change many uses of eg, <digit> to <.digit> so that we aren't saving …
29 token page { <.reverse_solidus> 'S' <.reverse_solidus> <character> }
30 token alphabet { <.reverse_solidus> 'P' <upper> <.reverse_solidus> <character> }
31 token end_extended { <.reverse_solidus> 'X0' <.reverse_solidus> }
32 token extended2 { <.reverse_solidus> 'X2' <.reverse_solidus> <hex_two>+ <.end_extended> }
33 token extended4 { <.reverse_solidus> 'X4' <.reverse_solidus> <hex_four>+ <.end_extended> }
34 token arbitrary { <.reverse_solidus> 'X' <.reverse_solidus> <hex_one> }
ff14d08f »
2012-09-04 Add the control directives to strings.
35 token control_directive { <page> | <alphabet> | <extended2> | <extended4> | <arbitrary> }
36
bf7d340a »
2012-10-09 Change many uses of eg, <digit> to <.digit> so that we aren't saving …
37 token non_q_char { <.special> | <.digit> | <.space> | <.lower> | <.upper> }
ff14d08f »
2012-09-04 Add the control directives to strings.
38 token string { "'" [ <non_q_char> | [<apostrophe> ** 2] | [<reverse_solidus> ** 2] | <control_directive> ]* "'" }
fde2d1f0 »
2012-09-03 Lots of tokens!
39
bf7d340a »
2012-10-09 Change many uses of eg, <digit> to <.digit> so that we aren't saving …
40 token entity_instance_name { '#' <.digit>+ }
41 token enumeration { '.' <.upper> [ <.upper> | <.digit> ]* '.' }
fde2d1f0 »
2012-09-03 Lots of tokens!
42
43 token hex { <[0..9]> | <[A..F]> }
44 token binary { '"' <[0..3]> <hex>* '"' }
f64f79a1 »
2012-09-03 Add some of the higher level things.
45
46 token parameter { <typed_parameter> | <untyped_parameter> | <omitted_parameter> }
47 token omitted_parameter { '*' }
48 token untyped_parameter { '$' | <real> | <integer> | <string>
49 | <entity_instance_name> | <enumeration> | <binary> | <list_of_parameters> }
50 rule typed_parameter { <keyword> '(' <parameter> ')' }
51 rule list_of_parameters { '(' [ <parameter> ]* % [ ',' ] ')' }
52 rule parameter_list { [ <parameter> ]+ % [ ',' ] }
53
54 rule header_entity { <keyword> '(' <parameter_list> ')' ';' }
55 rule header_entity_list { <header_entity>+ }
56 rule header_section {
57 "HEADER;"
58 <header_entity> <header_entity> <header_entity>
59 <header_entity_list>?
60 "ENDSEC;"
61 }
f56b9984 »
2012-09-04 Rules and tests for recognizing entities.
62
63 rule simple_record { <keyword> '(' <parameter_list>? ')' }
64 rule subsuper_record { '(' <simple_record>+ ')' }
65 rule simple_entity_instance { <entity_instance_name> '=' <simple_record> ';' }
66 rule complex_entity_instance { <entity_instance_name> '=' <subsuper_record> ';' }
67 rule entity_instance { <simple_entity_instance> | <complex_entity_instance> }
8c25fdba »
2012-09-04 Parse a full file!
68
69 rule data_section {
70 "DATA" [ '(' <parameter_list> ')']? ';'
71 <entity_instance>*
72 "ENDSEC" ';'
73 }
74
75 rule exchange_file {
76 "ISO-10303-21;"
77 <header_section> <data_section>+
78 "END-ISO-10303-21;"
79 }
2770655c »
2012-10-05 Add LooseGrammar, improved but slow tests.
80 }
81
82 grammar ISO_10303_21::LooseGrammar is ISO_10303_21::Grammar {
83 token non_q_char { <special> | <digit> | <space> | <lower> | <upper> | \v }
84 }
Something went wrong with that request. Please try again.