flat assembler
Message board for the users of flat assembler.

Index > Projects and Ideas > fasmg in compiler explorer experiment

Author
Thread Post new topic Reply to topic
dosmancer



Joined: 20 Feb 2025
Posts: 36
Location: Kingdom of Sweden
dosmancer 03 Jun 2025, 18:57
There isn't anything like this yet, or is there?

I thought it'd be a cool idea. Made an experiment. I made a quick test site that works but I won't share that since security was not a priority. I added fasmg but a lot of features don't work since I have only done the minimum requirements. I am not sure how much time I'm going to spend on improving it, probably not much at least not now, so many "side quests" in life already.

I'd prefer to not host this myself or maybe I can I'm not sure. I'm open for collab, MRs and such. Maybe we could get this, or a more polished version of it, into the main compiler-explorer repo and godbolt.org site for example. To make it really good one could add syntax highlighting, keywords et cetera.

https://github.com/fredrik-hjarner/compiler-explorer-fasmg


Description:
Filesize: 82.86 KB
Viewed: 1019 Time(s)

Screenshot_20250603-202012~2 (1).png



_________________
fasm68k
Post 03 Jun 2025, 18:57
View user's profile Send private message Visit poster's website Reply with quote
dosmancer



Joined: 20 Feb 2025
Posts: 36
Location: Kingdom of Sweden
dosmancer 08 Jun 2025, 00:11
I put up a proof-of-concept site https://fasmg-experiment.ddns.net/
no bells n whistles but pretty nice to use on cellphone for short one-off experiments when a real computer is unavailable.

_________________
fasm68k
Post 08 Jun 2025, 00:11
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4249
Location: vpcmpistri
bitRAKE 08 Jun 2025, 07:48
Very nice work. Those long bus/train rides have an added dimension.
Post 08 Jun 2025, 07:48
View user's profile Send private message Visit poster's website Reply with quote
dosmancer



Joined: 20 Feb 2025
Posts: 36
Location: Kingdom of Sweden
dosmancer 08 Jun 2025, 13:50
bitRAKE wrote:
Very nice work.

Thanks.
bitRAKE wrote:
Those long bus/train rides have an added dimension.

Yea, that might be a good use case. Another one might be to share snippets of code that could be run instantly in browser. I have not tested the share functionality much so Im not sure it works.

_________________
fasm68k


Last edited by dosmancer on 08 Jun 2025, 17:34; edited 4 times in total
Post 08 Jun 2025, 13:50
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4249
Location: vpcmpistri
bitRAKE 08 Jun 2025, 16:38
Namespaces can use numerical identifiers.

We can create a similar effect as "#pragma once".

Browser caching also works, afaict.

Happy to test any functionality.

- labels change color if additional line content
- tabs are four spaces

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 08 Jun 2025, 16:38
View user's profile Send private message Visit poster's website Reply with quote
dosmancer



Joined: 20 Feb 2025
Posts: 36
Location: Kingdom of Sweden
dosmancer 08 Jun 2025, 17:54
bitRAKE wrote:
Namespaces can use numerical identifiers.

We can create a similar effect as "#pragma once".

Browser caching also works, afaict.

Happy to test any functionality.

- labels change color if additional line content
- tabs are four spaces


Testing is very helpful. and requesting features but the implementation speed with be ultra slow.

Nice to see that snippets work. Regarding syntax highlighting I had hoped that it used the same as vscode (since both Compiler Explorer and vscode use monaco editor) but they dont (vscode uses TextMate grammar and Monaco itself uses something called Monarch) so I will not improve the syntax highlighting sadly (unless I notice TextMate grammars can be easily transformed into Monarch grammar).

Also dont "rely" too much on this as I have not made any automated backups (in case of important snippets of code one does not want to lose)

_________________
fasm68k
Post 08 Jun 2025, 17:54
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4249
Location: vpcmpistri
bitRAKE 08 Jun 2025, 19:42
I'm not familiar with Monaco/Monarch but I want this as a more viable option and am willing to spend some time on it. A complete solution is impossible* as the highlighter is stateless, but some lesser featureful option should be possible.

* Dynamic directives (removecomments/retaincomments, combinelines/isolatelines, etc) and the fundamental nature of fasmg can break a stateless highlighter.
Post 08 Jun 2025, 19:42
View user's profile Send private message Visit poster's website Reply with quote
dosmancer



Joined: 20 Feb 2025
Posts: 36
Location: Kingdom of Sweden
dosmancer 08 Jun 2025, 21:36
woa. I realized there's even a noscript version available out of the box: https://fasmg-experiment.ddns.net/noscript/z/4zsner
Quote:
I'm not familiar with Monaco/Monarch but I want this as a more viable option and am willing to spend some time on it.

That makes me happy. Pleas do if you want. Yes I'd be great if this could be polished a bit more.

Seems documentation is around here:

https://github.com/compiler-explorer/compiler-explorer/blob/main/docs/AddingALanguage.md

