Concrete syntax no longer indentation-based (nightmare to parse). Add indented multi-line code terminals.
This commit is contained in:
parent
59de61d0a3
commit
e875821e70
8 changed files with 119 additions and 73 deletions
16
concrete_syntax/common.py
Normal file
16
concrete_syntax/common.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
def indent(multiline_string, how_much):
|
||||
lines = multiline_string.split('\n')
|
||||
return '\n'.join([' '*how_much+l for l in lines])
|
||||
|
||||
def display_value(val: any, type_name: str, indentation=0):
|
||||
if type_name == "ActionCode":
|
||||
if '\n' in val:
|
||||
return '```\n'+indent(val, indentation+4)+'\n'+' '*indentation+'```'
|
||||
else:
|
||||
return '`'+val+'`'
|
||||
elif type_name == "String":
|
||||
return '"'+val+'"'
|
||||
elif type_name == "Integer" or type_name == "Boolean":
|
||||
return str(val)
|
||||
else:
|
||||
raise Exception("don't know how to display value" + type_name)
|
||||
Loading…
Add table
Add a link
Reference in a new issue