History log of /seL4-l4v-master/HOL4/src/parse/term_grammar.sig
Revision Date Author Comments
# d3dc93f8 20-Oct-2020 Michael Norrish <michael.norrish@data61.csiro.au>

Make grammar-deltas s-expressions when stored in theory .dat files

This makes them more legible, and is also a prelude to being more
uniform in the treatment of theory data that merges deltas across
ancestors.


# 13d48e45 04-Feb-2020 Michael Norrish <michael.norrish@data61.csiro.au>

Implement a remove_strliteral_form

This undoes the effect of add_strliteral_form. With test cases and a
nod in the direction of documentation.

Closes #778


# 1d8e9bc9 06-Jul-2019 Michael Norrish <Michael.Norrish@nicta.com.au>

Do pretty-printing for different string literal forms

Entrypoint is Parse.add_strliteral_form, which needs documentation.
But this otherwise completes issue #510.


# d95d3320 13-Mar-2018 Michael Norrish <Michael.Norrish@nicta.com.au>

Now up to PPBackEnd.sml (term_grammar.sml done)


# d0421b2c 26-Dec-2017 Jeremy Dawson <jeremy@cecs.anu.edu.au>

functions to print terms without using overloads


# ede4d6e9 09-Aug-2017 Michael Norrish <Michael.Norrish@nicta.com.au>

src/parse compiles but parser broken.

Completed change to remove LISTRULE form from grammar. Instead, all
list syntax is handled with embedded ListForms within normal rules.


# e8895bc2 08-Aug-2017 Michael Norrish <Michael.Norrish@nicta.com.au>

WIP for change to list syntax handling.

Very broken at the moment


# ab22e51d 02-Aug-2017 Michael Norrish <Michael.Norrish@nicta.com.au>

Use grammar-deltas for user-provided absyn post-processors


# b847c215 01-Aug-2017 Michael Norrish <Michael.Norrish@nicta.com.au>

Extract pretty-printing of LET-terms from term_pp.sml

It is now part of user-printer "land" in src/bool/boolpp.sml,
alongside the custom printer for if-then-else (COND).

This refactoring revealed a bug in the way overloaded constants
couldn't be handled by user-printers if they could have extra
arguments hanging off to the right (as in “LET f x y”), *unless* they
were overloaded to "case" (as in COND).

To make sure one's user-printer is going to work, you have to consult
the grammar's overload information to check if your term is one you
want to print according to the grammar_name function. Unfortunately,
looking for particular constants is not guaranteed to work, as the
process of descending terms in the pretty-printer is liable to turn
real constants into special "fake" constants that are actually
variables with special names.

This is progress with Github issue #154, to allow new (Isabelle-style)
syntax for let expressions.


# 5d5a8494 09-Mar-2017 Michael Norrish <Michael.Norrish@nicta.com.au>

Preserve add_user_printer properly in grammar data

This requires a slightly involved process for storing references to
code in theory files.

Update the .doc file on add_user_printer (which was already incredibly
long), and add a test.

Closes #367


# 0343a24d 05-Oct-2016 Michael Norrish <Michael.Norrish@nicta.com.au>

Ensure Unicode lambda is in grammars from min onwards

Fixes bug identified in 7cfe487


# 777dae59 03-Oct-2016 Michael Norrish <Michael.Norrish@nicta.com.au>

Provide "remove tok" update for term grammars

This one removes "all" rules that involve the given tok (except: the
behaviour with respect to list rules mimics what the remove_termtok
function does, and only looks at the first token of the various
components; this is probably something that can change).


# ef56fcbb 21-Sep-2016 Michael Norrish <Michael.Norrish@nicta.com.au>

Get tracked user_deltas to build grammars in Theory files


# 7e8d786d 19-Sep-2016 Michael Norrish <Michael.Norrish@nicta.com.au>

Record overload_on calls in GrammarDeltas


# d724881d 16-Sep-2016 Michael Norrish <Michael.Norrish@nicta.com.au>

Remove BRULE constructor from user_delta type

It is redundant, though the GRULE representation of a grammar's binder
rule contains information that is never used.


# a57b4725 15-Sep-2016 Michael Norrish <Michael.Norrish@nicta.com.au>

Properly re-org grammar code, removing rule_fixity

Now there is just one fixity type. Also decide that set_fixity and
set_mapped_fixity shouldn't be in the grammar-delta type; instead the
"remove-termtok" and "add_rule" actions (which can be used to implement
the above) should be.


# 4f4ab38f 15-Sep-2016 Michael Norrish <Michael.Norrish@nicta.com.au>

Refactor more grammar code

Ultimate is to switch to concrete "grammar-deltas" in theory files
rather than calls to the update_grms function. Start this process by
extending existing delta type with SET_MAPPED_FIXITY constructor. This
is not yet used.


# c79d08fb 14-Sep-2016 Michael Norrish <Michael.Norrish@nicta.com.au>

Move grammar code, mostly simplifying term_grammar

Most significant change sees some code in term_grammar that is only
useful in the concrete syntax parser move to parse_term. Add a _dtype
structure for the latter's public datatypes as well.


# bc5893cc 14-Sep-2016 Michael Norrish <Michael.Norrish@nicta.com.au>

Refactor grammar datatypes into separate struct

This removes duplicated datatype declarations


# 03e0f9c6 24-Feb-2016 Michael Norrish <Michael.Norrish@nicta.com.au>

Provide p/printer for rules part of a term grammar

Closes #249


# 43cfb1f2 21-Jan-2016 Michael Norrish <Michael.Norrish@nicta.com.au>

Allow for user "preterm processors"

These are inserted into the process where the abstract syntax gets
turned into preterms, and can call back to the builtin processor if
necessary.

Something like this is necessary if you are going to mess with binding
structure and need to do so in a way that is itself aware of what the
context's free variables are. This technology is needed for
pattern-matching, and should allow us to move the handling of
set-comprehension out of src/parse as well.


# e2a8b9bc 20-Jan-2016 Michael Norrish <Michael.Norrish@nicta.com.au>

Absyn post-processors now see the current grammar


# 66031f8d 20-Jan-2016 Michael Norrish <Michael.Norrish@nicta.com.au>

Undo all pmatch changes to src/parse

I now want to make new-style pmatch parsing happen via the mechanism of
absyn post-processors (as is done with monad syntax). I don't think
that changing the "core" parser is necessary (and it's certainly not
desirable).


# 66b3ce98 17-Jan-2016 Michael Norrish <Michael.Norrish@nicta.com.au>

Fix errors in b3de5020; add fupd for pmatch_on


# b3de5020 17-Jan-2016 Michael Norrish <Michael.Norrish@nicta.com.au>

Add flag to term grammars saying if to use PMATCH


# a98923f3 08-Jul-2015 Michael Norrish <Michael.Norrish@nicta.com.au>

Allow pretty-printing backends to modify grammar

If you know that you are targetting a particular backend, you may wish
to also modify the grammars that control pretty-printing.

For the moment, just use the identity update in all our backends, so
that nothing changes in terms of what the user sees.


# d2d3cc44 02-Nov-2014 Michael Norrish <michael.norrish@nicta.com.au>

Pretty-printer now annotates consts with their real names and types.

In "complicated" overload situations, such as the overloads for NOTIN
and <>, the annotation can't point to a "real" underlying constant,
but does still provide the type for the emacs tool-tips.

In passing, also create a new annotation form, the SymConst as well as
the Const. This is done for the TeX backend's benefit, so that it can
avoid treating things like + the same as normal identifiers. This
works well for math-mode munging where you want "+" to map to $+$, but
want "INSERT" to map to \textsf{INSERT}.

Closes #39


# 8e166d24 22-Oct-2014 Michael Norrish <michael.norrish@nicta.com.au>

Allow case-constant printing to be overridden by user overloads.

For the if-then-else case, the specially installed user-printer code
from ParseExtras needs to be adjusted.

Closes #206


# cf273a71 25-Feb-2014 Michael Norrish <michael.norrish@nicta.com.au>

Allow prefix-operators to be printed without parens in rand-position

This is a refinement to the decision in aeb0085a3d11, which insisted
that prefix operators (like if-then-else, binders, case-expressions
and others) should always get parentheses when printed as arguments to
functions.

Now you can tweak this by choosing the NotEvenIfRand parenthesis style
as an argument to add_rule. For particularly tight operators, ones
that may omit spaces before their arguments say, this may look better.
For example, you might define a "#" operator, when it might be nicer
to have

f #2 + g #n