https://microsoft.github.io/monaco-editor/monarch.html

I think this is the syntax highlighter that is in use currently: https://github.com/compiler-explorer/compiler-explorer/blob/main/static/modes/asm-mode.ts

I can take a look at the server/host-side and try to figure out how to backup and such as that's also important.

_________________
fasm68k
Post 08 Jun 2025, 21:36
View user's profile Send private message Visit poster's website Reply with quote
dosmancer



Joined: 20 Feb 2025
Posts: 36
Location: Kingdom of Sweden
dosmancer 09 Jun 2025, 19:53
Ok, now daily backups are made and they can also be restored. Restarting the host/server computer seems to work well too, everything starts as it should after reboots.

Only thing remaining host-side, at least that I can think of now, is experimenting with rebuilding compiler-explorer when the repo has been updated. Rebuidling is currently exteremly slow since the host machine only has 1GB RAM (and building requires a bit more than 3GB so is uses 2GB swap).
Post 09 Jun 2025, 19:53
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4249
Location: vpcmpistri
bitRAKE 10 Jun 2025, 00:01
bitRAKE wrote:
A complete solution is impossible
This is not entirely true as we could take the minimal approach - some perhaps prefer this as it's analygous to fasmgw editor. No effort is made to provide syntactical feedback during editing, but instead the reliance is on fasmg to pinpoint errors.

static/modes/fasmg-min-mode.ts
Code:
import * as monaco from 'monaco-editor';

monaco.languages.register({ id: 'fasmg' });

const language: monaco.languages.IMonarchLanguage = {
    syntactical: /[\!\#\&\(\)\*\+\,\-\.\/\:\;\<\=\>\?\[\\\]\`\{\|\}\~]/,
    tokenizer: {
        root: [
            [/\s+/, 'white'],
            [/;.*$/, 'comment'],
            [/('|")(?:(?!\1).|\1\1)*\1/, 'string'],
            [/@syntactical/, 'invalid'],

            // Float / scientific formats
            [/\d(?:[\d_'])*(?:(?:(?:\.[\d_']*\d)?[Ee][+-]?[\d_']*\d)|(?:(?:\.[\d_']*\d)?[Ff])|(?:\.[\d_']*\d))/, 'number.float'],
            // Hex formats
            [/\$[0-9A-Fa-f][0-9A-Fa-f_']*/, 'number.hex'],
            [/0x[0-9A-Fa-f][0-9A-Fa-f_']*/, 'number.hex'],
            [/[0-9][0-9A-Fa-f_']*[Hh]/, 'number.hex'],
            // Binary, octal, decimal
            [/[01][01_']*[Bb]/, 'number.binary'],
            [/[0-7][0-7_']*[OoQq]/, 'number.octal'],
            [/\d[\d_']*[Dd]?/, 'number'],
        ],
    },
};

monaco.languages.setLanguageConfiguration('fasmg', {
    comments: {
        lineComment: ';',
    },
    brackets: [
        ['{', '}'],
        ['[', ']'],
        ['(', ')'],
        ['<', '>'],
    ],
    autoClosingPairs: [
        { open: '{', close: '}' },
        { open: '[', close: ']' },
        { open: '(', close: ')' },
        { open: "'", close: "'", notIn: ['string', 'comment'] },
        { open: '"', close: '"', notIn: ['string', 'comment'] },
    ],
    surroundingPairs: [
        { open: '{', close: '}' },
        { open: '[', close: ']' },
        { open: '(', close: ')' },
        { open: '<', close: '>' },
        { open: '"', close: '"' },
        { open: "'", close: "'" },
    ]
});

monaco.languages.setMonarchTokensProvider('fasmg', language);
export default language;    
This tokenizer actually exceeds the accuracy of fasmgw with regard to floats (many corner cases exist and fasmgw is not trying to highlight floats per se).

I'm continuing to work on the full-featured version.

A timely relevant blog post,
How Compiler Explorer Works in 2025.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup


Last edited by bitRAKE on 10 Jun 2025, 06:39; edited 1 time in total
Post 10 Jun 2025, 00:01
View user's profile Send private message Visit poster's website Reply with quote
dosmancer



Joined: 20 Feb 2025
Posts: 36
Location: Kingdom of Sweden
dosmancer 10 Jun 2025, 06:39
Awesome. Tried it a bit and seems good. I was surprised that these two were actually valid:
Code:
x = $01_
repeat 1, i:x
    display `i, 13, 10
end repeat

x = 0x01_
repeat 1, i:x
    display `i, 13, 10
end repeat    

I "think" the regexes could be shortened a bit if ignoreCase is used. Case never matters for the builtin stuff, right?
Post 10 Jun 2025, 06:39
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4249
Location: vpcmpistri
bitRAKE 10 Jun 2025, 06:41
I had a similar thought, but ignoreCase doesn't appear to work in character classes.
Post 10 Jun 2025, 06:41
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.