Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Algol 68 executor #1169

Merged
merged 3 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Supported languages include:
The judge can also grade in the languages listed below:

* Ada
* Algol 68
* AWK
* Brain\*\*\*\*
* COBOL
Expand Down
42 changes: 42 additions & 0 deletions dmoj/executors/ALGL68.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from typing import List

from dmoj.cptbox.handlers import ACCESS_EACCES
from dmoj.executors.compiled_executor import CompiledExecutor


class Executor(CompiledExecutor):
ext = 'a'
command = 'a68g'

test_program = """
BEGIN
STRING input;
get(standin, input);
print((input, newline))
END
"""

data_grace = 131072
syscalls = [
('mkdir', ACCESS_EACCES),
('mkdirat', ACCESS_EACCES),
'alarm',
'setitimer',
]

def get_compile_args(self) -> List[str]:
command = self.get_command()
assert command is not None
assert self._code is not None
# This doesn't actually compile anything, but will generate useful
# output if the program is malformed.
return [command, '--norun', '--noportcheck', '--nopragmats', self._code]

def get_cmdline(self, **kwargs) -> List[str]:
command = self.get_command()
assert command is not None
assert self._code is not None
return [command, '--nowarnings', '--noportcheck', '--nopragmats', self._code]

def get_executable(self):
return self.get_command()
8 changes: 8 additions & 0 deletions dmoj/executors/compiled_executor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import fcntl
import hashlib
import os
import pty
import struct
import termios
from typing import Any, Dict, IO, List, Optional, Tuple, Union

import pylru
Expand Down Expand Up @@ -126,6 +129,11 @@ def create_compile_process(self, args: List[str]) -> TracedPopen:
#
# Emulate the streams of a process connected to a terminal: stdin, stdout, and stderr are all ptys.
_master, _slave = pty.openpty()

# Some runtimes helpfully try to word-wrap error messages by determining the width of the screen. Lie and say
# we're a 1024x1024 terminal, so they don't try wrapping to 1-column width.
fcntl.ioctl(_slave, termios.TIOCSWINSZ, struct.pack('HHHH', 1024, 1024, 0, 0))

# Some runtimes *cough cough* Swift *cough cough* actually check the environment variables too.
env = self.get_compile_env() or os.environ.copy()
env['TERM'] = 'xterm'
Expand Down
Loading