print that way, rather than with extra parentheses. At the moment, our
standard number injection function & does print with parentheses, but
this case does feel like one where dispensing with the parentheses
might be a good idea.


# 5c44a74f 10-Feb-2014 Ramana Kumar <ramana@member.fsf.org>

informational function in Parse: print the term grammar rules

The existing term_grammar() returns the grammar which is pretty printed
by showing the rules, the known constants, and overloading info.
Sometimes this is too much information. So the new print_term_grammar()
just pretty prints the rules (and returns unit). This is useful
especially to see infix and precedence information.


# 0bbd2a7e 21-Jun-2011 Michael Norrish <Michael.Norrish@nicta.com.au>

Rename TruePrefix to Prefix; use fixity options with NONE for what was Prefix.

90+% of this work was done by Ramana Kumar. The following list are
the commits for a series of individual commits that have been squished
into one big change:
* remove mention of TruePrefix from the add_rule docfile
* first batch of changes removing TruePrefix from src/parse
* replace TruePrefix by Prefix in boolScript.sml
* remove TruePrefix from Rsyntax
is a fixity ever required for new_specification?
* some more Prefix -> NONE and TruePrefix -> Prefix in theories
* TruePrefix changes for datatype
* TruePrefix changes for res_quan
* TruePrefix->Prefix in a TeX selftest
* TruePrefix changes for quotient
* TruePrefix changes for integer and real
* fix quotient examples for TruePrefix removal
* more fixes for quotient examples
* fixes for lambda example for TruePrefix removal
* Reword description manual in light of removal of TruePrefix.
* Fix msgTheory quotient example; Poly 5.3 had problems with monotypes.
* Fixes for files in examples/lambda given removal of TruePrefix.
* Fix in examples/unification given removal of TruePrefix.
* Fix in examples/HolCheck given removal of TruePrefix.
* Fixes in examples/acl2 given removal of TruePrefix.


# 0e6ded4f 25-Mar-2010 Michael Norrish <Michael.Norrish@nicta.com.au>

Rework grammar infrastructure, losing 'preference' for concrete syntax.

Instead, the most recent rule is the one the pretty-printer will prefer.
The clear_prefs function disappears, but the prefer_form function stays
because it can just adjust the timestamp on the desired form to be most
recent.


# 3745987e 22-Mar-2010 Michael Norrish <Michael.Norrish@nicta.com.au>

Bugfix: unsetting Unicode trace wasn't correctly removing all Unicode rules.


# c2976fa7 25-Feb-2010 Michael Norrish <Michael.Norrish@nicta.com.au>

Move theory min's grammars into {type,term}_grammar (out of Parse).


# 98b950eb 23-Feb-2010 Michael Norrish <Michael.Norrish@nicta.com.au>

Add encoder and reader for grammar rules.

Also add some more entrypoints from optmonad to Coding.sig.


# a93e89cc 15-Feb-2010 Michael Norrish <Michael.Norrish@nicta.com.au>

Remove a misleading comment.


# d9003833 26-Nov-2008 Michael Norrish <Michael.Norrish@nicta.com.au>

Fairly dramatic change, supporting the use of "syntactic patterns".
It is now possible to overload a name to term (typically a
lambda-abstraction) in order to create syntax-only definitions. For
example, there is a definition of not-equals now in the system:
val _ = overload_on ("<>", ``\x y. ~(x = y)``)
val _ = set_fixity "<>" (Infix(NONASSOC, 450))
This definition is parsed and pretty-printed.

