Thread: [Japi-cvs] SF.net SVN: japi: [613] tools/cstyle/trunk/src/net/sf/japi/cstyle
Status: Beta
Brought to you by:
christianhujer
|
From: <chr...@us...> - 2007-09-23 20:11:04
|
Revision: 613
http://japi.svn.sourceforge.net/japi/?rev=613&view=rev
Author: christianhujer
Date: 2007-09-23 13:11:01 -0700 (Sun, 23 Sep 2007)
Log Message:
-----------
Committing current intermediate work of cstyle. This is unfinnished. Committing due to source directory layout refactoring.
Modified Paths:
--------------
tools/cstyle/trunk/src/net/sf/japi/cstyle/CStyle.java
Added Paths:
-----------
tools/cstyle/trunk/src/net/sf/japi/cstyle/AbstractParser.java
tools/cstyle/trunk/src/net/sf/japi/cstyle/ByteParser.java
tools/cstyle/trunk/src/net/sf/japi/cstyle/CharParser.java
tools/cstyle/trunk/src/net/sf/japi/cstyle/LineEndingParser.java
tools/cstyle/trunk/src/net/sf/japi/cstyle/LineParser.java
tools/cstyle/trunk/src/net/sf/japi/cstyle/ParseEvent.java
tools/cstyle/trunk/src/net/sf/japi/cstyle/ParseListener.java
tools/cstyle/trunk/src/net/sf/japi/cstyle/Parser.java
Added: tools/cstyle/trunk/src/net/sf/japi/cstyle/AbstractParser.java
===================================================================
--- tools/cstyle/trunk/src/net/sf/japi/cstyle/AbstractParser.java (rev 0)
+++ tools/cstyle/trunk/src/net/sf/japi/cstyle/AbstractParser.java 2007-09-23 20:11:01 UTC (rev 613)
@@ -0,0 +1,69 @@
+/*
+ * CStyle is a program that verifies that a C source code adheres to a specific coding convention.
+ * Copyright (C) 2007 Christian Hujer
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package net.sf.japi.cstyle;
+
+import javax.swing.event.EventListenerList;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Useful baseclass for Parsers.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public abstract class AbstractParser implements Parser {
+
+ /** The listeners. */
+ private final EventListenerList listeners = new EventListenerList();
+
+ /** Create an AbstractParser. */
+ protected AbstractParser() {
+ }
+
+ /** {@inheritDoc} */
+ public void addParseListener(@NotNull final ParseListener listener) {
+ listeners.add(ParseListener.class, listener);
+ }
+
+ /** {@inheritDoc} */
+ public void removeParseListener(@NotNull final ParseListener listener) {
+ listeners.remove(ParseListener.class, listener);
+ }
+
+ /** {@inheritDoc} */
+ public void init() {
+ }
+
+ /** {@inheritDoc} */
+ public void reset() {
+ }
+
+ /** {@inheritDoc} */
+ public void end() {
+ }
+
+ /** Fires a ParseEvent.
+ * @param event ParseEvent to fire
+ */
+ protected void fireParseEvent(@NotNull final ParseEvent event) {
+ for (final ParseListener listener : listeners.getListeners(ParseListener.class)) {
+ listener.parseEvent(event);
+ }
+ }
+
+} // class AbstractParser
Property changes on: tools/cstyle/trunk/src/net/sf/japi/cstyle/AbstractParser.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
Added: tools/cstyle/trunk/src/net/sf/japi/cstyle/ByteParser.java
===================================================================
--- tools/cstyle/trunk/src/net/sf/japi/cstyle/ByteParser.java (rev 0)
+++ tools/cstyle/trunk/src/net/sf/japi/cstyle/ByteParser.java 2007-09-23 20:11:01 UTC (rev 613)
@@ -0,0 +1,33 @@
+/*
+ * CStyle is a program that verifies that a C source code adheres to a specific coding convention.
+ * Copyright (C) 2007 Christian Hujer
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package net.sf.japi.cstyle;
+
+/**
+ * Parser at byte level.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public interface ByteParser extends Parser {
+
+ /** Processes a byte.
+ * @param b Byte to process.
+ */
+ void process(byte b);
+
+} // interface ByteParser
Property changes on: tools/cstyle/trunk/src/net/sf/japi/cstyle/ByteParser.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
Modified: tools/cstyle/trunk/src/net/sf/japi/cstyle/CStyle.java
===================================================================
--- tools/cstyle/trunk/src/net/sf/japi/cstyle/CStyle.java 2007-09-23 19:49:21 UTC (rev 612)
+++ tools/cstyle/trunk/src/net/sf/japi/cstyle/CStyle.java 2007-09-23 20:11:01 UTC (rev 613)
@@ -42,7 +42,7 @@
/** Main program.
* @param args Command line arguments.
*/
- public static void main(final String... args) {
+ public static void main(@NotNull final String... args) {
ArgParser.simpleParseAndRun(new CStyle(), args);
}
Added: tools/cstyle/trunk/src/net/sf/japi/cstyle/CharParser.java
===================================================================
--- tools/cstyle/trunk/src/net/sf/japi/cstyle/CharParser.java (rev 0)
+++ tools/cstyle/trunk/src/net/sf/japi/cstyle/CharParser.java 2007-09-23 20:11:01 UTC (rev 613)
@@ -0,0 +1,33 @@
+/*
+ * CStyle is a program that verifies that a C source code adheres to a specific coding convention.
+ * Copyright (C) 2007 Christian Hujer
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package net.sf.japi.cstyle;
+
+/**
+ * Parser at char level.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public interface CharParser extends Parser {
+
+ /** Processes a character.
+ * @param c Character to process.
+ */
+ void process(char c);
+
+} // interface CharParser
Property changes on: tools/cstyle/trunk/src/net/sf/japi/cstyle/CharParser.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
Added: tools/cstyle/trunk/src/net/sf/japi/cstyle/LineEndingParser.java
===================================================================
--- tools/cstyle/trunk/src/net/sf/japi/cstyle/LineEndingParser.java (rev 0)
+++ tools/cstyle/trunk/src/net/sf/japi/cstyle/LineEndingParser.java 2007-09-23 20:11:01 UTC (rev 613)
@@ -0,0 +1,75 @@
+/*
+ * CStyle is a program that verifies that a C source code adheres to a specific coding convention.
+ * Copyright (C) 2007 Christian Hujer
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package net.sf.japi.cstyle;
+
+import org.jetbrains.annotations.NotNull;
+
+/** A LineEndingParser can verify whether a file has the correct line ending.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public class LineEndingParser extends AbstractParser implements CharParser {
+
+ /** Whether the previous character was {@link #ASCII_CR}. */
+ private boolean carriageReturn;
+
+ /** ASCII control character CR (Carriage Return). */
+ private static final int ASCII_CR = 0x0D;
+
+ /** ASCII control character LF (Line Feed). */
+ private static final int ASCII_LF = 0x0A;
+
+ /** The desired NewLine. */
+ @NotNull private NewLine desiredNewLine;
+
+ /** {@inheritDoc} */
+ public void process(final char b) {
+ final boolean lineFeed = b == ASCII_LF;
+ final NewLine newLineFound;
+ newLineFound = lineFeed
+ ? carriageReturn ? NewLine.DOS : NewLine.UNIX
+ : carriageReturn ? NewLine.MAC : null;
+ carriageReturn = b == ASCII_CR;
+ if (newLineFound != null && newLineFound != desiredNewLine) {
+ // TODO
+ }
+ }
+
+ /** Set the desired NewLine.
+ * @param desiredNewLine Desired NewLine.
+ */
+ public void setDesiredNewLine(@NotNull final NewLine desiredNewLine) {
+ this.desiredNewLine = desiredNewLine;
+ }
+
+ /** Newline state. */
+ public enum NewLine {
+
+ /** CRLF DOS NewLine. */
+ DOS,
+
+ /** LF UNIX NewLine. */
+ UNIX,
+
+ /** CR MAC NewLine. */
+ MAC
+
+ } // enum NewLine
+
+} // class LineEndingParser
Property changes on: tools/cstyle/trunk/src/net/sf/japi/cstyle/LineEndingParser.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
Added: tools/cstyle/trunk/src/net/sf/japi/cstyle/LineParser.java
===================================================================
--- tools/cstyle/trunk/src/net/sf/japi/cstyle/LineParser.java (rev 0)
+++ tools/cstyle/trunk/src/net/sf/japi/cstyle/LineParser.java 2007-09-23 20:11:01 UTC (rev 613)
@@ -0,0 +1,33 @@
+/*
+ * CStyle is a program that verifies that a C source code adheres to a specific coding convention.
+ * Copyright (C) 2007 Christian Hujer
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package net.sf.japi.cstyle;
+
+/**
+ * Parser at line level.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public interface LineParser extends Parser {
+
+ /** Processes a line.
+ * @param line Line to process.
+ */
+ void parse(String line);
+
+} // interface LineParser
Property changes on: tools/cstyle/trunk/src/net/sf/japi/cstyle/LineParser.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
Added: tools/cstyle/trunk/src/net/sf/japi/cstyle/ParseEvent.java
===================================================================
--- tools/cstyle/trunk/src/net/sf/japi/cstyle/ParseEvent.java (rev 0)
+++ tools/cstyle/trunk/src/net/sf/japi/cstyle/ParseEvent.java 2007-09-23 20:11:01 UTC (rev 613)
@@ -0,0 +1,27 @@
+package net.sf.japi.cstyle;
+
+import java.util.EventObject;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Event for information while parsing.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public class ParseEvent extends EventObject {
+
+ /**
+ * Constructs a ParseEvent.
+ * @param source The Parser on which the Event initially occurred.
+ * @throws IllegalArgumentException if source is <code>null</code>.
+ */
+ public ParseEvent(@NotNull final Parser source) {
+ super(source);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Parser getSource() {
+ return (Parser) super.getSource();
+ }
+
+}// class ParseEvent
Property changes on: tools/cstyle/trunk/src/net/sf/japi/cstyle/ParseEvent.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
Added: tools/cstyle/trunk/src/net/sf/japi/cstyle/ParseListener.java
===================================================================
--- tools/cstyle/trunk/src/net/sf/japi/cstyle/ParseListener.java (rev 0)
+++ tools/cstyle/trunk/src/net/sf/japi/cstyle/ParseListener.java 2007-09-23 20:11:01 UTC (rev 613)
@@ -0,0 +1,36 @@
+/*
+ * CStyle is a program that verifies that a C source code adheres to a specific coding convention.
+ * Copyright (C) 2007 Christian Hujer
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package net.sf.japi.cstyle;
+
+import java.util.EventListener;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Created by IntelliJ IDEA.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public interface ParseListener extends EventListener {
+
+ /** Report an event during parsing.
+ * @param event Event that's reported.
+ */
+ void parseEvent(@NotNull ParseEvent event);
+
+} // interface ParseListener
Property changes on: tools/cstyle/trunk/src/net/sf/japi/cstyle/ParseListener.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
Added: tools/cstyle/trunk/src/net/sf/japi/cstyle/Parser.java
===================================================================
--- tools/cstyle/trunk/src/net/sf/japi/cstyle/Parser.java (rev 0)
+++ tools/cstyle/trunk/src/net/sf/japi/cstyle/Parser.java 2007-09-23 20:11:01 UTC (rev 613)
@@ -0,0 +1,48 @@
+/*
+ * CStyle is a program that verifies that a C source code adheres to a specific coding convention.
+ * Copyright (C) 2007 Christian Hujer
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package net.sf.japi.cstyle;
+
+import org.jetbrains.annotations.NotNull;
+
+/** A Parser processes a file character by character.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public interface Parser {
+
+ /** Initializes this Parser. */
+ void init();
+
+ /** Resets this parser. */
+ void reset();
+
+ /** Tells this parser that the stream it was parsing came to its regular end. */
+ void end();
+
+ /** Registers a ParseListener with this Parser.
+ * @param listener ParseListener to register.
+ */
+ void addParseListener(@NotNull ParseListener listener);
+
+ /** Removes a ParseListener from this Parser.
+ * @param listener ParseListener to unregister.
+ */
+ void removeParseListener(@NotNull ParseListener listener);
+
+} // interface Parser
Property changes on: tools/cstyle/trunk/src/net/sf/japi/cstyle/Parser.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|