@@ -44,6 +44,7 @@ module.exports = grammar(
4444 $ . label_line ,
4545 $ . memory_offset ,
4646 $ . source_location ,
47+ '...' ,
4748 ) ,
4849
4950 header : $ => seq ( $ . file_path , ":" , "file" , "format" , $ . identifier ) ,
@@ -94,18 +95,28 @@ module.exports = grammar(
9495 optional ( $ . file_offset ) ,
9596 )
9697 ) ,
97- instruction : $ => / [ ^ \n # < ] + / ,
98- bad_instruction : $ => "(bad)" ,
98+ instruction : _ => / ( [ ^ \n # ; < ] | # - ? \d + ) + / ,
99+ bad_instruction : _ => "(bad)" ,
99100
100101 comment : $ => seq (
101- "#" ,
102+ choice ( "#" , ';' ) ,
102103 choice (
103104 $ . _comment_with_address ,
104105 $ . _comment_with_label ,
105106 ) ,
106107 ) ,
107108
108- _comment_with_label : $ => seq ( $ . address , $ . code_location , optional ( $ . file_offset ) ) ,
109+ _comment_with_label : $ => choice (
110+ seq (
111+ '(' ,
112+ optional ( seq ( alias ( / [ ^ \d , ] [ ^ , ] + / , $ . instruction ) , ',' ) ) ,
113+ $ . address ,
114+ $ . code_location ,
115+ optional ( $ . file_offset ) ,
116+ ')'
117+ ) ,
118+ seq ( $ . address , $ . code_location , optional ( $ . file_offset ) ) ,
119+ ) ,
109120 _comment_with_address : $ => $ . hexadecimal ,
110121
111122 code_location : $ => seq (
@@ -117,11 +128,11 @@ module.exports = grammar(
117128
118129 label_line : $ => seq ( alias ( $ . _label_identifier , $ . label ) , ":" ) ,
119130
120- hexadecimal : $ => / 0 [ x h ] [ 0 - 9 a - f A - F ] + / ,
121- byte : $ => / [ 0 - 9 a - f A - F ] { 2 } / ,
131+ hexadecimal : _ => / 0 [ x h ] [ 0 - 9 a - f A - F ] + / ,
132+ byte : _ => / [ 0 - 9 a - f A - F ] { 2 , 4 } / ,
122133 machine_code_bytes : $ => space_separated1 ( $ . byte ) ,
123134
124- address : $ => / [ 0 - 9 a - f A - F ] + / ,
135+ address : _ => / [ 0 - 9 a - f A - F ] + / ,
125136
126137 file_offset : $ => seq ( "(" , "File" , "Offset:" , $ . hexadecimal , ")" ) ,
127138
@@ -131,15 +142,15 @@ module.exports = grammar(
131142 ":" ,
132143 ) ,
133144
134- integer : $ => / \d + / ,
145+ integer : _ => / \d + / ,
135146
136147 // TODO: Support windows paths, later. Also make sure Linux paths work
137- file_path : $ => / [ \/ \w \- \. \+ ] + / ,
148+ file_path : _ => / [ \/ \w \- \. \+ ] + / ,
138149
139- _label_identifier : $ => / [ A - Z a - z . @ _ ] [ A - Z a - z 0 - 9 . @ _ $ -\( \) ] * / , // Test this, later
140- identifier : $ => / [ ^ \n ] + / ,
150+ _label_identifier : _ => / [ A - Z a - z . @ _ ] [ A - Z a - z 0 - 9 . @ _ $ -\( \) ] * / , // Test this, later
151+ identifier : _ => / [ ^ \n ] + / ,
141152
142- _section_name : $ => / [ ^ : ] + / ,
153+ _section_name : _ => / [ ^ : ] + / ,
143154 }
144155 }
145156)
0 commit comments