File: binary.g

package info (click to toggle)
antlr 2.7.7%2Bdfsg-7
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 9,888 kB
  • sloc: java: 54,649; cs: 12,537; makefile: 8,945; cpp: 7,359; pascal: 5,273; sh: 4,337; python: 4,301; lisp: 1,969; xml: 220; lex: 192; ansic: 127
file content (34 lines) | stat: -rw-r--r-- 590 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// This file is part of PyANTLR. See LICENSE.txt for license
// details..........Copyright (C) Wolfgang Haefelinger, 2004.
//
// $Id$

options {
    language=Python;
}

class binary_p extends Parser;

file:	(	sh:SHORT	{ print sh.getText()           }
		|	st:STRING	{ print "\"" + st.getText() + "\"" }
		)+
	;

class binary_l extends Lexer;
options {
	charVocabulary = '\u0000'..'\u00FF';
}

SHORT
	:	'\0' high:. lo:.
		{
            v = (ord(high)<<8) + ord(lo)
            $setText(str(v))
		}
	;

STRING
	:	'\1'!	// begin string (discard)
		( ~'\2' )*
		'\2'!	// end string (discard)
	;