Questions tagged [syntax]

For challenges related to programming or markup language syntax, including but not limited to checking syntax for validity, converting from one syntax to another or fixing invalid syntax. See also the [balanced-string] tag.

Filter by
Sorted by
Tagged with
16 votes
6 answers

Is it a valid Go type?

Write the shortest program or function that will determine if an input is a valid Go type. Spec This challenge will use the following simplified subset of Go types. For more information, see the ...
bigyihsuan's user avatar
  • 9,348
9 votes
5 answers

Convert the type modifiers from prefix to C-fix

Given a base type T, this can be augmented with * or [], each meaning pointer and array. For ...
xiver77's user avatar
  • 2,365
53 votes
13 answers

Read out the C variable declaration

Background Variable declaration statement in C consists of three parts: the name of the variable, its base type, and the type modifier(s). There are three kinds of type modifiers: Pointer ...
Bubbler's user avatar
  • 76k
14 votes
3 answers

Flatten a Stack Cats program

Stack Cats is a reversible, stack-based language. Its reversible nature makes for somewhat weird loops. This challenge is about the conditional loop (...). When ...
Martin Ender's user avatar
10 votes
14 answers

Expand Comparison Chains

Unlike most languages, Python evaluates a<b<c as it would be done in mathematics, actually comparing the three numbers, as opposed to comparing the boolean <...
Maltysen's user avatar
  • 25.7k
19 votes
10 answers

SQL select number ranges

I found it quite hard to achieve a range of numbers as rows in MySQL. For example the range 1-5 is achieved by: ...
Dimgold's user avatar
  • 333
9 votes
2 answers

Reindent Java/C/C++/etc. code

Write a program that adds or removes whitespace to format code nicely. Rules for what the code should look like when you're done: No line should contain more than one of ...
tbodt's user avatar
  • 2,436
63 votes
85 answers

Sugar Free Syntax

In Haskell the list notation: [a,b,c] Is just syntactic sugar for: a:b:c:[] And the string notation: ...
Wheat Wizard's user avatar
  • 98.5k
21 votes
6 answers

Fix my notation for lists of matrices, part 1

Sometimes, I have lists of constant matrices in my code: [ [[1, 0], [0, 1]], [[1, 0], [0,-1]], [[0, 1], [1, 0]], [[0,-1], [1, 0]] ] That's ...
Martin Ender's user avatar
13 votes
2 answers

Close your tags!

This is based off a previous deleted challenge of mine with the same name Introduction You are tasked with writing a program that returns a truthy or falsey value based on if the input has all its ...
Andrew Li's user avatar
  • 1,071
12 votes
1 answer

Prove 2+2=2*2 (and similar)

Output a full formal poof of such statements such as 1+2=3, 2+2=2*(1+1) etc. Introuction If you know Peano Arithmetic you can ...
spraff's user avatar
  • 891
4 votes
0 answers

Ungolf batch programs [closed]

This question wants you to golf batch programms. In Batch you can use set x=averylongbatchcommand %x% arg1 which expands to ...
Linnea Gräf's user avatar
  • 3,059
29 votes
13 answers

Evaluate an expression of ternary operators

Consider a grammar over the alphabet {0, 1, ?, :} ...
Lynn's user avatar
  • 68.7k
10 votes
3 answers

RegEx-golf: match all contents in a string

Your task is to write a RegEx that matches everything inside strings. A string is defined as everything surrounded by (but not including) two unescaped ". A ...
Leaky Nun's user avatar
  • 49.7k
18 votes
8 answers

Translate a Glypho program

Given an input of any valid Glypho program, output its "human-readable" counterpart. Glypho is an interesting esolang idea: The instruction reference is given here. For each instruction, the ...
Doorknob's user avatar
  • 71.5k
20 votes
11 answers

Make a numeric list converter

Don't you hate it when you want to copy-paste a list of numbers (vector, array ...), from one program to another, but the format you have the numbers on doesn't match the format you need it on? For ...
Stewie Griffin's user avatar
13 votes
4 answers

Get The Getters

The Task I guess everybody loves automatic code generation and saving some time during work. You have to create a lot of classes and members during the day and you don't want to create all those ...
insertusernamehere's user avatar
23 votes
9 answers

Formatting a Lisp-like Syntax

Background (Based on a true, heart-wrenching story) In my time, I've played around with Lisp and similar languages often. I've written with them, ran them, interpreted them, designed them, and made ...
BrainSteel's user avatar
  • 5,460
25 votes
7 answers

A Basic Pyth-like Syntax Checker

Pyth is a golfing language based on Python. It uses prefix notation, with each command having a different arity (number of arguments it accepts). Your task is to write a syntax checker for a (non-...
Sp3000's user avatar
  • 61.9k
11 votes
4 answers

Prelude Syntax-Checker

Prelude is an esoteric programming language, which has very few, but unusual, restrictions on what constitutes a valid program. Any block of printable ASCII text ("block" meaning that lines of ...
Martin Ender's user avatar
8 votes
9 answers

Make a finky syntax checker

You are to make a program that can check the syntax of programs of its same language. For example, if you do it in python, it checks python syntax. Your program will receive a program on standard ...
Christopher King's user avatar
37 votes
19 answers

Code Romanization

The challenge is to make any Roman numerals valid code in your chosen language. They should not appear inside of strings or anything similar, but work just like any other tokens, literals such as (...
daniero's user avatar
  • 18.6k