Created
March 8, 2019 23:58
-
-
Save thalesmg/4d527c0d991929fa586095d8af1cceba to your computer and use it in GitHub Desktop.
How to parse a string to an integer from stdin in ATS2 / Postiats-ATS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "share/HATS/atspre_staload_prelude.hats" | |
#include "share/HATS/atspre_staload_libats_ML.hats" | |
implement main0 () = () where { | |
val s: string = fileref_get_line_string(stdin_ref) | |
val n: int = g0string2int(s) | |
val _ = println!("li um ", n + 10, " - 10 !") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.DEFAULT_GOAL := main | |
PATSHOMEQ="$(PATSHOME)" | |
PATSCC=$(PATSHOMEQ)/bin/patscc | |
PATSOPT=$(PATSHOMEQ)/bin/patsopt | |
PATSCCFLAGS=-O2 -flto -DATS_MEMALLOC_LIBC -latslib | |
# Looks like only -latslib is necessary | |
# LDFLAGS=-L$(PATSHOME)/ccomp/atslib/lib -latslib | |
# Also, the variable MUST be called `LDFLAGS` | |
# Setting `-latslib` in `PATSCCFLAGS` does not work... | |
LDFLAGS=-latslib | |
cleanall:: | |
main: main.dats | |
$(PATSCC) $(PATSCCFLAGS) -o $@ $< $(LDFLAGS) || echo $@ ": ERROR!!!" | |
cleanall:: ; $(RMF) main | |
RMF=rm -f | |
clean:: ; $(RMF) *_?ats.c | |
cleanall:: clean |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment