Fivemac con xCode

Fivemac con xCode

Postby mastintin » Tue Jun 25, 2013 9:01 am

Lo que teníamos de realizado a nivel de colorear la sintaxis de fivemac para xCode 3 quedó roto con la version xCode 4 ,despues de investigar mucho y no conseguir nada y gracias un ejemplo realizado con lua , he conseguido inyectar el código suficiente para que aunque manualmente y de una manera inicial ( aun falta por mejorar mucho el archivo de lenguaje ) coloree el código y detecte los anidamientos de los bloques de funcion , if , for , while .
dejo aqui los dos archivos que tengo por ahora y que funcionan. Se trata de colocarlos en un mismo directorio y con un terminal ejecutar el archivo sh , y listo , se habre el xcode -> menu-> escoger el color como fivemac para ese archivo y listo.
archivo :installFivemac.sh
Code: Select all  Expand view

#!/bin/bash

#  Created by Manuel Alvarez.
#  Last edited 6/18/2013
#  Copyright 2013 Manuel Alvarez. All rights reserved.
#
# Updates Xcode and to support fivemac language for editing
#

set -e

# Assumes Xcode 4+.
XCODE_MAJOR_VERSION=`xcodebuild -version | awk 'NR == 1 {print substr($2,1,1)}'`
if [ "$XCODE_MAJOR_VERSION" -lt "4" ]; then
        echo "Xcode 4.x not found."
        exit 1
fi

# Path were this script is located
SCRIPT_PATH="$(dirname "$BASH_SOURCE")"

# Set up path for PlistBuddy helper application which can add elements to Plist files
PLISTBUDDY=/usr/libexec/PlistBuddy

# install (all contained in Xcode.app)
DVTFOUNDATION_PATH="/Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/Resources/"

# Create Plist file of additional languages to add to 'DVTFoundation.xcplugindata'
cat >AdditionalLanguages.plist <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Xcode.SourceCodeLanguage.Fivemac</key>
    <dict>
        <key>languageSpecification</key>
        <string>xcode.lang.fivemac</string>
        <key>fileDataType</key>
        <array>
            <dict>
                <key>identifier</key>
                <string>com.apple.xcode.fivemac-source</string>
            </dict>
        </array>
        <key>id</key>
        <string>Xcode.SourceCodeLanguage.Fivemac</string>
        <key>point</key>
        <string>Xcode.SourceCodeLanguage</string>
        <key>languageName</key>
        <string>Fivemac</string>
        <key>version</key>
        <string>1.0</string>
        <key>documentationAbbreviation</key>
        <string>fivemac</string>               
        <key>conformsTo</key>
        <array>
            <dict>
                <key>identifier</key>
                <string>Xcode.SourceCodeLanguage.Generic</string>
            </dict>
        </array>
        <key>name</key>
        <string>Fivemac Language</string>
    </dict>
</dict>
</plist>
EOF

# Backup
cp "$DVTFOUNDATION_PATH/DVTFoundation.xcplugindata" "$DVTFOUNDATION_PATH/DVTFoundation.xcplugindata.bak"

# Now merge in the additonal languages to DVTFoundation.xcplugindata
$PLISTBUDDY "$DVTFOUNDATION_PATH/DVTFoundation.xcplugindata"  -c 'Merge AdditionalLanguages.plist plug-in:extensions'

# Get rid of the AdditionalLanguages.plist since it was just temporary
rm -f AdditionalLanguages.plist

# Copy in the xclangspecs for the languages (assumes in same directory as this shell script)
cp "$SCRIPT_PATH/Fivemac.xclangspec" "$DVTFOUNDATION_PATH"

