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)
;
|