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

Windows recompiling bug #9

Open
wants to merge 47 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
38abedf
Add inspectify binaries
oeb25 Feb 12, 2023
b869839
Update binaries to v0.1.5
oeb25 Feb 21, 2023
dcc5d17
Update the README
oeb25 Feb 21, 2023
b9a5887
Clarify installation of .NET and evaluation in the README
oeb25 Feb 22, 2023
75eafeb
Grammar fixes in the README
oeb25 Feb 22, 2023
2f00f07
Update README.md
cmatheja Feb 22, 2023
4057493
Update README.md
cmatheja Feb 22, 2023
2692e6f
Update README.md
cmatheja Feb 22, 2023
cdf62db
Update README.md
cmatheja Feb 22, 2023
e44d0c2
Update Graph.fs
cmatheja Feb 22, 2023
6927ca0
Update README.md
cmatheja Feb 22, 2023
be3aff7
Update README.md
cmatheja Feb 22, 2023
ae97201
Update README.md
cmatheja Feb 22, 2023
d29ec5e
Update README.md
cmatheja Feb 22, 2023
03b2d61
Update README.md
cmatheja Feb 22, 2023
9a29835
Update README.md
cmatheja Feb 22, 2023
86aa5f2
Update README.md
cmatheja Feb 22, 2023
b5e8f44
Update README.md
cmatheja Feb 22, 2023
17af85e
Update README.md
cmatheja Feb 22, 2023
2fb0670
Update README.md
cmatheja Feb 22, 2023
a683022
Update README.md
cmatheja Feb 22, 2023
742e31e
Update README.md
cmatheja Feb 22, 2023
9e392c8
Update README.md
cmatheja Feb 22, 2023
cc53a90
Update README.md
cmatheja Feb 22, 2023
5bbef10
Update README.md
cmatheja Feb 22, 2023
dd79070
added picture
cmatheja Feb 22, 2023
6a4d037
Update README.md
cmatheja Feb 22, 2023
d04c178
Add extension recommendations for VSCode
oeb25 Feb 23, 2023
5e745f5
Update README.md
albertolluch Feb 23, 2023
5697803
Update README.md
albertolluch Feb 23, 2023
802835d
Merge pull request #2 from albertolluch/patch-4
cmatheja Feb 23, 2023
546222d
Merge pull request #1 from albertolluch/patch-3
cmatheja Feb 23, 2023
b4fbf43
Added TODO markers where to get started. (#2)
cmatheja Feb 27, 2023
86c2552
Update README.md
cmatheja Mar 1, 2023
155352a
added explicit case for parsing task.
cmatheja Mar 1, 2023
10963bb
Merge branch 'main' into patch-1
cmatheja Mar 1, 2023
46f6ce3
removed unnecessary file
cmatheja Mar 1, 2023
7a232e9
Merge branch 'patch-1' of github.com:cmatheja/fsharp-starter into pat…
cmatheja Mar 1, 2023
c2d1a39
Merge pull request #3 from cmatheja/patch-1
cmatheja Mar 1, 2023
47e9fe4
Add variable number of arguments to parse CLI entrypoint
oeb25 Mar 8, 2023
6fcbc67
Change parse to output in JSON format
oeb25 Mar 10, 2023
b3d52f1
Rework the input/output of interpreter (#5)
oeb25 Mar 15, 2023
d6c0cea
chore: Add ignore field to run.toml to ignore build artifacts
oeb25 Mar 16, 2023
b3cbaf0
Program verification with enriched GCL language and predicates (#7)
oeb25 Mar 23, 2023
00bbd61
Update ProgramVerification.fs
cmatheja Mar 23, 2023
2e5629a
Improve parse error message for program verification
oeb25 Mar 23, 2023
1ea441b
Resolve windows recompiling bug
martin045k Mar 28, 2023
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
6 changes: 6 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"mnxn.fsharp-fsl-fsy",
"ionide.ionide-fsharp"
]
}
3 changes: 1 addition & 2 deletions Graph.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@ type Input = { determinism: Determinism }

type Output = { dot: string }

// Start you implementation here
let analysis (src: string) (input: Input) : Output =
failwith "Graph analysis not yet implemented"
failwith "Graph analysis not yet implemented" // TODO: start here
35 changes: 27 additions & 8 deletions Interpreter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,39 @@ type InterpreterMemory =
type Input =
{ determinism: Determinism
assignment: InterpreterMemory
trace_size: int }
trace_length: int }

type ProgramState =
// TODO: Change this to you internal version of node
// If your node type is defined in graph, consider using the following:
// type Node = Graph.Node
type Node = string

type TerminationState =
| Running
| Stuck
| Terminated

