From f508189682b6fba62e08feeb1596f682bad5fff9 Mon Sep 17 00:00:00 2001 From: tpearson Date: Wed, 24 Feb 2010 18:42:24 +0000 Subject: Added KDE3 version of PikLab git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/piklab@1095639 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- src/data/syntax_xml_generator.cpp | 231 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 231 insertions(+) create mode 100644 src/data/syntax_xml_generator.cpp (limited to 'src/data/syntax_xml_generator.cpp') diff --git a/src/data/syntax_xml_generator.cpp b/src/data/syntax_xml_generator.cpp new file mode 100644 index 0000000..9f3553e --- /dev/null +++ b/src/data/syntax_xml_generator.cpp @@ -0,0 +1,231 @@ +/*************************************************************************** + * Copyright (C) 2006 Nicolas Hadacek * + * * + * 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 generate xml files for kate highlighting +// the original syntax file was created by Alain Gibaud + +#include +#include + +const char * const DIRECTIVES[] = { +"__badram", "__config", "__idlocs", "__maxram", +"bankisel", "banksel", "cblock", "code", "cblock", "constant", "da", "data", "db", +"de", "dt", "dw", "endm", "endc", "endw", "equ", "error", "errorlevel", "extern", +"exitm", "expand", "fill", "global", "idata", "list", "local", "macro", "messg", +"noexpand", "nolist", "org", "page", "processor", "pagesel", "radix", "res", "set", +"space", "subtitle", "title", "udata", "udata_acs", "udata_ovr", "udata_shr", +"variable", "end", 0 +}; +const char * const CONDITIONNALS[] = { +"if", "else", "ifdef", "ifndef", "endif", "while", "include", "endw", "{", "}", 0 +}; +const char * const GPASM_MACROS[] = { +"addcf", "b", "bc", "bz", "bnc", "bnz", "clrc", "clrz", "setc", "setz", "movfw", +"negf", "skpc", "skpz", "skpnc", "skpnz", "subcf", "tstf", 0 +}; +const char * const CPIK_MACROS[] = { +"IBZ", "IBNZ", "IBRA", "ICALL", 0 +}; +const char * const SFRS[] = { // #### should be extracted from dev files... +"TOSU", "TOSH", "TOSL", "STKPTR", "PCLATU", "PCLATH", "PCL", "TBLPTRU", "TBLPTRH", +"TBLPTRL", "TABLAT", "PRODH", "PRODL", "INTCON", "INTCON2", "INTCON3", "INDF0", +"POSTINC0", "POSTDEC0", "PREINC0", "PLUSW0", "FSR0H", "FSR0L", "WREG", "INDF1", +"POSTINC1", "POSTDEC1", "PREINC1", "PLUSW1", "FSR1H", "FSR1L", "BSR", "INDF2", +"POSTINC2", "POSTDEC2", "PREINC2", "PLUSW2", "FSR2H", "FSR2L", "STATUS", "TMR0H", +"TMR0L", "T0CON", "OSCCON", "LVDCON", "WDTCON", "RCON", "TMR1H", "TMR1L","T1CON", +"TMR2", "PR2", "T2CON", "SSPBUF", "SSPADD", "SSPSTAT", "SSPCON1", "SSPCON2", "ADRESH", +"ADRESL", "ADCON0", "ADCON1", "ADCON2", "CCPR1H", "CCPR1L", "CCP1CON", "CCPR2H", +"CCPR2L", "CCP2CON", "PWM1CON", "ECCPAS", "CVRCON", "CMCON", "TMR3H", "TMR3L", +"T3CON", "SPBRG", "RCREG", "TXREG", "TXSTA", "RCSTA", "EEADR", "EEDATA", "EECON2", +"EECON1", "IPR2", "PIR2", "PIE2", "IPR1", "PIR1", "PIE1", "OSCTUNE", "TRISE", +"TRISD", "TRISC", "TRISB", "TRISA", "LATE", "LATD", "LATC", "LATB", "LATA", +"PORTE", "PORTD", "PORTC", "PORTB", "PORTA", "TMR0", "TMR1", "OPTION_REG", 0 +}; +const char * const INSTRUCTIONS[] = { +"addlw", "addwf", "addwfc", "andlw", "andwf", "bcf", "bc", "bn", "bnc", "bnn", "bnov", +"bnz", "bz", "bov", "bra", "bsf", "btfsc", "btg", "btfss", "call", "clrf", "clrw", +"clrwdt", "comf", "cpfseq", "cpfsgt", "cpfslt", "daw", "decf", "decfsz", "dcfsnz", +"goto", "incf", "incfsz", "infsnz", "iorlw", "iorwf", "lfsr", "movf", "movff", +"movlb", "movlw", "movwf", "mullw", "mulwf", "negf", "nop", "option", "pop", "push", +"rcall", "reset", "retfie", "retlw", "rlcf", "rlncf", "rrcf", "rrncf", "return", "rlf", +"rrf", "setf", "sleep", "sublw", "subfwb", "subwf", "subwfb", "swapf", "tstfsz", +"tris", "tblrd", "tblwt", "xorlw", "xorwf", 0 +}; + +QTextStream *initFile(QFile &file) +{ + if ( !file.open(IO_WriteOnly) ) qFatal("Cannot create \"%s\".", file.name().latin1()); + QTextStream *s = new QTextStream(&file); + (*s) << "" << endl; + (*s) << "" << endl; + (*s) << "" << endl; + return s; +} + +void addList(QTextStream &s, const QString &name, const char * const *items, bool upper) +{ + s << " " << endl; + for (uint i=0; items[i]; i++) { + s << " " << items[i] << ""; + if (upper) s << "" << QString(items[i]).upper() << ""; + s << endl; + }; + s <<" " << endl; +} + +void addCommon(QTextStream &s) +{ + addList(s, "instructions", INSTRUCTIONS, true); + s << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << endl; + s << " " << endl; + s << " " << endl; +} + +void addAsmContexts(QTextStream &s) +{ + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; +} + +void endFile(QTextStream &s) +{ + s << " " << endl; + s << "" << endl; + s << endl; + s << "" << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << " " << endl; + s << "" << endl; + s << endl; + s << "" << endl; +} + +int main(int, char **) +{ + QFile afile("asm-pic.xml"); + QTextStream *s = initFile(afile); + (*s) << "" << endl; + (*s) << endl; + (*s) << "" << endl; + addList(*s, "directives", DIRECTIVES, true); + addList(*s, "conditionnal", CONDITIONNALS, false); + addList(*s, "gpasm_macro", GPASM_MACROS, false); + addList(*s, "cpik_macro", CPIK_MACROS, false); + addList(*s, "sfrs", SFRS, false); + addCommon(*s); + addAsmContexts(*s); + endFile(*s); + + QFile cfile("coff-pic.xml"); + s = initFile(cfile); + (*s) << "" << endl; + (*s) << endl; + (*s) << "" << endl; + addCommon(*s); + (*s) << " " << endl; + (*s) << " " << endl; + (*s) << " " << endl; + (*s) << " " << endl; + (*s) << " " << endl; + (*s) << " " << endl; + (*s) << " " << endl; + (*s) << " " << endl; + (*s) << " " << endl; + (*s) << " " << endl; + (*s) << " " << endl; + (*s) << " " << endl; + (*s) << " " << endl; + (*s) << " " << endl; + (*s) << " " << endl; + (*s) << " " << endl; + (*s) << " " << endl; + (*s) << " " << endl; + (*s) << " " << endl; + (*s) << " " << endl; + (*s) << " " << endl; + (*s) << " " << endl; + (*s) << " " << endl; + (*s) << " " << endl; + (*s) << " " << endl; + (*s) << " " << endl; + (*s) << " " << endl; + endFile(*s); +} -- cgit v1.2.3