# Remove any cached Xcode plugins
rm -rf /private/var/folders/*/*/*/com.apple.DeveloperTools/*/Xcode/PlugInCache.xcplugincache

echo "Syntax coloring must be manually selected from the Editor - Syntax Coloring menu in Xcode."





Archivo Fivemac.xclangspec

Code: Select all  Expand view

(
    {
        Identifier = "xcode.lang.fivemac.preprocessor";
        Syntax = {
            Start = "#";
            EscapeChar = "\\";
            End = "\n";
            StartAtBOL = YES;
            Tokenizer = "xcode.lang.fivemac.preprocessor.lexer";
            IncludeRules = (
                "xcode.lang.fivemac.preprocessor.include",
            );
            Type = "xcode.syntax.preprocessor";
        };
    },
    {
        Identifier = "xcode.lang.fivemac.preprocessor.systemIncludeString";
        Syntax = {
            Start = "<";
            End = ">";
            AltEnd = "\n";
            Type = "xcode.syntax.string";
        };
    },
    {
        Identifier = "xcode.lang.fivemac.preprocessor.lexer";
        Syntax = {
            IncludeRules = (
                "xcode.lang.comment.degenerate",
                "xcode.lang.comment.headerdoc",
                "xcode.lang.comment.headerdoc.star",
                "xcode.lang.comment.headerdoc.singleline.bang",
                "xcode.lang.comment.headerdoc.singleline.slash",
                "xcode.lang.comment",
                "xcode.lang.comment.singleline",
                "xcode.lang.string",
                "xcode.lang.character",
                "xcode.lang.number",
                "xcode.lang.fivemac.preprocessor.identifier",
            );
        };
    },
    {
        Identifier = "xcode.lang.fivemac.preprocessor.identifier";
        Syntax = {
            StartChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";
            Chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
            Words = (
                assert,
                define,
                elif,
                else,
                endif,
                error,
                if,
                ifdef,
                ifndef,
                import,
                include,
                "include_next",
                line,
                pragma,
                unassert,
                undef,
                warning,
            );
            Type = "xcode.syntax.preprocessor.keyword";
            AltType = "xcode.syntax.preprocessor.identifier";
        };
    },
    {
        Identifier = "xcode.lang.fivemac.preprocessor.include.lexer";
        Syntax = {
            IncludeRules = (
                "xcode.lang.comment.degenerate",
                "xcode.lang.comment.headerdoc",
                "xcode.lang.comment.headerdoc.star",
                "xcode.lang.comment.headerdoc.singleline.bang",
                "xcode.lang.comment.headerdoc.singleline.slash",
                "xcode.lang.comment",
                "xcode.lang.comment.singleline",
                "xcode.lang.string",
                "xcode.lang.character",
                "xcode.lang.number",
                "xcode.lang.fivemac.logicals",
            );
        };
    },
    {
        Identifier = "xcode.lang.fivemac.preprocessor.include";
        Syntax = {
            Tokenizer = "xcode.lang.fivemac.preprocessor.include.lexer";
            Rules = (
                include,
                "xcode.lang.string",
            );
            Type = "xcode.syntax.preprocessor.include";
        };
    },
    {
        Identifier = "xcode.lang.fivemac.identifier";
        Syntax = {
            CaseSensitive = NO;
            StartChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_[";
            Chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_?[]";
            Words = (
                and,
                break,
                do,
                else,
                elseif,
                end,
                enddo,
                endif,
                for,
                function,
                if,
                in,
                local,
                not,
                or,
                repeat,
                return,
                then,
                until,
                while,
                assert,
                error,
                next,
                select,
                valtype,
                unpack,
                str,
                substr,
                len,
                lower,
                upper,
                abs,
                close,
                fwrite,
                fclose,
              fread,
                fseek,
                date,
                default,
            );
            Type = "xcode.syntax.keyword";
            AltType = "xcode.syntax.identifier";
        };
    },
    {
        Identifier = "xcode.lang.lau.interestingOperators";
        Syntax = {
            Words = (
                "::",
                ".",
                ":",
            );
            Type = "xcode.syntax.plain";
        };
    },
    {
        Identifier = "xcode.lang.fivemac";
        Description = "Fivemac Coloring";
        BasedOn = "xcode.lang.simpleColoring";
        IncludeInMenu = YES;
        Name = Fivemac;
        Syntax = {
            Tokenizer = "xcode.lang.fivemac.lexer.toplevel";
            IncludeRules = (
                "xcode.lang.fivemac.module",
                "xcode.lang.fivemac.class",
                "xcode.lang.fivemac.function",
                "xcode.lang.fivemac.block",
                "xcode.lang.fivemac.block.if",
                "xcode.lang.fivemac.block.while",
                "xcode.lang.fivemac.block.repeat",
                "xcode.lang.fivemac.block.for",
                "xcode.lang.fivemac.bracketexpr",
                "xcode.lang.fivemac.parenexpr",
                "xcode.lang.fivemac.logicals",
            );
            Type = "xcode.syntax.plain";
        };
    },
    {
        Identifier = "xcode.lang.fivemac.lexer";
        Syntax = {
            IncludeRules = (
                "xcode.lang.fivemac.comment",
                "xcode.lang.fivemac.comment.singleline",
                "xcode.lang.string",
                "xcode.lang.string.fivemac0",
                "xcode.lang.string.fivemac1",
                "xcode.lang.string.fivemac2",
                "xcode.lang.string.fivemac3",
                "xcode.lang.string.fivemac4",
                "xcode.lang.string.fivemac5",
                "xcode.lang.character",
                "xcode.lang.fivemac.identifier",
                "xcode.lang.number",
                "xcode.lang.lau.interestingOperators",
            );
        };
    },
    {
        Identifier = "xcode.lang.fivemac.lexer.toplevel";
        Syntax = {
            IncludeRules = (
                "xcode.lang.fivemac.comment",
                "xcode.lang.fivemac.comment.singleline",
                "xcode.lang.string",
                "xcode.lang.string.fivemac0",
                "xcode.lang.string.fivemac1",
                "xcode.lang.string.fivemac2",
                "xcode.lang.string.fivemac3",
                "xcode.lang.string.fivemac4",
                "xcode.lang.string.fivemac5",
                "xcode.lang.character",
                "xcode.lang.fivemac.module.declarator",
                "xcode.lang.fivemac.class.declarator",
                "xcode.lang.fivemac.function.declarator",
                "xcode.lang.fivemac.identifier",
                "xcode.lang.number",
            );
        };
    },
    {
        Identifier = "xcode.lang.string.fivemac0";
        Syntax = {
            Start = "[[";
            End = "]]";
            Type = "xcode.syntax.string";
        };
    },
    {
        Identifier = "xcode.lang.string.fivemac1";
        Syntax = {
            Start = "\"";
            End = "\"";
            Type = "xcode.syntax.string";
        };
    },
    {
        Identifier = "xcode.lang.string.fivemac2";
        Syntax = {
            Start = "'";
            End = "'";
            Type = "xcode.syntax.string";
        };
    },
    {
        Identifier = "xcode.lang.string.fivemac3";
        Syntax = {
            Start = "[===[";
            End = "]===]";
            Type = "xcode.syntax.string";
        };
    },
    {
        Identifier = "xcode.lang.string.fivemac4";
        Syntax = {
            Start = "[====[";
            End = "]====]";
            Type = "xcode.syntax.string";
        };
    },
    {
        Identifier = "xcode.lang.string.fivemac5";
        Syntax = {
            Start = "[=====[";
            End = "]=====]";
            Type = "xcode.syntax.string";
        };
    },
    {
        Identifier = "xcode.lang.fivemac.logicals";
        Syntax = {
            StartChars = "=*-+/:,.";
            CaseSensitive = NO;
            Chars = "=*-+/:,.notadrf";
            Words = (
                "=",
                "+",
                "-",
                "*",
                "/",
                "==",
                "<",
                ">",
                "=>",
                "<=",
                ".not.",
                ".and.",
                ".or.",
                ".t.",
                ".f.",
            );
            Type = "xcode.syntax.character";
        };
    },
    {
        Identifier = "xcode.lang.fivemac.module";
        Syntax = {
            Tokenizer = "xcode.lang.fivemac.lexer.toplevel";
            Start = "xcode.lang.fivemac.module.declarator";
            End = end;
            Foldable = YES;
            Recursive = YES;
            IncludeRules = (
                "xcode.lang.fivemac.class",
                "xcode.lang.fivemac.function",
            );
            Type = "xcode.syntax.definition.class";
        };
    },
    {
        Identifier = "xcode.lang.fivemac.module.declarator";
        Syntax = {
            Tokenizer = "xcode.lang.fivemac.lexer";
            Rules = (
                require,
                "xcode.lang.fivemac.identifier",
            );
            Type = "xcode.syntax.name.partial";
        };
    },
    {
        Identifier = "xcode.lang.fivemac.class";
        Syntax = {
            Tokenizer = "xcode.lang.fivemac.lexer.toplevel";
            Start = "xcode.lang.fivemac.class.declarator";
            End = end;
            Foldable = YES;
            Recursive = YES;
            IncludeRules = (
                "xcode.lang.fivemac.function",
            );
            Type = "xcode.syntax.definition.class";
        };
    },
    {
        Identifier = "xcode.lang.fivemac.class.declarator";
        Syntax = {
            Tokenizer = "xcode.lang.fivemac.lexer";
            Rules = (
                class,
                "xcode.lang.fivemac.identifier",
                "xcode.lang.fivemac.superclass?",
            );
            Type = "xcode.syntax.name.partial";
        };
    },
    {
        Identifier = "xcode.lang.fivemac.superclass";
        Syntax = {
            Tokenizer = "xcode.lang.fivemac.lexer";
            Rules = (
                "->",
                "xcode.lang.fivemac.identifier",
            );
        };
    },
    {
        Identifier = "xcode.lang.fivemac.function";
        Syntax = {
            Tokenizer = "xcode.lang.fivemac.lexer.toplevel";
            "CaseSensitive " = NO;
            Start = "xcode.lang.fivemac.function.declarator";
            End = return;
            Foldable = YES;
            Recursive = YES;
            IncludeRules = (
                "xcode.lang.fivemac.block",
                "xcode.lang.fivemac.block.if",
                "xcode.lang.fivemac.block.while",
                "xcode.lang.fivemac.block.repeat",
                "xcode.lang.fivemac.block.for",
                "xcode.lang.fivemac.bracketexpr",
                "xcode.lang.fivemac.parenexpr",
            );
            Type = "xcode.syntax.definition.function";
        };
    },
    {
        Identifier = "xcode.lang.fivemac.function.declarator";
        Syntax = {
            Tokenizer = "xcode.lang.fivemac.lexer";
            Rules = (
                function,
                "xcode.lang.fivemac.function.name",
            );
        };
    },
    {
        Identifier = "xcode.lang.fivemac.function.name";
        Syntax = {
            Tokenizer = "xcode.lang.fivemac.lexer";
            Rules = (
                "xcode.lang.fivemac.identifier",
                "xcode.lang.fivemac.function.name.more?",
            );
            Type = "xcode.syntax.name.partial";
        };
    },
    {
        Identifier = "xcode.lang.fivemac.function.name.more";
        Syntax = {
            Tokenizer = "xcode.lang.fivemac.lexer";
            Rules = (
                ".",
                "xcode.lang.fivemac.identifier",
            );
            Type = "xcode.syntax.name.partial";
        };
    },
    {
        Identifier = "xcode.lang.fivemac.block";
        Syntax = {
            Tokenizer = "xcode.lang.fivemac.lexer";
            Start = "{";
            End = "}";
            Foldable = YES;
            Recursive = YES;
            IncludeRules = (
                "xcode.lang.fivemac.block.if",
                "xcode.lang.fivemac.block.while",
                "xcode.lang.fivemac.block.repeat",
                "xcode.lang.fivemac.block.for",
                "xcode.lang.fivemac.bracketexpr",
                "xcode.lang.fivemac.parenexpr",
            );
        };
    },
    {
        Identifier = "xcode.lang.fivemac.block.if";
        Syntax = {
            Tokenizer = "xcode.lang.fivemac.lexer";
            Start = if;
            End = endif;
            Foldable = YES;
            CaseSensitive = NO;
            Recursive = YES;
            StartAtBOL = YES;
            IncludeRules = (
                "xcode.lang.fivemac.block",
                "xcode.lang.fivemac.block.while",
                "xcode.lang.fivemac.block.repeat",
                "xcode.lang.fivemac.block.for",
                "xcode.lang.fivemac.bracketexpr",
                "xcode.lang.fivemac.parenexpr",
            );
        };
    },
    {
        Identifier = "xcode.lang.fivemac.block.while";
        Syntax = {
            Tokenizer = "xcode.lang.fivemac.lexer";
            Start = do;
            End = enddo;
            Foldable = YES;
            CaseSensitive = NO;
            Recursive = YES;
            StartAtBOL = YES;
            IncludeRules = (
                "xcode.lang.fivemac.block",
                "xcode.lang.fivemac.block.if",
                "xcode.lang.fivemac.block.repeat",
                "xcode.lang.fivemac.block.for",
                "xcode.lang.fivemac.bracketexpr",
                "xcode.lang.fivemac.parenexpr",
            );
        };
    },
    {
        Identifier = "xcode.lang.fivemac.block.repeat";
        Syntax = {
            Tokenizer = "xcode.lang.fivemac.lexer";
            Start = repeat;
            End = until;
            Foldable = YES;
            Recursive = YES;
            StartAtBOL = YES;
            IncludeRules = (
                "xcode.lang.fivemac.block",
                "xcode.lang.fivemac.block.if",
                "xcode.lang.fivemac.block.while",
                "xcode.lang.fivemac.block.for",
                "xcode.lang.fivemac.bracketexpr",
                "xcode.lang.fivemac.parenexpr",
            );
        };
    },
    {
        Identifier = "xcode.lang.fivemac.block.for";
        Syntax = {
            Tokenizer = "xcode.lang.fivemac.lexer";
            Start = for;
            End = next;
            Foldable = YES;
            CaseSensitive = NO;
            Recursive = YES;
            StartAtBOL = YES;
            IncludeRules = (
                "xcode.lang.fivemac.block",
                "xcode.lang.fivemac.block.if",
                "xcode.lang.fivemac.block.while",
                "xcode.lang.fivemac.block.repeat",
                "xcode.lang.fivemac.bracketexpr",
                "xcode.lang.fivemac.parenexpr",
            );
        };
    },
    {
        Name = {
            Identifier = "xcode.lang.fivemac.default";
            Syntax = {
                Tokenizer = "xcode.lang.fivemac.lexer";
                Rules = (
                    default,
                    "xcode.lang.fivemac.block",
                );
                Type = "xcode.syntax.preprocessor";
            };
        };
        Identifier = "xcode.lang.fivemac.parenexpr";
        Syntax = {
            Tokenizer = "xcode.lang.fivemac.lexer";
            Start = "(";
            End = ")";
            Recursive = YES;
            IncludeRules = (
                "xcode.lang.fivemac.bracketexpr",
            );
        };
    },
    {
        Identifier = "xcode.lang.fivemac.bracketexpr";
        Syntax = {
            Tokenizer = "xcode.lang.fivemac.lexer";
            Start = "[";
            End = "]";
            Recursive = YES;
            IncludeRules = (
                "xcode.lang.fivemac.parenexpr",
            );
        };
    },
    {
        Identifier = "xcode.lang.fivemac.comment";
        Syntax = {
            Start = "/*";
            End = "*/";
            Foldable = YES;
            IncludeRules = (
                "xcode.lang.url",
                "xcode.lang.url.mail",
                "xcode.lang.comment.mark",
            );
            Type = "xcode.syntax.comment";
        };
    },
    {
        Identifier = "xcode.lang.fivemac.comment.singleline";
        Syntax = {
            Start = "//";
            End = "\n";
            IncludeRules = (
                "xcode.lang.url",
                "xcode.lang.url.mail",
                "xcode.lang.comment.mark",
            );
            Type = "xcode.syntax.comment";
        };
    },
    {
        Identifier = "xcode.lang.fivemac.comment1";
        Syntax = {
            Start = "--[=[";
            End = "]=]";
            Foldable = YES;
            IncludeRules = (
                "xcode.lang.url",
                "xcode.lang.url.mail",
                "xcode.lang.comment.mark",
            );
            Type = "xcode.syntax.comment";
        };
    },
)

 
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: Fivemac con xCode

Postby Antonio Linares » Tue Jun 25, 2013 2:34 pm

Manuel,

muy bueno, muchas gracias :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41205
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveMac / FivePhone (iPhone, iPad)

Who is online

Users browsing this forum: No registered users and 2 guests