Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
#!/usr/bin/env dart
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
|
|
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
//
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
// This is a very specialized tool which was created in order to support
|
|
|
|
// adding hash values used as location markers in the LaTeX source of the
|
|
|
|
// language specification. It is intended to take its input file as the
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
// first argument, an output file name as the second argument, and a
|
|
|
|
// hash listing file name as the third argument. From docs/language a
|
|
|
|
// typical usage would be as follows:
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
//
|
2018-11-02 12:11:41 +00:00
|
|
|
// dart ../../tools/addlatexhash.dart dartLangSpec.tex out.tex hash.txt
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
//
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
// This will produce a normalized variant out.tex of the language
|
|
|
|
// specification with hash values filled in, and a listing hash.txt of
|
|
|
|
// all the hash values along with the label of their textual context
|
|
|
|
// (section, subsection, subsubsection, paragraph) . For more details,
|
|
|
|
// please check the language specification source itself.
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
//
|
|
|
|
// NB: This utility assumes UN*X style line endings, \n, in the LaTeX
|
2018-10-10 19:15:30 +00:00
|
|
|
// source file received as input; it will not work with other styles.
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
|
2022-02-17 19:09:52 +00:00
|
|
|
// ignore_for_file: constant_identifier_names
|
|
|
|
|
2019-04-09 02:06:09 +00:00
|
|
|
import 'dart:convert';
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
import 'dart:io';
|
2016-04-15 17:00:24 +00:00
|
|
|
|
|
|
|
import 'package:convert/convert.dart';
|
2019-04-09 02:06:09 +00:00
|
|
|
import 'package:crypto/crypto.dart';
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
// Normalization of the text: removal or normalization of parts that
|
|
|
|
// do not affect the output from latex, such as white space.
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
|
2022-02-17 19:09:52 +00:00
|
|
|
final commentRE = RegExp(r"[^\\]%.*"); // NB: . does not match \n.
|
|
|
|
final whitespaceAllRE = RegExp(r"^\s+$");
|
|
|
|
final whitespaceRE = RegExp(r"(?:(?=\s).){2,}"); // \s except end-of-line
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
/// Removes [match]ing part of [line], adjusting that part with the
|
|
|
|
/// given [startOffset] and [endOffset], bounded to be valid indices
|
|
|
|
/// into the string if needed, then inserts [glue] where text was
|
|
|
|
/// removed. If there is no match then [line] is returned.
|
2022-02-17 19:09:52 +00:00
|
|
|
cutMatch(line, match, {startOffset = 0, endOffset = 0, glue = ""}) {
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
if (match == null) return line;
|
|
|
|
var start = match.start + startOffset;
|
|
|
|
var end = match.end + endOffset;
|
|
|
|
var len = line.length;
|
|
|
|
if (start < 0) start = 0;
|
|
|
|
if (end > len) end = len;
|
|
|
|
return line.substring(0, start) + glue + line.substring(end);
|
|
|
|
}
|
|
|
|
|
2022-02-17 19:09:52 +00:00
|
|
|
cutRegexp(line, re, {startOffset = 0, endOffset = 0, glue = ""}) {
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
return cutMatch(line, re.firstMatch(line),
|
2017-04-20 16:08:27 +00:00
|
|
|
startOffset: startOffset, endOffset: endOffset, glue: glue);
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
}
|
|
|
|
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
/// Removes the rest of [line] starting from the beginning of the
|
|
|
|
/// given [match], and adjusting with the given [offset]. If there
|
|
|
|
/// is no match then [line] is returned.
|
2022-02-17 19:09:52 +00:00
|
|
|
cutFromMatch(line, match, {offset = 0, glue = ""}) {
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
if (match == null) return line;
|
|
|
|
return line.substring(0, match.start + offset) + glue;
|
|
|
|
}
|
|
|
|
|
2022-02-17 19:09:52 +00:00
|
|
|
cutFromRegexp(line, re, {offset = 0, glue = ""}) {
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
return cutFromMatch(line, re.firstMatch(line), offset: offset, glue: glue);
|
|
|
|
}
|
|
|
|
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
isWsOnly(line) => line.contains(whitespaceAllRE);
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
isCommentOnly(line) => line.startsWith("%");
|
|
|
|
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
/// Returns the end-of-line character at the end of [line], if any,
|
|
|
|
/// otherwise returns the empty string.
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
justEol(line) {
|
|
|
|
return line.endsWith("\n") ? "\n" : "";
|
|
|
|
}
|
|
|
|
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
/// Removes the contents of the comment at the end of [line],
|
|
|
|
/// leaving the "%" in place. If no comment is present,
|
|
|
|
/// return [line].
|
|
|
|
///
|
|
|
|
/// NB: it is tempting to remove everything from the '%' and out,
|
|
|
|
/// including the final newline, if any, but this does not work.
|
|
|
|
/// The problem is that TeX will do exactly this, but then it will
|
|
|
|
/// add back a character that depends on its state (S, M, or N),
|
|
|
|
/// and it is tricky to maintain a similar state that matches the
|
|
|
|
/// state of TeX faithfully. Hence, we remove the content of
|
|
|
|
/// comments but do not remove the comments themselves, we just
|
|
|
|
/// leave the '%' at the end of the line and let TeX manage its
|
|
|
|
/// states in a way that does not differ from the file from before
|
|
|
|
/// stripComment.
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
stripComment(line) {
|
|
|
|
if (isCommentOnly(line)) return "%\n";
|
|
|
|
return cutRegexp(line, commentRE, startOffset: 2);
|
|
|
|
}
|
|
|
|
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
/// Reduces a white-space-only [line] to its eol character,
|
|
|
|
/// removes leading ws entirely, and reduces multiple
|
|
|
|
/// white-space chars to one.
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
normalizeWhitespace(line) {
|
|
|
|
var trimLine = line.trimLeft();
|
|
|
|
if (trimLine.isEmpty) return justEol(line);
|
|
|
|
return trimLine.replaceAll(whitespaceRE, " ");
|
|
|
|
}
|
|
|
|
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
/// Reduces sequences of >1 white-space-only lines in [lines] to 1,
|
|
|
|
/// and sequences of >1 comment-only lines to 1. Treats comment-only
|
|
|
|
/// lines as white-space-only when they occur in white-space-only
|
|
|
|
/// line blocks.
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
multilineNormalize(lines) {
|
2017-04-20 16:08:27 +00:00
|
|
|
var afterBlankLines = false; // Does [line] succeed >0 empty lines?
|
|
|
|
var afterCommentLines = false; // Does [line] succeed >0 commentOnly lines?
|
2020-03-23 19:47:52 +00:00
|
|
|
var newLines = [];
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
for (var line in lines) {
|
|
|
|
if (afterBlankLines && afterCommentLines) {
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
// Previous line was both blank and a comment: not possible.
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
throw "Bug, please report to eernst@";
|
|
|
|
} else if (afterBlankLines && !afterCommentLines) {
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
// At least one line before [line] is wsOnly.
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
if (!isWsOnly(line)) {
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
// Blank line block ended.
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
afterCommentLines = isCommentOnly(line);
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
// Special case: It seems to be safe to remove commentOnly lines
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
// after wsOnly lines, so the TeX state must be predictably right;
|
|
|
|
// next line will then be afterCommentLines and be dropped, so
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
// we drop the entire comment block---which is very useful. We can
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
// also consider this comment line to be an empty line, such that
|
|
|
|
// subsequent empty lines can be considered to be in a block of
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
// empty lines. Note that almost all variants of this breaks.
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
if (afterCommentLines) {
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
// _Current_ 'line' is a commentOnly here.
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
afterBlankLines = true;
|
|
|
|
afterCommentLines = false;
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
// Omit addition of [line].
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
} else {
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
// After blanks, but current 'line' is neither blank nor comment.
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
afterBlankLines = false;
|
|
|
|
newLines.add(line);
|
|
|
|
}
|
|
|
|
} else {
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
// Blank line block continues, omit addition of [line].
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
}
|
|
|
|
} else if (!afterBlankLines && afterCommentLines) {
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
// At least one line before [line] is commentOnly.
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
if (!isCommentOnly(line)) {
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
// Comment block ended.
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
afterBlankLines = isWsOnly(line);
|
|
|
|
afterCommentLines = false;
|
|
|
|
newLines.add(line);
|
|
|
|
} else {
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
// Comment block continues, do not add [line].
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
assert(!afterBlankLines && !afterCommentLines);
|
2018-10-10 19:15:30 +00:00
|
|
|
// No wsOnly or commentOnly lines precede [line].
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
afterBlankLines = isWsOnly(line);
|
|
|
|
afterCommentLines = isCommentOnly(line);
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
if (!afterCommentLines) {
|
|
|
|
newLines.add(line);
|
|
|
|
} else {
|
|
|
|
// skip commentOnly line after nonWs/nonComment text.
|
|
|
|
}
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return newLines;
|
|
|
|
}
|
|
|
|
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
/// Selects the elements in the normalization pipeline.
|
2014-11-11 11:39:40 +00:00
|
|
|
normalize(line) => normalizeWhitespace(stripComment(line));
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
|
|
|
|
/// Selects the elements in the significant-spacing block
|
|
|
|
/// normalization pipeline.
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
sispNormalize(line) => stripComment(line);
|
|
|
|
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
// Managing fragments with significant spacing.
|
|
|
|
|
2022-02-17 19:09:52 +00:00
|
|
|
final dartCodeBeginRE = RegExp(r"^\s*\\begin\s*\{dartCode\}");
|
|
|
|
final dartCodeEndRE = RegExp(r"^\s*\\end\s*\{dartCode\}");
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
|
|
|
|
/// Recognizes beginning of dartCode block.
|
|
|
|
sispIsDartBegin(line) => line.contains(dartCodeBeginRE);
|
|
|
|
|
|
|
|
/// Recognizes end of dartCode block.
|
|
|
|
sispIsDartEnd(line) => line.contains(dartCodeEndRE);
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
// Analyzing the input to point out "interesting" lines
|
|
|
|
|
|
|
|
/// Returns the event information for [lines] as determined by the
|
|
|
|
/// given [analyzer]. The method [analyzer.analyze] indicates that a
|
|
|
|
/// line is "uninteresting" by returning null (i.e., no events here),
|
|
|
|
/// and "interesting" lines may be characterized by [analysisFunc] via
|
|
|
|
/// the returned event object.
|
|
|
|
findEvents(lines, analyzer) {
|
2020-03-23 19:47:52 +00:00
|
|
|
var events = [];
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
for (var line in lines) {
|
|
|
|
var event = analyzer.analyze(line);
|
|
|
|
if (event != null) events.add(event);
|
|
|
|
}
|
|
|
|
return events;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Returns RegExp text for recognizing a command occupying a line
|
|
|
|
/// of its own, given the part of the RegExp that recognizes the
|
|
|
|
/// command name, [cmdNameRE]
|
2022-02-17 19:09:52 +00:00
|
|
|
lineCommandRE(cmdNameRE) => RegExp(r"^\s*\\" + cmdNameRE + r"\s*\{.*\}%?\s*$");
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
|
2022-02-17 19:09:52 +00:00
|
|
|
final hashLabelStartRE = RegExp(r"^\s*\\LMLabel\s*\{");
|
|
|
|
final hashLabelEndRE = RegExp(r"\}\s*$");
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
|
|
|
|
final hashMarkRE = lineCommandRE("LMHash");
|
|
|
|
final hashLabelRE = lineCommandRE("LMLabel");
|
|
|
|
final sectioningRE = lineCommandRE("((|sub(|sub))section|paragraph)");
|
|
|
|
final sectionRE = lineCommandRE("section");
|
|
|
|
final subsectionRE = lineCommandRE("subsection");
|
|
|
|
final subsubsectionRE = lineCommandRE("subsubsection");
|
|
|
|
final paragraphRE = lineCommandRE("paragraph");
|
|
|
|
|
|
|
|
/// Returns true iff [line] begins a block of lines that gets a hash value.
|
|
|
|
isHashMarker(line) => line.contains(hashMarkRE);
|
|
|
|
|
|
|
|
/// Returns true iff [line] defines a sectioning label.
|
|
|
|
isHashLabel(line) => line.contains(hashLabelRE);
|
|
|
|
|
|
|
|
/// Returns true iff [line] is a sectioning command resp. one of its
|
|
|
|
/// more specific forms; note that it is assumed that sectioning commands
|
|
|
|
/// do not contain a newline between the command name and the '{'.
|
|
|
|
isSectioningCommand(line) => line.contains(sectioningRE);
|
|
|
|
isSectionCommand(line) => line.contains(sectionRE);
|
|
|
|
isSubsectionCommand(line) => line.contains(subsectionRE);
|
|
|
|
isSubsubsectionCommand(line) => line.contains(subsubsectionRE);
|
|
|
|
isParagraphCommand(line) => line.contains(paragraphRE);
|
|
|
|
|
|
|
|
/// Returns true iff [line] does not end a block of lines that gets
|
|
|
|
/// a hash value.
|
2018-06-18 22:31:32 +00:00
|
|
|
bool isntHashBlockTerminator(line) => !isSectioningCommand(line);
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
|
|
|
|
/// Returns the label text part from [line], based on the assumption
|
|
|
|
/// that isHashLabel(line) returns true.
|
|
|
|
extractHashLabel(line) {
|
|
|
|
var startMatch = hashLabelStartRE.firstMatch(line);
|
|
|
|
var endMatch = hashLabelEndRE.firstMatch(line);
|
2020-02-07 14:41:36 +00:00
|
|
|
if (startMatch != null && endMatch != null) {
|
|
|
|
return line.substring(startMatch.end, endMatch.start);
|
|
|
|
} else {
|
|
|
|
throw "Assertion failure (so this file is both valid nnbd and not)";
|
|
|
|
}
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Event classes: Keep track of relevant information about the LaTeX
|
|
|
|
// source code lines, such as where \LMHash and \LMLabel commands are
|
|
|
|
// used, and how they are embedded in the sectioning structure.
|
|
|
|
|
|
|
|
/// Abstract events, enabling us to [setEndLineNumber] on all events.
|
|
|
|
abstract class HashEvent {
|
|
|
|
/// For events that have an endLineNumber, set it; otherwise ignore.
|
|
|
|
/// The endLineNumber specifies the end of the block of lines
|
|
|
|
/// associated with a given event, for event types concerned with
|
|
|
|
/// blocks of lines rather than single lines.
|
2022-02-17 19:09:52 +00:00
|
|
|
setEndLineNumber(int n) {}
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
|
|
|
|
/// Returns null except for \LMHash{} events, where it returns
|
|
|
|
/// the startLineNumber. This serves to specify a boundary because
|
|
|
|
/// the preceding \LMHash{} block should stop before the line of
|
|
|
|
/// this \LMHash{} command. Note that hash blocks may stop earlier,
|
|
|
|
/// because they cannot contain sectioning commands.
|
2022-02-18 11:11:23 +00:00
|
|
|
int? getStartLineNumber() => null;
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class HashMarkerEvent extends HashEvent {
|
|
|
|
// Line number of first line in block that gets hashed.
|
2022-02-17 19:09:52 +00:00
|
|
|
int startLineNumber;
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
|
|
|
|
// Highest possible number of first line after block that gets
|
|
|
|
// hashed (where the next \LMHash{} occurs). Note that this value
|
|
|
|
// is not known initially (because that line has not yet been
|
|
|
|
// reached), so [endLineNumber] will be initialized in a separate
|
|
|
|
// scan. Also note that the block may end earlier, because a block
|
|
|
|
// ends if it would otherwise include a sectioning command.
|
2022-02-18 11:11:23 +00:00
|
|
|
int? endLineNumber;
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
|
|
|
|
HashMarkerEvent(this.startLineNumber);
|
|
|
|
|
2022-02-17 19:09:52 +00:00
|
|
|
@override
|
|
|
|
setEndLineNumber(int n) {
|
2017-04-20 16:08:27 +00:00
|
|
|
endLineNumber = n;
|
|
|
|
}
|
|
|
|
|
2022-02-17 19:09:52 +00:00
|
|
|
@override
|
|
|
|
int getStartLineNumber() => startLineNumber;
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class HashLabelEvent extends HashEvent {
|
2022-02-17 19:09:52 +00:00
|
|
|
String labelText;
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
HashLabelEvent(this.labelText);
|
|
|
|
}
|
|
|
|
|
|
|
|
class HashAnalyzer {
|
|
|
|
// List of kinds of pending (= most recently seen) sectioning command.
|
|
|
|
// When updating this list, also update sectioningPrefix below.
|
|
|
|
static const PENDING_IS_NONE = 0;
|
|
|
|
static const PENDING_IS_SECTION = 1;
|
|
|
|
static const PENDING_IS_SUBSECTION = 2;
|
|
|
|
static const PENDING_IS_SUBSUBSECTION = 3;
|
|
|
|
static const PENDING_IS_PARAGRAPH = 1;
|
|
|
|
|
|
|
|
var lineNumber = 0;
|
|
|
|
var pendingSectioning = PENDING_IS_NONE;
|
|
|
|
|
|
|
|
HashAnalyzer();
|
|
|
|
|
|
|
|
setPendingToSection() {
|
|
|
|
pendingSectioning = PENDING_IS_SECTION;
|
|
|
|
}
|
|
|
|
|
|
|
|
setPendingToSubsection() {
|
|
|
|
pendingSectioning = PENDING_IS_SUBSECTION;
|
|
|
|
}
|
|
|
|
|
|
|
|
setPendingToSubsubsection() {
|
|
|
|
pendingSectioning = PENDING_IS_SUBSUBSECTION;
|
|
|
|
}
|
|
|
|
|
|
|
|
setPendingToParagraph() {
|
|
|
|
pendingSectioning = PENDING_IS_PARAGRAPH;
|
|
|
|
}
|
|
|
|
|
|
|
|
clearPending() {
|
|
|
|
pendingSectioning = PENDING_IS_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
sectioningPrefix() {
|
|
|
|
switch (pendingSectioning) {
|
2017-04-20 16:08:27 +00:00
|
|
|
case PENDING_IS_SECTION:
|
|
|
|
return "sec:";
|
|
|
|
case PENDING_IS_SUBSECTION:
|
|
|
|
return "subsec:";
|
|
|
|
case PENDING_IS_SUBSUBSECTION:
|
|
|
|
return "subsubsec:";
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
case PENDING_IS_NONE:
|
2022-02-17 19:09:52 +00:00
|
|
|
throw "\\LMHash{..} should only be used after a sectioning command "
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
"(\\section, \\subsection, \\subsubsection, \\paragraph)";
|
|
|
|
default:
|
|
|
|
// set of PENDING_IS_.. was extended, but updates here omitted
|
|
|
|
throw "Bug, please report to eernst@";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
analyze(line) {
|
|
|
|
var currentLineNumber = lineNumber++;
|
|
|
|
if (isHashMarker(line)) {
|
2022-02-17 19:09:52 +00:00
|
|
|
return HashMarkerEvent(currentLineNumber);
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
} else if (isHashLabel(line)) {
|
|
|
|
var labelText = sectioningPrefix() + extractHashLabel(line);
|
2022-02-17 19:09:52 +00:00
|
|
|
return HashLabelEvent(labelText);
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
} else {
|
|
|
|
// No events to emit, but we may need to note state changes
|
|
|
|
if (isSectionCommand(line)) {
|
|
|
|
setPendingToSection();
|
|
|
|
} else if (isSubsectionCommand(line)) {
|
|
|
|
setPendingToSubsection();
|
|
|
|
} else if (isSubsubsectionCommand(line)) {
|
|
|
|
setPendingToSubsubsection();
|
|
|
|
} else if (isParagraphCommand(line)) {
|
|
|
|
setPendingToParagraph();
|
|
|
|
} else {
|
|
|
|
// No state changes.
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
findHashEvents(lines) {
|
|
|
|
// Create the list of events, omitting endLineNumbers.
|
2022-02-17 19:09:52 +00:00
|
|
|
var events = findEvents(lines, HashAnalyzer());
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
// Set the endLineNumbers.
|
|
|
|
var currentEndLineNumber = lines.length;
|
|
|
|
for (var event in events.reversed) {
|
|
|
|
event.setEndLineNumber(currentEndLineNumber);
|
|
|
|
var nextEndLineNumber = event.getStartLineNumber();
|
|
|
|
if (nextEndLineNumber != null) currentEndLineNumber = nextEndLineNumber;
|
|
|
|
}
|
|
|
|
return events;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
// Removal of non-normative elements of the text (rationale, commentary).
|
|
|
|
|
|
|
|
/// Returns [line] without the command [cmdName] (based on a match
|
|
|
|
/// on "\\cmdName\s*{..}") starting at [startIndex]; note that it is
|
|
|
|
/// assumed but not checked that [line] contains "\\cmdType\s*{..",
|
|
|
|
/// and note that the end of the {..} block is found via brace matching
|
|
|
|
/// (i.e., nested {..} blocks are handled), but it may break if '{' is
|
|
|
|
/// made an active character etc.etc.
|
|
|
|
removeCommand(line, cmdName, startIndex) {
|
2017-04-20 16:08:27 +00:00
|
|
|
const BACKSLASH = 92; // char code for '\\'.
|
|
|
|
const BRACE_BEGIN = 123; // char code for '{'.
|
|
|
|
const BRACE_END = 125; // char code for '}'.
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
|
|
|
|
var blockStartIndex = startIndex + cmdName.length + 1;
|
|
|
|
while (blockStartIndex < line.length &&
|
2017-04-20 16:08:27 +00:00
|
|
|
line.codeUnitAt(blockStartIndex) != BRACE_BEGIN) {
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
blockStartIndex++;
|
|
|
|
}
|
|
|
|
blockStartIndex++;
|
|
|
|
if (blockStartIndex > line.length) {
|
|
|
|
throw "Bug, please report to eernst@";
|
|
|
|
}
|
|
|
|
// [blockStartIndex] has index just after '{'.
|
|
|
|
|
2017-04-20 16:08:27 +00:00
|
|
|
var afterEscape = false; // Is true iff [index] is just after '{'.
|
|
|
|
var braceLevel = 1; // Have seen so many '{'s minus so many '}'s.
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
|
|
|
|
for (var index = blockStartIndex; index < line.length; index++) {
|
|
|
|
switch (line.codeUnitAt(index)) {
|
|
|
|
case BRACE_BEGIN:
|
|
|
|
if (afterEscape) {
|
|
|
|
afterEscape = false;
|
|
|
|
} else {
|
|
|
|
braceLevel++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case BRACE_END:
|
|
|
|
if (afterEscape) {
|
|
|
|
afterEscape = false;
|
|
|
|
} else {
|
|
|
|
braceLevel--;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case BACKSLASH:
|
|
|
|
afterEscape = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
afterEscape = false;
|
|
|
|
}
|
|
|
|
if (braceLevel == 0) {
|
|
|
|
return line.substring(0, startIndex) + line.substring(index + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Removal failed; we consider this to mean that the input is ill-formed.
|
|
|
|
throw "Unmatched braces";
|
|
|
|
}
|
|
|
|
|
2022-02-17 19:09:52 +00:00
|
|
|
final commentaryRE = RegExp(r"\\commentary\s*\{");
|
|
|
|
final rationaleRE = RegExp(r"\\rationale\s*\{");
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
|
|
|
|
/// Removes {}-balanced '\commentary{..}' commands from [line].
|
|
|
|
removeCommentary(line) {
|
|
|
|
var match = commentaryRE.firstMatch(line);
|
|
|
|
if (match == null) return line;
|
|
|
|
return removeCommentary(removeCommand(line, r"commentary", match.start));
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Removes {}-balanced '\rationale{..}' commands from [line].
|
|
|
|
removeRationale(line) {
|
|
|
|
var match = rationaleRE.firstMatch(line);
|
|
|
|
if (match == null) return line;
|
|
|
|
return removeRationale(removeCommand(line, r"rationale", match.start));
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Removes {}-balanced '\commentary{..}' and '\rationale{..}'
|
|
|
|
/// commands from [line], then normalizes its white-space.
|
|
|
|
simplifyLine(line) {
|
|
|
|
var simplerLine = removeCommentary(line);
|
|
|
|
simplerLine = removeRationale(simplerLine);
|
|
|
|
simplerLine = normalizeWhitespace(simplerLine);
|
|
|
|
return simplerLine;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
// Recognition of line blocks, insertion of block hash into \LMHash{}.
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
|
2022-02-17 19:09:52 +00:00
|
|
|
final latexArgumentRE = RegExp(r"\{.*\}");
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
cleanupLine(line) => cutRegexp(line, commentRE, startOffset: 1).trimRight();
|
|
|
|
|
|
|
|
/// Returns concatenation of all lines from [startIndex] in [lines] until
|
|
|
|
/// a hash block terminator is encountered or [nextIndex] reached (if so,
|
|
|
|
/// the line lines[nextIndex] itself is not included); each line is cleaned
|
|
|
|
/// up using [cleanupLine], and " " is inserted between the lines gathered.
|
2017-04-20 16:08:27 +00:00
|
|
|
gatherLines(lines, startIndex, nextIndex) => lines
|
|
|
|
.getRange(startIndex, nextIndex)
|
|
|
|
.takeWhile(isntHashBlockTerminator)
|
|
|
|
.map(cleanupLine)
|
|
|
|
.join(" ");
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
|
|
|
|
/// Computes the hash value for the line block starting at [startIndex]
|
|
|
|
/// in [lines], stopping just before [nextIndex]. SIDE EFFECT:
|
|
|
|
/// Outputs the simplified text and its hash value to [listSink].
|
|
|
|
computeHashValue(lines, startIndex, nextIndex, listSink) {
|
|
|
|
final gatheredLine = gatherLines(lines, startIndex, nextIndex);
|
|
|
|
final simplifiedLine = simplifyLine(gatheredLine);
|
|
|
|
listSink.write(" % $simplifiedLine\n");
|
2019-04-09 02:06:09 +00:00
|
|
|
var digest = sha1.convert(utf8.encode(simplifiedLine));
|
2016-04-15 17:00:24 +00:00
|
|
|
return digest.bytes;
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
}
|
|
|
|
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
computeHashString(lines, startIndex, nextIndex, listSink) =>
|
2017-04-20 16:08:27 +00:00
|
|
|
hex.encode(computeHashValue(lines, startIndex, nextIndex, listSink));
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
/// Computes and adds hashes to \LMHash{} lines in [lines] (which
|
|
|
|
/// must be on the line numbers specified in [hashEvents]), and emits
|
|
|
|
/// sectioning markers and hash values to [listSink], along with
|
|
|
|
/// "comments" containing the simplified text (using the format
|
|
|
|
/// ' % <text>', where the text is one, long line, for easy grepping
|
|
|
|
/// etc.).
|
|
|
|
addHashMarks(lines, hashEvents, listSink) {
|
|
|
|
for (var hashEvent in hashEvents) {
|
|
|
|
if (hashEvent is HashMarkerEvent) {
|
|
|
|
var start = hashEvent.startLineNumber;
|
|
|
|
var end = hashEvent.endLineNumber;
|
|
|
|
final hashValue = computeHashString(lines, start + 1, end, listSink);
|
2022-05-10 00:08:42 +00:00
|
|
|
lines[start] = lines[start].replaceAll(latexArgumentRE, "{$hashValue}");
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
listSink.write(" $hashValue\n");
|
|
|
|
} else if (hashEvent is HashLabelEvent) {
|
|
|
|
listSink.write("${hashEvent.labelText}\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
/// Transforms LaTeX input to LaTeX output plus hash value list file.
|
2017-04-20 16:08:27 +00:00
|
|
|
main([args]) {
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
if (args.length != 3) {
|
|
|
|
print("Usage: addlatexhash.dart <input-file> <output-file> <list-file>");
|
|
|
|
throw "Received ${args.length} arguments, expected three";
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
}
|
|
|
|
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
// Get LaTeX source.
|
2022-02-17 19:09:52 +00:00
|
|
|
var inputFile = File(args[0]);
|
2014-11-11 11:39:40 +00:00
|
|
|
assert(inputFile.existsSync());
|
|
|
|
var lines = inputFile.readAsLinesSync();
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
|
|
|
|
// Will hold LaTeX source with normalized spacing etc., plus hash values.
|
2022-02-17 19:09:52 +00:00
|
|
|
var outputFile = File(args[1]);
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
|
|
|
|
// Will hold hierarchical list of hash values.
|
2022-02-17 19:09:52 +00:00
|
|
|
var listFile = File(args[2]);
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
var listSink = listFile.openWrite();
|
|
|
|
|
|
|
|
// Perform single-line normalization.
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
var inDartCode = false;
|
2020-03-23 19:47:52 +00:00
|
|
|
var normalizedLines = [];
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
|
|
|
|
for (var line in lines) {
|
|
|
|
if (sispIsDartBegin(line)) {
|
|
|
|
inDartCode = true;
|
|
|
|
} else if (sispIsDartEnd(line)) {
|
|
|
|
inDartCode = false;
|
|
|
|
}
|
|
|
|
if (inDartCode) {
|
2022-05-10 00:08:42 +00:00
|
|
|
normalizedLines.add(sispNormalize("$line\n"));
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
} else {
|
2022-05-10 00:08:42 +00:00
|
|
|
normalizedLines.add(normalize("$line\n"));
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
// Perform multi-line normalization.
|
|
|
|
normalizedLines = multilineNormalize(normalizedLines);
|
|
|
|
|
|
|
|
// Insert hash values.
|
|
|
|
var hashEvents = findHashEvents(normalizedLines);
|
|
|
|
addHashMarks(normalizedLines, hashEvents, listSink);
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
|
Working insertion of hash values; added a few labels in spec
Hash values are now computed for each "paragraph" starting with \LMHash
(which includes subsequent grammar, dartCode, itemize blocks, but stops
at \section-like commands). Now addlatexhash.dart expects three arguments
(first the source latex file, then the destination simplified and
hash-value-annotated latex source file, and finally a file name used to
create the list of hash values emitted). Adjusted testing accordingly.
Added a test for robustness of the hash value generation: It is checked
that lots of different "unimportant" changes make no difference for the
generated hash values (e.g., we can add/remove comments, change white
space, add \commentary{..} etc. without changing the hash values).
In order to ensure that all "structure" commands in the spec have a label,
I added an \LMLabel{..} a handful of places, following the style which is
used throughout the spec.
In dart.sty, the \renewcommand that made \LMHash{} produce a fixed
hash value has been removed such that the actual hash values are now
inserted into the generated spec PDF/DVI file. Tests have been adjusted
to handle this difference between the spec with and without hash values
when comparing the two.
R=gbracha@google.com, lrn@google.com, ricow@google.com
Committed: https://code.google.com/p/dart/source/detail?r=41658
Reverted: https://code.google.com/p/dart/source/detail?r=41662
Review URL: https://codereview.chromium.org//652993005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41687 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-12 08:41:55 +00:00
|
|
|
// Produce/finalize output.
|
|
|
|
outputFile.writeAsStringSync(normalizedLines.join());
|
|
|
|
listSink.close();
|
Introduced hash valued location markers in the spec
Introduced support for adding SHA1 hash valued location markers
at several levels in the language specification, added long explanatory
comment at the end, added a script 'addlatexhash.dart' to normalize
spacing, remove comments, etc., in the spec, such that the hash values
are more robust than they would be with a direct usage of the spec.
The script passes the "dvi2tty test", that is, when the location markers
are empty, the resulting *.dvi files created from dartLangSpec.tex and
from the version processed by the script give rise to the same text via
dvi2tty, i.e., the script does not destroy the spec.
R=gbracha@google.com, ricow@google.com
Review URL: https://codereview.chromium.org//646003002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41191 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 14:02:23 +00:00
|
|
|
}
|