source: other-projects/rsyntax-textarea/devel-packages/jflex-1.4.3/examples/binary/binary.flex@ 25584

Last change on this file since 25584 was 25584, checked in by davidb, 12 years ago

Initial cut an a text edit area for GLI that supports color syntax highlighting

File size: 1.9 KB
Line 
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2 * Copyright (C) 1998-2009 Gerwin Klein <[email protected]> *
3 * All rights reserved. *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License. See the file *
7 * COPYRIGHT for more information. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License along *
15 * with this program; if not, write to the Free Software Foundation, Inc., *
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
17 * *
18 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
19
20
21import java.io.*;
22
23%%
24
25%class BinaryLexer
26%8bit
27
28%int
29
30%{
31 public static void main(String [] argv) {
32 for (int i = 0; i < argv.length; i++) {
33 try {
34 System.out.print("["+argv[i]+"] is ");
35 BinaryLexer l = new BinaryLexer(new StraightStreamReader(new FileInputStream(argv[i])));
36 l.yylex();
37 }
38 catch (Exception e) {
39 e.printStackTrace(System.out);
40 System.exit(1);
41 }
42 }
43 }
44%}
45
46magic = \xCA \xFE \xBA \xBE
47
48%%
49
50{magic} [^]+ { System.out.println("a class file"); }
51
52[^]+ { System.out.println("not a class file"); }
Note: See TracBrowser for help on using the repository browser.