Skip to content

Commit

Permalink
Uploading the grammar configurator.
Browse files Browse the repository at this point in the history
  • Loading branch information
remivantrijp committed Feb 17, 2022
1 parent ac5139e commit a031c79
Show file tree
Hide file tree
Showing 5 changed files with 2,331 additions and 0 deletions.
154 changes: 154 additions & 0 deletions css.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
;; Copyright 2021-present Sony Computer Science Laboratories Paris

;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at

;; http://www.apache.org/licenses/LICENSE-2.0

;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an "AS IS" BASIS,
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.
;;=========================================================================

(in-package :fcg)

;; This file contains prototype code that was developed for research purposes and should not be used in production environments.
;; No warranties are provided.


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; This file contains all css code that is related to the grammar configurator. ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(define-css 'grammar-configurator "
.grammar-configurator {
margin-top: 15px;
border: 1px solid grey;
border-radius: 15px;
width: auto;
display: inline-block;
padding: 10px;
}
.grammar-configurator td {
padding: 10px;
}
.gc-button {
border: none;
color: white;
padding: 10px 32px;
width: auto;
text-align: center;
text-decoration: none;
display: inline-block;
border-radius: 4px;
}
.reset {
background-color: #f44336;
}
.configure {
background-color: #4CAF50;
}
.grammar-configurator a:link, a:visited, a:hover, a:active {
text-decoration: none;
}
.reset:hover {
background-color: #aa1409;
}
.reset:active {
background-color: #f44336;
}
.configure:hover {
background-color: #2f6a31;
}
.configure:active {
background-color: #4CAF50;
}
.feature-type-label {
display: inline-block;
margin-right: 10px;
}
.gc-inner-table td {
padding-top: 0px;
padding-bottom: 0px;
padding-right: 15px;
padding-left: 0px;
}
.top-level-label {
display: block;
font-weight: bold;
margin-bottom:10px;
}
.top-level-value {
margin-bottom:15px;
margin-left:25px;
}
.checkbox-label {
margin-left:5px;
}
.vspacer {
height:15px;
}
.ft_textbox {
width: 250px;
}
.other-configurations {
font-family: Helvetica Neue, Helvetica, Arial;
font-size: 9pt;
}
input {
font-family: Helvetica Neue, Helvetica, Arial;
font-size: 9pt;
}
")
72 changes: 72 additions & 0 deletions demo.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
;; Copyright 2021-present Sony Computer Science Laboratories Paris

;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at

;; http://www.apache.org/licenses/LICENSE-2.0

;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an "AS IS" BASIS,
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.
;;=========================================================================

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Grammar Configurator Demonstration ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; This file contains prototype code that was developed for research purposes and should not be used in production environments.
;; No warranties are provided.

;; Loading ... ;;
;;;;;;;;;;;;;;;;;

(ql:quickload '(:cl-json :fcg))
(in-package :fcg)

;; About the grammar configurator ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; The grammar configurator is a graphical tool to design the configuration of an FCG grammar.
;; It takes the shape of an interactive form embedded in FCG's web interface.

;; The grammar configurator can be used to create a new configuration from scratch, or to visualize and
;; potentially alter the configuration of an existing grammar.

;; The output of the grammar configurator is a ready-to-evaluate def-fcg-constructions macro call.
;; This macro call is printed to the output buffer of your Common Lisp editor.


;; Launching the grammar configurator ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; The grammar configuration can be used to create a new configuration from scratch, or to visualize
;; and potentially alter the configuration of an existing grammar.

;; Let us first consider the case where you would like to create a grammar from scratch. The grammar
;; configurator can be launched by evaluating the following macro call:

(configure-grammar)

;; The grammar configurator interface should now have appeared in the FCG web interface (http://localhost:8000 by default).

;; The grammar configurator interface consists of a number of collapsable/expandable elements (denoted by + and -).
;; The form is initialised by sensible default values. Hitting the 'Reset' button at the bottom will reset these values.
;; Hitting the 'Configure' button will write the configuration to the output browser of your Common Lisp editor. You can
;; then copy/paste this configuration to your grammar file and add constructions to the construction inventory.

;; If the aim is to inspect or alter the configuration of an existing construction inventory, the configure-grammar macro
;; can be called with construction inventory as argument.

(load-demo-grammar) ;; loads a grammar into *fcg-constructions*
(configure-grammar *fcg-constructions*)

;; The grammar configurator now reflects the current state of the configuration of the chosen grammar and can be used
;; to browse through it in a graphical way. The configuration can also be adapted using the form. Upon hitting the
;; 'Configure' button, the adapted configuration is printed to the output browser of your Common Lisp editor.


Loading

0 comments on commit a031c79

Please sign in to comment.