Add syntax definition for Elm language to syntax-highlighting
ClosedPublic

Authored by bonghyunkim on Mar 1 2019, 7:56 AM.

Details

Summary

This commit adds syntax definition for Elm language to syntax-highlighting. This commit adds syntax definition for Elm language to KDE/syntax-highlighting. Elm is a purely functional language of ML family that compiles to Javascript for creating web browser-based graphical user interfaces.

Diff Detail

Repository
R216 Syntax Highlighting
Lint
Lint Skipped
Unit
Unit Tests Skipped
bonghyunkim created this revision.Mar 1 2019, 7:56 AM
Restricted Application added projects: Kate, Frameworks. · View Herald TranscriptMar 1 2019, 7:56 AM
Restricted Application added subscribers: kde-frameworks-devel, kwrite-devel. · View Herald Transcript
bonghyunkim requested review of this revision.Mar 1 2019, 7:56 AM

Could you elaborate what Elm is used for?
Also, could you please provide a small test file (also MIT licensed) that we can use for unit testing?

bonghyunkim planned changes to this revision.Mar 4 2019, 7:37 AM

Could you elaborate what Elm is used for?
Also, could you please provide a small test file (also MIT licensed) that we can use for unit testing?

I created 'highlight.elm' in autotests/input/ folder, as per guide on https://github.com/KDE/syntax-highlighting, but couldn't follow the instruction.
I tried running make && make test, but the root folder didn't have Makefile, and when I ran it inside autotests/input/, it failed to run because of
missing Makefile.in. What should I do next?

bonghyunkim updated this revision to Diff 53180.Mar 5 2019, 7:08 AM
bonghyunkim edited the summary of this revision. (Show Details)

I created 'highlight.elm' in autotests/input/ folder, as per guide on https://github.com/KDE/syntax-highlighting, but couldn't follow the instruction.
I tried running make && make test, but the root folder didn't have Makefile, and when I ran it inside autotests/input/, it failed to run because of the missing Makefile.in.

nibags added a subscriber: nibags.Mar 5 2019, 7:12 AM

Use: cmake ./ && make to compile

bonghyunkim planned changes to this revision.Mar 12 2019, 4:52 AM

I finally got some time to install various dependencies to set up the tests and run them, but three tests keep failing. They are: folding_test, testhighlighter_test, htmlhighlighter_test.

The error message is always same:

FAIL!  : HTMLHighlighterTest::testHighlight(highlight.elm) 'ref.open(QIODevice::ReadOnly | QIODevice::Text)' returned FALSE. ()
   Loc: [/home/lambda/Documents/Projects/syntax-highlighting/autotests/test-config.h(65)]

I tried giving all privileges through chmod 777, changing file name and extension to that of another language that already works, i.e. test.hs, and making the file an empty file by deleting all texts in it.
None worked, and I couldn't google how to handle this error.

I'm running Ubuntu 18.04, cmake 3.13.4, Make 4.1, and QT 5.10.0.

Is there any further advice?

It isn't possible to compile, because the elm.xml file has multiple issues :(
The script "data/schema/validatehl.sh" serves to verify the XML files:

cd syntax-highlighting/data/schema/
./validatehl.sh ../syntax/elm.xml

Output:

../syntax/elm.xml:3: element language: Schemas validity error : Element 'language', attribute 'version': '1.0' is not a valid value of the atomic type 'xs:integer'.
../syntax/elm.xml:43: element WordDetect: Schemas validity error : Element 'WordDetect', attribute 'string': The attribute 'string' is not allowed.
../syntax/elm.xml:43: element WordDetect: Schemas validity error : Element 'WordDetect': The attribute 'String' is required but missing.
../syntax/elm.xml:84: element StringDetect: Schemas validity error : Element 'StringDetect', attribute 'char': The attribute 'char' is not allowed.
../syntax/elm.xml:84: element StringDetect: Schemas validity error : Element 'StringDetect': The attribute 'String' is required but missing.
../syntax/elm.xml:86: element context: Schemas validity error : Element 'context': The attribute 'lineEndContext' is required but missing.
../syntax/elm.xml:93: element context: Schemas validity error : Element 'context': The attribute 'lineEndContext' is required but missing.
../syntax/elm.xml:102: element context: Schemas validity error : Element 'context': The attribute 'lineEndContext' is required but missing.
../syntax/elm.xml:114: element itemDatas: Schemas validity error : Element 'itemDatas': This element is not expected. Expected is ( context ).
../syntax/elm.xml:4: element highlighting: Schemas validity error : Element 'highlighting': Missing child element(s). Expected is ( itemDatas ).
../syntax/elm.xml fails to validate

For example: </contexts> (line 133) must be placed before <itemDatas> and dsHexVal isn't a valid default style (use dsBaseN, look here). By solving it, maybe compile everything well.

Also, I'm not sure if Elm should be in the "Sources" or "Script" section (maybe not so relevant).
To compile, try installing: libkf5syntaxhighlighting-dev qtbase5-dev libqt5xmlpatterns5-dev perl (although installing the first installs the rest)

Sorry that I forgot to update the actual diff file - this should compile now!

bonghyunkim updated this revision to Diff 55475.Apr 5 2019, 2:10 PM

It's been about three weeks since I've uploaded last diff but haven't received any response since then. I've made another diff against the most recent commit of KDE/syntax-highlighting (508be5417e67dc697166e72bde49a1fbf59c23a8), but I doubt anything would have changed. I'm including the logs of outputs from compiling the project and running tests. Failure seems to start from Qt library but I'm not sure what's going on here.

I'm running Ubuntu 18.04, cmake 3.13.4, Make 4.1, and QT 5.10.0.

Log for compiling and overall tests: Link
Log for HTMLHighlighterTest Link
Log for TestHighlighterTest Link
Log for FoldingTest Link

nibags added a comment.Apr 5 2019, 8:20 PM
  • Running make test, after adding a new file to autotests/input, will throw an error in "testhighlighter_test", "htmlhighlighter_test" and "folding_test", since references haven't been updated. It's normal to show you that error.
  • You have to execute the autotest/update-reference-data.sh script to update the references (new files will be copied to folding, html & reference). When running again make test everything will work fine.
  • Having the outdated base shouldn't be a problem, although you can update it to the last master with:
git fetch
git rebase --onto origin/master master
  • Also: in the log you used cmake ./, I recommend using another folder to avoid problems when updating the diff (because I wrote that you compiled with "cmake ./"): cd ./syntax-highlighting/build && cmake ../
dhaumann accepted this revision.Apr 6 2019, 7:30 AM

It's also ok to generate the reference data om first commit. Often highlighting contributors do not have a compiling KSyntaxHighlighting git around, so this is a significant hurdle. I'd be fine we commit this as is and add the reference ourselves.

@nibags: could you do so? Would be great!

This revision is now accepted and ready to land.Apr 6 2019, 7:30 AM
nibags updated this revision to Diff 55583.Apr 6 2019, 5:58 PM
  • Ok! Adding autotest references
nibags closed this revision.Apr 6 2019, 5:59 PM