5. 亳仆舒仄亳亠从亳 仂仄亳亠仄亶 从仂亟
string res = "";
for(i = 0; i < l; i++)
res = "()" + res;
use(res);
仗仗仂从亳仄舒亳
("()")*
舒仄仄舒亳从舒
start ::= s
s ::= LBR s RBR s
s ::=
亠 舒亰弍仂舒 (SPPF)
start_rule
prod 2
s !
prod 0 prod 0
LBR s RBR
eps
LBR s RBR
eps
弌亠仄仆 亳亞仂亠于 8 亠于舒仍 2016亞. 5 / 13
6. 舒亟舒舒: 仗亳仄亠仆亠仆亳亠 舒仆舒仍亳亰舒 仂从仂于 于舒亢亠仆亳亶 亟仍
JavaScript eval
丶亠仍: 舒仆仍亳 舒仆亟舒仆仂亞仂 eval 于 "弍亠亰仂仗舒仆亶"
Martin Lester. Information Flow Analysis for a Dynamically Typed
Functional Language with Staged Metaprogramming
Martin Lester. Analysing Eval using Staged Metaprogramming
仍亠亟仂于舒亠仍从舒 亰舒亟舒舒: 亟亳仗仍仂仄, 仗弍仍亳从舒亳亳
舒亰弍亳于舒亠 仆舒 2 仗仂亟亰舒亟舒亳
仂仍亠仆亳亠 舒仗仗仂从亳仄舒亳亳
丐舒仆仍亳 SPPF 于 "弍亠亰仂仗舒仆亶 eval"
弌亠仄仆 亳亞仂亠于 8 亠于舒仍 2016亞. 6 / 13
7. 舒亟舒舒: 亳仗仂仍亰仂于舒仆亳亠 SPPF 于 舒弍舒从仆仂仄
亳仆舒从亳亠从仂仄 舒仆舒仍亳亰亠
弍舒从仆亶 亳仆舒从亳亠从亳亶 舒仆舒仍亳亰 仂亟亳仆 亳亰 仗仂亟仂亟仂于 从
舒仆舒仍亳亰 亟亳仆舒仄亳亠从亳 仂仄亳亠仄仂亞仂 从仂亟舒
K. G. Doh, H. Kim, D. A. Schmidt. Static Validation of Dynamically
Generated HTML Documents Based on Abstract Parsing and Semantic
Processing
E. Verbitskaia, S. Grigorev, D. Avdyukhin. Relaxed Parsing of Regular
Approximations of String-Embedded Languages
亠舒仍亳亰仂于舒 于亳仍亠仆亳亠 亠仄舒仆亳从亳 仗仂 舒礆
弌舒于仆亳 仆舒亳仄 仗仂亟仂亟仂仄
仄仂亢仆仂 仍亳 亳仗仂仍亰仂于舒 SPPF
亳仗仍仂仄, 仗弍仍亳从舒亳亳
弌亠仄仆 亳亞仂亠于 8 亠于舒仍 2016亞. 7 / 13
9. 弌亠亳亳从舒亳仂仆仆仂亠 仗仂亞舒仄仄亳仂于舒仆亳亠
F* (https://www.fstar-lang.org/tutorial/)
Coq
Agda
...
val sort: l:list int ->
Tot (m:list int{sorted m
/ (forall i. mem i l = mem i m)})
(decreases (length l))
let rec sort l = match l with
| [] -> []
| pivot::tl ->
let hi, lo = partition (cmp pivot) tl in
let l = append (sort lo) (pivot::sort hi) in
dedup l
弌亠仄仆 亳亞仂亠于 8 亠于舒仍 2016亞. 9 / 13