Creating Language Plugin not used for new language

Roland Plüss roland at rptd.ch
Mon Jul 16 17:40:07 BST 2018


I tried now getting this Lexer and some simple rules working using
KDevelop-PG-QT. I'm struggling hard with it since the documentation is
there but lacking in the details required to get it sucessfully implemented.

My main problem right now seems to be UTF8. I'm using a simple
test-script consisting of the typical header-GPL-notice, some empty
lines and one declaration line. The problem is that the
header-GPL-notice contains my name, and thus a UTF8 only character. The
Lexer seems to be thrown off my one character there resulting in the
lexing not working correctly. I have no clue though how I can fix this.
I'm using a code similar to this one:

ParseJob::run(...)
...
ParseSession session;
session.setContents( QString::fromUtf8( contents().contents ) );

Then inside the ParserSession:

void ParseSession::setContents(...)
    pContentsBytes = contents.toUtf8();
    pLexer = new Lexer( KDevPG::QByteArrayIterator(
pContentsBytes.constBegin() ) );

I tried different combinations of fromUt8, fromLocal8Bit, toLocal8Bit,
toUtf8 but it does not work.

How can I get the source files as UTF8 encoded in a way the generated
Lexer gives me correct token indices for tokenString() to work correctly?

On 07/11/2018 05:12 PM, Friedrich W. H. Kossebau wrote:
> Hi Roland,
>
> Am Mittwoch, 11. Juli 2018, 16:54:44 CEST schrieb Roland Pluess:
>> I'm trying to make a language plugin for my own language I used in projects
> I applaud such efforts :)
>
>> What else do I need to to to get my language plugin being used for source
>> files with the right extension? There exists no mime-type for this language
>> in the system obviously so can this be done by using file extensions?
> IIRC no, the related code relies on QMimeDatabase having the related MIME type 
> definition (which at least on Linux/*BSD uses xdg's sharedmimeinfo).
>
> But compare the things done for initial CUDA/OpenCL support by installing 
> matching custom MIME type definitions at the end of
> https://cgit.kde.org/kdevelop.git/tree/plugins/clang/CMakeLists.txt
> --- 8< ---
> install(FILES kdevclang.xml DESTINATION ${KDE_INSTALL_MIMEDIR})
> update_xdg_mimetypes(${KDE_INSTALL_MIMEDIR})
> --- 8< ---
>
> with the MIME type definitions being
> https://cgit.kde.org/kdevelop.git/tree/plugins/clang/kdevclang.xml
>
> See 
> https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html for more info about how to write your own MIME type 
> definitions as usable with xdg's sharedmimeinfo.
>
> For that custom type definition installation to work, you will need 
> SharedMimeInfo macros included, so have this in the toplevel CMakeLists.txt:
> --- 8< ---
> find_package(SharedMimeInfo REQUIRED)
> --- 8< ---
>
> That should get you started hopefully. Such definition should also allow 
> having proper things elsewhere, like matching icons in the file manager/dialog 
> (once added) :)
>
> Cheers
> Friedrich
>
>


-- 
Mit freundlichen Grüssen
Plüss Roland

Leader und Head Programmer
- Game: Epsylon ( http://www.indiedb.com/games/epsylon )
- Game Engine: Drag[en]gine ( http://www.indiedb.com/engines/dragengine
, http://dragengine.rptd.ch/wiki )
- Sowie verschiedene Blender Export-Skripts und Game-Tools

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: OpenPGP digital signature
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20180716/16859f05/attachment.sig>


More information about the KDevelop-devel mailing list