type ProgramTrace =
{ node: string
state: ProgramState
type Configuration<'node> =
{ node: 'node
memory: InterpreterMemory }

type Output = List<ProgramTrace>
type Output =
{ execution_sequence: List<Configuration<string>>
final: TerminationState }

let stringifyNode (internalNode: Node) : string =
// TODO: implement for internal node type
internalNode

let prepareConfiguration (c: Configuration<Node>) : Configuration<string> =
{ node = stringifyNode c.node
memory = c.memory }


// Start you implementation here
let analysis (src: string) (input: Input) : Output =
failwith "Interpreter not yet implemented"
failwith "Interpreter not yet implemented" // TODO: start here
let execution_sequence: List<Configuration<Node>> = failwith "TODO"
let final: TerminationState = failwith "TODO"

{ execution_sequence = List.map prepareConfiguration execution_sequence
final = final }
37 changes: 37 additions & 0 deletions Parse.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module Parse

open FSharp.Text.Lexing
open System
open AST

exception ParseError of Position * string * Exception

let parse parser src =
let lexbuf = LexBuffer<char>.FromString src

let parser = parser Lexer.tokenize

try
Ok(parser lexbuf)
with
| e ->
let pos = lexbuf.EndPos
let line = pos.Line
let column = pos.Column
let message = e.Message
let lastToken = new String(lexbuf.Lexeme)
eprintf "Parse failed at line %d, column %d:\n" line column
eprintf "Last token: %s" lastToken
eprintf "\n"
Error(ParseError(pos, lastToken, e))

let rec prettyPrint ast =
// TODO: start here
failwith "GCL parser not yet implemented"

let analysis (src: string) : string =
match parse Parser.start (src) with
| Ok ast ->
Console.Error.WriteLine("> {0}", ast)
prettyPrint ast
| Error e -> "Parse error: {0}"
8 changes: 7 additions & 1 deletion Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ let main (args) =
Console.WriteLine("{0}", evaluate ast)
| Error e -> Console.Error.WriteLine("Parse error: {0}", e)

0
| "parse" :: src :: _ ->
let output: string = Parse.analysis src
Console.WriteLine("{0}", JsonConvert.SerializeObject output)

0
| [ "graph"; src; input ] ->
let input = JsonConvert.DeserializeObject<Graph.Input> input
Expand Down Expand Up @@ -82,9 +87,10 @@ let main (args) =
| _ ->
let commands =
[ "calc <EXPRESSION...>"
"parse <SRC>"
"graph <SRC> <INPUT>"
"interpreter <SRC> <INPUT>"
"pv <SRC> <INPUT>"
"program-verification <SRC> <INPUT>"
"sign <SRC> <INPUT>"
"security <SRC> <INPUT>" ]

Expand Down
27 changes: 23 additions & 4 deletions ProgramVerification.fs
Original file line number Diff line number Diff line change
@@ -1,15 +1,34 @@
module ProgramVerification

open System
open Predicate.AST

(*
This defines the input and output for the program verification analysis.
Please do not change the definitions below as they are needed for the
validation and evaluation tools!
*)

type Input = { post_condition: string }
type Input = unit

type Output = { pre_condition: string }
type Output =
{ verification_conditions: List<SerializedPredicate> }

// Start you implementation here
let analysis (src: string) (input: Input) : Output =
failwith "Program verification analysis not yet implemented"
let (P, C, Q) =
match Predicate.Parse.parse src with
| Ok (AnnotatedCommand (P, C, Q)) -> P, C, Q
| Error e ->
failwith
$"Failed to parse.\n\nDid you remember to surround your program with predicate blocks, like so?\n\n {{ true }} skip {{ true }}\n\n{e}"

// TODO: Remove these print statements
Console.Error.WriteLine("P = {0}", P)
Console.Error.WriteLine("C = {0}", C)
Console.Error.WriteLine("Q = {0}", Q)

let verification_conditions: List<Predicate> =
failwith "Program verification not yet implemented" // TODO: start here

// Let this line stay as it is.
{ verification_conditions = List.map serialize_predicate verification_conditions }
47 changes: 33 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# FsLexYacc-Starter
# F# Starter

This folder contains the skeleton of a parser along with the input and output types for each analysis given in the assignment. It also contain an example of a "calculator" program in F# that reads an arithmetic expression from the command line and print the result of evaluating such expression for initial testing.
This folder contains the skeleton of a parser along with the input and output types for each analysis given in the assignment. It also contains an example of a "calculator" program in F# that reads an arithmetic expression from the command line and print the result of evaluating such expression for initial testing.

## Files

Expand All @@ -9,31 +9,35 @@ F#/FsLexYacc
* [Parser.fsp](Parser.fsp): The parser for arithmetic expressions
* [Types.fs](Types.fs): Global types that are used in many analysis
* [AST.fs](AST.fs): Types for AST of arithmetic expressions
* [Program.fs](Program.fs): The entrypoint for the program
* [Program.fs](Program.fs): The entry point for the program
* [Security.fs](Security.fs): File for the security analysis
* [SignAnalysis.fs](SignAnalysis.fs): File for the sign analysis
* [ProgramVerification.fs](ProgramVerification.fs): File for program verification
* [Graph.fs](Graph.fs): File for graphs
* [Interpreter.fs](Interpreter.fs): File for the interpreter


## Running on macOS M1
## Getting started

Building on macOS requires the `dotnet-sdk` package. This can be installed using [brew](https://brew.sh):
Building this project requires .NET 7.0. For installation, follow the description matching your platform:

```bash
brew install dotnet-sdk
```
- **Windows:** Installation instructions for this, can be found [here](https://dotnet.microsoft.com/en-us/download).
- **macOS:** Building on macOS requires the `dotnet-sdk` package. This can be installed using [Homebrew](https://brew.sh) and running `brew install dotnet-sdk`
- **Linux:** There are many ways to install on Linux, but a good starting point might be [this](https://fsharp.org/use/linux/).

To check that you have an up-to-date version run `dotnet --version` to display the version number, which should be something starting with 7. If it does not, consider updating your installation, and if that doesn't work, try uninstalling your current version and installing from scratch.

The next step is getting the code, which is done by cloning this repository and using `cd` to change directory to the newly cloned folder. To do this, make sure that you have your SSH keys set up correctly (instructions for [GitLab](https://docs.gitlab.com/ee/user/ssh.html)).

## Instructions for F#/FSLexYacc
## Running the code

To run the program do:
To run the program, navigate to the directory of your cloned repository and do:

```bash
dotnet run
```

### Calculator
This should display a list of the available commands to run. Among these are the calculator, which is a good starting point.

To run the calculator do:

Expand All @@ -43,7 +47,7 @@ dotnet run calc "1 + 52 * 23"

## Interactive UI

The analysis can be explored in the interactive tool. Run the program in `dev/` folder matching you operating system.
When you get further, the analysis can be explored in the interactive tool. Run the program in the `dev/` folder matching your operating system.

```bash
# Windows
Expand All @@ -60,8 +64,23 @@ With the `--open` flag this should open the tool at `http://localhost:3000/` in

The tool knows how to compile your program by the instructions in `run.toml`.

### Downloading updates

It is recommended to update the binaries in `dev/` regularly. You do this by running the command below matching your platform, and following the instructions when prompted:

```bash
# Windows
./dev/win.exe --self-update

# macOS
./dev/macos --self-update

# linux
./dev/linux --self-update
```

## Evaluation

Every time you push to git, the program gets evaluated automatically.
Every time you push your Git repository, your code is ready to be evaluated automatically by your teachers.

The result can be seen at GitLab in the `result` branch.
When your project has been evaluated, the results can be seen (at GitLab) in the "result" branch.
3 changes: 1 addition & 2 deletions Security.fs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,5 @@ type Output =
violations: Flow list }


// "Start you implementation here"
let analysis (src: string) (input: Input) : Output =
failwith "Security analysis not yet implemented"
failwith "Security analysis not yet implemented" // TODO: start here
3 changes: 1 addition & 2 deletions SignAnalysis.fs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,5 @@ type Output =
nodes: Map<string, Set<SignAssignment>> }


// Start you implementation here
let analysis (src: string) (input: Input) : Output =
failwith "Sign analysis not yet implemented"
failwith "Sign analysis not yet implemented" // TODO: start here
14 changes: 14 additions & 0 deletions calculator.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@
<Compile Include="Parser.fsi" />
<Compile Include="Parser.fs" />
<Compile Include="Lexer.fs" />
<Compile Include="Parse.fs" />

<Compile Include="predicates/AST.fs" />
<FsYacc Include="predicates/Parser.fsy">
<OtherFlags>--module Predicate.Parser -o predicates/Parser.fs</OtherFlags>
</FsYacc>
<FsLex Include="predicates/Lexer.fsl">
<OtherFlags>--module Predicate.Lexer --unicode -o predicates/Lexer.fs</OtherFlags>
</FsLex>
<Compile Include="predicates/Parser.fsi" />
<Compile Include="predicates/Parser.fs" />
<Compile Include="predicates/Lexer.fs" />
<Compile Include="predicates/Parse.fs" />

<Compile Include="Graph.fs" />
<Compile Include="Interpreter.fs" />
<Compile Include="SignAnalysis.fs" />
Expand Down
Binary file added dev/linux
Binary file not shown.
Binary file added dev/macos
Binary file not shown.
Binary file added dev/win.exe
Binary file not shown.
Loading