Two other annoying changes. The interface for adding unicode variants
has changed, and I have made precedence level 450 of the parser
non-associative. This latter change has caused most of the (minor)
adjustments to the files below. The regression test doesn't go
through yet. (Currently there is a failure in
quotient/examples/sigma that I don't understand.)


# 6cf5d50e 04-Nov-2008 Michael Norrish <Michael.Norrish@nicta.com.au>

Update the handling of binders so that different concrete syntax forms
can map to the same abstract syntax form. This makes binders more
similar to other forms. For example, the if-then-else and =>-|
concrete forms might both map to the underlying name "COND". Now,
with Unicode enabled, the Unicode universal quantifier as well as "!"
can both map to the name "!". (Internally, there is a preferred flag
set, so that the pretty-printer knows which should be printed when it
comes to the term "!".)

This couldn't be done before, so for example the Unicode universal
quantifier mapped to itself, and this name was then overloaded to be
an alias for "!". This use of the overloading level for Unicode led
to some problems, and was inconsistent with the approach taken for the
other symbols.

There are some other tidy-ups now that binders are more like other
forms.


# a6ecbd7a 14-Oct-2008 Michael Norrish <Michael.Norrish@nicta.com.au>

Modify the ability to add user-printers so that they're keyed off
term-matches (using first order term-matching). Also give the user's
function access to the relevant grammars, and to the "smart"
add_string and add_break functions that the system printer uses itself
to avoid symbol merging.


# 04a9e3d2 14-Oct-2008 Michael Norrish <Michael.Norrish@nicta.com.au>

A stepping stone on the way to allowing arbitrary abstract syntax
post-processing to be added to user parsers in a straightforward way.
Also add the useful FunctionalRecordUpdate code from mlton.org to
portableML.


# 77687ebf 26-Aug-2008 Michael Norrish <Michael.Norrish@nicta.com.au>

Another fix to the way Unicode-overloading works. It now checks to
see if the term you are overloading to has an ASCII concrete syntax.
(For example, integer$int_le has an ASCII concrete syntax of <= as an
infix.) If so, it will set up the Unicode symbol as an alias for that
concrete syntax. This means that subsequent overloads on the same
ASCII symbol will also pick up the Unicode symbol.

Graphically, we have something like



x <= y +----- arithmetic$<=
\ |
>---> COMB(COMB(<=,x),y) >---+----- integer$int_le
/ |
x ≤ y +----- words$word_le
|
... etc

where the middle column is the result of Absyn applied to the given
quotation.


# 6c969553 26-Feb-2008 Michael Norrish <Michael.Norrish@nicta.com.au>

Remove more Polyhash occurrences.


# 532d6d9a 28-Dec-2007 Konrad Slind <konrad.slind@gmail.com>

hanges to upgrade EVAL on BIGUNION {}.



M src/parse/term_grammar.sig
M src/pred_set/src/pred_setScript.sml
M src/pred_set/src/pred_setLib.sml
M src/pred_set/src/PFset_conv.sml


# d67d1999 14-May-2006 Michael Norrish <Michael.Norrish@nicta.com.au>

Extend the add_listform interface so that the user can specify a printing
"consistency" for the block of list elements. Previously, it was just
assumed that the user always wanted (INCONSISTENT,0). This is the value
now specified in the various places where add_listform is used.


# 0cbf5322 29-Nov-2004 Michael Norrish <Michael.Norrish@nicta.com.au>

Open up the grammar interface, so that users can modify the "specials"
component of the grammar. This then allows them to change the magic
tokens that stand for lambda abstraction (\), the symbol that introduces
type annotations (:), the symbol used to mark the end of a variable binding
sequence (.), the restricted quantifiers (this is already accessible
through the API), and the restricted quantifier token (::).

To parse/print with a grammar, use functions in Parse such as
temp_set_grammars
parse_from_grammars
print_from_grammars
print_term_by_grammar


# fb863eae 03-Sep-2003 Michael Norrish <Michael.Norrish@nicta.com.au>

Modify the add_listform function in line with a suggestion of Lockwood
Morris's to provide slightly more flexibility in the way that list forms
are pretty-printed. Previously, the format was fixed as
<left-delimiter> el1 <sep> <a space> el2 <sep> <a space> ...
Now, the spacing is more directly under user-control.


# 6a2aaf04 14-Aug-2002 Michael Norrish <Michael.Norrish@nicta.com.au>

Changes to parsing technology to allow left-associated infixes to
co-exist with function application in the same slot in the grammar.
Application of this new facility to the example of FAPPLY in finite_map
theory. Might also be useful if and when we get round to modelling sets
as functions in pred_set theory.


# 03b97a87 08-May-2001 Michael Norrish <Michael.Norrish@nicta.com.au>

Modifications to implement parsing and printing of case expressions.


# 87b1bbce 20-Apr-2001 Michael Norrish <Michael.Norrish@nicta.com.au>

Added ability for users to add their own pretty-printers, tied to the type
of the term being printed out.


# 607d3f54 19-Apr-2001 Michael Norrish <Michael.Norrish@nicta.com.au>

Cleaned up treatment of overloading and extended pretty-printer to
show types verbosely, when appropriate.


# bf7d5c49 07-Nov-2000 Michael Norrish <Michael.Norrish@nicta.com.au>

Treatment of known constants and overloading was bogus. Now known constants
are just the domain of the map in the overloading info. reveal now
puts all constants of the given name into the overloading map. Will
have to add a precise function for removing pairs from this.


# a2511ab7 02-Nov-2000 Michael Norrish <Michael.Norrish@nicta.com.au>

Changes to bring about Kananaskis parser. Known bug exists in
treatment of qualified identifiers.


# 90374f50 25-Oct-2000 Michael Norrish <Michael.Norrish@nicta.com.au>

Slew of changes to get rid of local open in end in signature files, and
one or two other fixes to make source mosml2.00 compatible. Also added
ability to set and get term_printer function, as per request by Peter
Homeier.


# ef50e06b 03-May-2000 Michael Norrish <Michael.Norrish@nicta.com.au>

Implementation of move of hide/show information from Parse_support list
into grammars.


# 23e9a485 09-Nov-1999 Michael Norrish <Michael.Norrish@nicta.com.au>

Implemented pretty-printing for grammars. In order to allow for this
to be installed as a pretty-printer for all values of this type, made
grammar implementation a datatype; this change invisible externally.


# 858d1a0b 18-Oct-1999 Michael Norrish <Michael.Norrish@nicta.com.au>

Changes to support the proper construction and export of theory grammar
values. Theory export now takes an extra parameter, which is a string
that will be pre-pended to the Theory.sml file. This allows me to
remove code in TheoryPP that was rather specific to what was being
done in Parse. Now, this code can remain ignorant of that level of the
system, as should be the case.


# c03bd7b1 15-Oct-1999 Michael Norrish <Michael.Norrish@nicta.com.au>

Implemented new operation of grammar merging. This will be used
to deal with the dodgy implementation of internal grammar value
calculation done in theories.


# d28425f8 06-Sep-1999 Michael Norrish <Michael.Norrish@nicta.com.au>

Quite radical changes which allow for "." to be used as the record
field selection operator. Lexer has changed quite dramatically:
it is no longer responsible for determining whether or not a token
is a "keyword" or not. Instead this is done at the parsing level.

The lexer is also now unable to cope with identifiers that are a mix
of alphabetically acceptable and symbolically acceptable characters.


# dc18dcf9 03-Sep-1999 Michael Norrish <Michael.Norrish@nicta.com.au>

Many changes, mainly to do with record syntax. Also implemented long IDs
as theory-name$id. All of HOL doesn't quite build because field selection
operator is ->, which is used in the real library. Will change this to be
just a simple "." Have also started on concrete syntax for updates.


# 631903ee 31-Aug-1999 Michael Norrish <Michael.Norrish@nicta.com.au>

Record field selection implemented as far as parsing and pretty-printing are
concerned.


# 259c8172 23-Aug-1999 Michael Norrish <Michael.Norrish@nicta.com.au>

Many changes to allow numerals to be overloaded as well as operators.


# 3bed8d45 19-Aug-1999 Michael Norrish <Michael.Norrish@nicta.com.au>

Big raft of changes allowing a simple form of overloading to be supported.


# 4332c966 06-Aug-1999 Michael Norrish <Michael.Norrish@nicta.com.au>

Implementation of new pretty-printing support whereby grammar rules now
contain extra information on how various forms are to be printed, with
extra information specifying spacing, block structure and when things
should be parenthesised, even if not strictly necessary.


# 0d378140 28-Jul-1999 Michael Norrish <Michael.Norrish@nicta.com.au>

Changes necessary to make :: an infix operator representing CONS as well
as the restricted quantification operator. This change has required some
changes to the basic design of the parser; it's now not possible to have
more than one res. quan. operator.


# cf9ed16b 07-Jul-1999 Michael Norrish <Michael.Norrish@nicta.com.au>

Numerous changes allowing for printing and parsing of numerals and
treating them as members of different families depending on the contents
of the numeral_info part of the term_grammar. Tested inasmuch the
distribution builds correctly, and with integerTheory loaded.


# 0058df84 28-Jun-1999 Michael Norrish <Michael.Norrish@nicta.com.au>

Fixed to bring it up to date with Taupo release 0.
(Changes have come across from parse_branch development.)