#!/usr/bin/env python # Projet de compilation Umons 2025 # Par Debucquoy Anthony (231687) import argparse import lark import sys class SPFTransformer(lark.Transformer): pass def main(): arg_parser = argparse.ArgumentParser() arg_parser.add_argument("spf_file", help="Fichier source à interpréter") arg_parser.add_argument("-d", "--dump", help="affichage de la mémoire du programme", action="store_true") arg_parser.add_argument("-t", "--trace", help="affichage de la mémoire au cours du programme", action="store_true") args = arg_parser.parse_args() if args.dump: print("Dump activated (TODO)", file=sys.stderr) if args.trace: print("Trace activated (TODO)", file=sys.stderr) with open("spf.lark") as grammar: spf_parser = lark.Lark(grammar, parser="lalr", strict=True, debug=True) with open(args.spf_file) as spf_input: program = spf_input.read() parsed = spf_parser.parse(program) print(parsed.pretty()) if __name__ == "__main__": main()