From 69b52f003b5942cc36d2b92e6deaef779fc2f128 Mon Sep 17 00:00:00 2001 From: Sergio Gutierrez Date: Tue, 22 Mar 2016 12:24:46 +0100 Subject: [PATCH] First working version --- LICENSE => LICENSE.txt | 0 README.md | 24 +- antlr4/BufferedTokenStream.py | 325 + antlr4/CommonTokenFactory.py | 84 + antlr4/CommonTokenStream.py | 110 + antlr4/FileStream.py | 57 + antlr4/InputStream.py | 133 + antlr4/IntervalSet.py | 295 + antlr4/LL1Analyzer.py | 195 + antlr4/Lexer.py | 341 + antlr4/ListTokenSource.py | 139 + antlr4/Parser.py | 575 ++ antlr4/ParserInterpreter.py | 187 + antlr4/ParserRuleContext.py | 188 + antlr4/PredictionContext.py | 647 ++ antlr4/Recognizer.py | 166 + antlr4/RuleContext.py | 232 + antlr4/StdinStream.py | 46 + antlr4/Token.py | 184 + antlr4/Utils.py | 64 + antlr4/__init__.py | 21 + antlr4/atn/ATN.py | 147 + antlr4/atn/ATNConfig.py | 149 + antlr4/atn/ATNConfigSet.py | 239 + antlr4/atn/ATNDeserializationOptions.py | 46 + antlr4/atn/ATNDeserializer.py | 540 + antlr4/atn/ATNSimulator.py | 70 + antlr4/atn/ATNState.py | 283 + antlr4/atn/ATNType.py | 37 + antlr4/atn/LexerATNSimulator.py | 586 ++ antlr4/atn/LexerAction.py | 316 + antlr4/atn/LexerActionExecutor.py | 160 + antlr4/atn/ParserATNSimulator.py | 1518 +++ antlr4/atn/PredictionMode.py | 544 + antlr4/atn/SemanticContext.py | 360 + antlr4/atn/Transition.py | 277 + antlr4/atn/__init__.py | 1 + antlr4/dfa/DFA.py | 150 + antlr4/dfa/DFASerializer.py | 99 + antlr4/dfa/DFAState.py | 154 + antlr4/dfa/__init__.py | 1 + antlr4/error/DiagnosticErrorListener.py | 131 + antlr4/error/ErrorListener.py | 97 + antlr4/error/ErrorStrategy.py | 719 ++ antlr4/error/Errors.py | 181 + antlr4/error/__init__.py | 1 + antlr4/tree/Chunk.py | 26 + antlr4/tree/ParseTreeMatch.py | 145 + antlr4/tree/ParseTreePattern.py | 94 + antlr4/tree/ParseTreePatternMatcher.py | 392 + antlr4/tree/RuleTagToken.py | 74 + antlr4/tree/TokenTagToken.py | 72 + antlr4/tree/Tree.py | 191 + antlr4/tree/Trees.py | 132 + antlr4/tree/__init__.py | 0 antlr4/xpath/XPath.py | 346 + antlr4/xpath/__init__.py | 1 + art/logo.png | Bin 0 -> 296868 bytes grammar/PBXProj.g4 | 809 ++ grammar/PBXProj.tokens | 212 + grammar/PBXProjLexer.py | 939 ++ grammar/PBXProjLexer.tokens | 212 + grammar/PBXProjListener.py | 1275 +++ grammar/PBXProjParser.py | 8975 +++++++++++++++++ grammar/__init__.py | 0 kin/__init__.py | 0 kin/args_parser.py | 26 + kin/kin.py | 32 + kin/kin_error_listener.py | 9 + kin/verifier.py | 20 + logo.sketch | Bin 0 -> 679936 bytes setup.cfg | 2 + setup.py | 16 + tests/__init__.py | 0 tests/ko/001.out | 1 + tests/ko/001.pbxproj | 697 ++ tests/ok/advance.56412ec.project.pbxproj | 1882 ++++ tests/ok/afnetworking.c8e5ce2.project.pbxproj | 1512 +++ tests/ok/charts.8eaba34.project.pbxproj | 1697 ++++ tests/ok/criollo.b1e014c.project.pbxproj | 937 ++ tests/ok/dwifft.05d449a.project.pbxproj | 427 + .../dznemptydataset.d3ab4e0.project.pbxproj | 296 + ...njectionpluginlite.f6d6387.project.pbxproj | 417 + tests/ok/masonry.b88578c.project.pbxproj | 529 + .../mjrefreshexample.3b41316.project.pbxproj | 767 ++ tests/ok/peekpop.c27c05e.project.pbxproj | 434 + .../ok/reactivecocoa.4384610.project.pbxproj | 3235 ++++++ tests/ok/sdwebimage.07fe1f0.project.pbxproj | 1692 ++++ .../sptpersistencache.cfbe4f8.project.pbxproj | 619 ++ tests/ok/v2exswift.53049f1.project.pbxproj | 845 ++ tests/ok/weixin.17aeced.project.pbxproj | 1655 +++ tests/ok/yocelsius.09b4cb7.project.pbxproj | 1443 +++ tests/tester.py | 46 + 93 files changed, 43948 insertions(+), 2 deletions(-) rename LICENSE => LICENSE.txt (100%) create mode 100644 antlr4/BufferedTokenStream.py create mode 100644 antlr4/CommonTokenFactory.py create mode 100644 antlr4/CommonTokenStream.py create mode 100644 antlr4/FileStream.py create mode 100644 antlr4/InputStream.py create mode 100644 antlr4/IntervalSet.py create mode 100644 antlr4/LL1Analyzer.py create mode 100644 antlr4/Lexer.py create mode 100644 antlr4/ListTokenSource.py create mode 100644 antlr4/Parser.py create mode 100644 antlr4/ParserInterpreter.py create mode 100644 antlr4/ParserRuleContext.py create mode 100644 antlr4/PredictionContext.py create mode 100644 antlr4/Recognizer.py create mode 100644 antlr4/RuleContext.py create mode 100644 antlr4/StdinStream.py create mode 100644 antlr4/Token.py create mode 100644 antlr4/Utils.py create mode 100644 antlr4/__init__.py create mode 100644 antlr4/atn/ATN.py create mode 100644 antlr4/atn/ATNConfig.py create mode 100755 antlr4/atn/ATNConfigSet.py create mode 100644 antlr4/atn/ATNDeserializationOptions.py create mode 100644 antlr4/atn/ATNDeserializer.py create mode 100644 antlr4/atn/ATNSimulator.py create mode 100644 antlr4/atn/ATNState.py create mode 100644 antlr4/atn/ATNType.py create mode 100644 antlr4/atn/LexerATNSimulator.py create mode 100644 antlr4/atn/LexerAction.py create mode 100644 antlr4/atn/LexerActionExecutor.py create mode 100755 antlr4/atn/ParserATNSimulator.py create mode 100644 antlr4/atn/PredictionMode.py create mode 100644 antlr4/atn/SemanticContext.py create mode 100644 antlr4/atn/Transition.py create mode 100644 antlr4/atn/__init__.py create mode 100644 antlr4/dfa/DFA.py create mode 100644 antlr4/dfa/DFASerializer.py create mode 100644 antlr4/dfa/DFAState.py create mode 100644 antlr4/dfa/__init__.py create mode 100644 antlr4/error/DiagnosticErrorListener.py create mode 100644 antlr4/error/ErrorListener.py create mode 100644 antlr4/error/ErrorStrategy.py create mode 100644 antlr4/error/Errors.py create mode 100644 antlr4/error/__init__.py create mode 100644 antlr4/tree/Chunk.py create mode 100644 antlr4/tree/ParseTreeMatch.py create mode 100644 antlr4/tree/ParseTreePattern.py create mode 100644 antlr4/tree/ParseTreePatternMatcher.py create mode 100644 antlr4/tree/RuleTagToken.py create mode 100644 antlr4/tree/TokenTagToken.py create mode 100644 antlr4/tree/Tree.py create mode 100644 antlr4/tree/Trees.py create mode 100644 antlr4/tree/__init__.py create mode 100644 antlr4/xpath/XPath.py create mode 100644 antlr4/xpath/__init__.py create mode 100644 art/logo.png create mode 100644 grammar/PBXProj.g4 create mode 100644 grammar/PBXProj.tokens create mode 100644 grammar/PBXProjLexer.py create mode 100644 grammar/PBXProjLexer.tokens create mode 100644 grammar/PBXProjListener.py create mode 100644 grammar/PBXProjParser.py create mode 100644 grammar/__init__.py create mode 100644 kin/__init__.py create mode 100644 kin/args_parser.py create mode 100755 kin/kin.py create mode 100644 kin/kin_error_listener.py create mode 100644 kin/verifier.py create mode 100644 logo.sketch create mode 100644 setup.cfg create mode 100644 setup.py create mode 100644 tests/__init__.py create mode 100644 tests/ko/001.out create mode 100644 tests/ko/001.pbxproj create mode 100644 tests/ok/advance.56412ec.project.pbxproj create mode 100644 tests/ok/afnetworking.c8e5ce2.project.pbxproj create mode 100644 tests/ok/charts.8eaba34.project.pbxproj create mode 100644 tests/ok/criollo.b1e014c.project.pbxproj create mode 100644 tests/ok/dwifft.05d449a.project.pbxproj create mode 100644 tests/ok/dznemptydataset.d3ab4e0.project.pbxproj create mode 100644 tests/ok/injectionpluginlite.f6d6387.project.pbxproj create mode 100644 tests/ok/masonry.b88578c.project.pbxproj create mode 100644 tests/ok/mjrefreshexample.3b41316.project.pbxproj create mode 100644 tests/ok/peekpop.c27c05e.project.pbxproj create mode 100644 tests/ok/reactivecocoa.4384610.project.pbxproj create mode 100644 tests/ok/sdwebimage.07fe1f0.project.pbxproj create mode 100644 tests/ok/sptpersistencache.cfbe4f8.project.pbxproj create mode 100644 tests/ok/v2exswift.53049f1.project.pbxproj create mode 100644 tests/ok/weixin.17aeced.project.pbxproj create mode 100644 tests/ok/yocelsius.09b4cb7.project.pbxproj create mode 100644 tests/tester.py diff --git a/LICENSE b/LICENSE.txt similarity index 100% rename from LICENSE rename to LICENSE.txt diff --git a/README.md b/README.md index 6be5336..8d938c8 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,22 @@ -# SPBXPV -Simple PBXProj Verifier +![logo][logo] + +# KIN + +KIN is a tool to check whether your project.pbxproj file is correct + +##Usage + +``` +usage: spbxpv.py [-h] [-v] [-t | -f FILE] + +Verifies the correctness of your project.pbxproj file + +optional arguments: + -h, --help show this help message and exit + -v, --verbose prints information on screen + -t, --test run all tests + -f FILE, --file FILE path to your project.pbxproj file +``` + + +[logo]: art/logo.png \ No newline at end of file diff --git a/antlr4/BufferedTokenStream.py b/antlr4/BufferedTokenStream.py new file mode 100644 index 0000000..fe11d21 --- /dev/null +++ b/antlr4/BufferedTokenStream.py @@ -0,0 +1,325 @@ +# +# [The "BSD license"] +# Copyright (c) 2012 Terence Parr +# Copyright (c) 2012 Sam Harwell +# Copyright (c) 2014 Eric Vergnaud +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# This implementation of {@link TokenStream} loads tokens from a +# {@link TokenSource} on-demand, and places the tokens in a buffer to provide +# access to any previous token by index. +# +#

+# This token stream ignores the value of {@link Token#getChannel}. If your +# parser requires the token stream filter tokens to only those on a particular +# channel, such as {@link Token#DEFAULT_CHANNEL} or +# {@link Token#HIDDEN_CHANNEL}, use a filtering token stream such a +# {@link CommonTokenStream}.

+from io import StringIO +from antlr4.Token import Token +from antlr4.error.Errors import IllegalStateException + +# this is just to keep meaningful parameter types to Parser +class TokenStream(object): + + pass + + +class BufferedTokenStream(TokenStream): + + def __init__(self, tokenSource): + # The {@link TokenSource} from which tokens for this stream are fetched. + self.tokenSource = tokenSource + + # A collection of all tokens fetched from the token source. The list is + # considered a complete view of the input once {@link #fetchedEOF} is set + # to {@code true}. + self.tokens = [] + + # The index into {@link #tokens} of the current token (next token to + # {@link #consume}). {@link #tokens}{@code [}{@link #p}{@code ]} should be + # {@link #LT LT(1)}. + # + #

This field is set to -1 when the stream is first constructed or when + # {@link #setTokenSource} is called, indicating that the first token has + # not yet been fetched from the token source. For additional information, + # see the documentation of {@link IntStream} for a description of + # Initializing Methods.

+ self.index = -1 + + # Indicates whether the {@link Token#EOF} token has been fetched from + # {@link #tokenSource} and added to {@link #tokens}. This field improves + # performance for the following cases: + # + #