From 016f9852d6fdcdbd929346ae288aa17437b2dd6f Mon Sep 17 00:00:00 2001 From: Ted Nyman Date: Sun, 29 Dec 2013 12:24:02 -0800 Subject: [PATCH] Update prolog samples --- lib/linguist/samples.json | 62 +++++++++++++++++++++++++++++-- samples/Prolog/test-prolog.prolog | 12 ++++++ samples/Prolog/turing.pl | 21 +++++++++++ 3 files changed, 92 insertions(+), 3 deletions(-) create mode 100644 samples/Prolog/test-prolog.prolog create mode 100644 samples/Prolog/turing.pl diff --git a/lib/linguist/samples.json b/lib/linguist/samples.json index d3b01fa1..8071844b 100644 --- a/lib/linguist/samples.json +++ b/lib/linguist/samples.json @@ -319,6 +319,10 @@ "Processing": [ ".pde" ], + "Prolog": [ + ".pl", + ".prolog" + ], "Protocol Buffer": [ ".proto" ], @@ -519,8 +523,8 @@ ".gemrc" ] }, - "tokens_total": 439417, - "languages_total": 511, + "tokens_total": 439684, + "languages_total": 513, "tokens": { "ABAP": { "*/**": 1, @@ -38586,6 +38590,56 @@ "PI": 1, "TWO_PI": 1 }, + "Prolog": { + "-": 38, + "male": 3, + "(": 29, + "john": 2, + ")": 29, + ".": 17, + "peter": 3, + "female": 2, + "vick": 2, + "christie": 3, + "parents": 4, + "brother": 1, + "X": 3, + "Y": 2, + "F": 2, + "M": 2, + "turing": 1, + "Tape0": 2, + "Tape": 2, + "perform": 4, + "q0": 1, + "[": 12, + "]": 12, + "Ls": 12, + "Rs": 16, + "reverse": 1, + "Ls1": 4, + "append": 1, + "qf": 1, + "Q0": 2, + "Ls0": 6, + "Rs0": 6, + "symbol": 3, + "Sym": 6, + "RsRest": 2, + "once": 1, + "rule": 1, + "Q1": 2, + "NewSym": 2, + "Action": 2, + "action": 4, + "|": 7, + "Rs1": 2, + "b": 2, + "left": 4, + "stay": 1, + "right": 1, + "L": 2 + }, "Protocol Buffer": { "package": 1, "tutorial": 1, @@ -46930,6 +46984,7 @@ "PostScript": 107, "PowerShell": 12, "Processing": 74, + "Prolog": 267, "Protocol Buffer": 63, "Python": 5715, "R": 175, @@ -47068,6 +47123,7 @@ "PostScript": 1, "PowerShell": 2, "Processing": 1, + "Prolog": 2, "Protocol Buffer": 1, "Python": 7, "R": 2, @@ -47111,5 +47167,5 @@ "Xtend": 2, "YAML": 1 }, - "md5": "3969c4c97eb1dc3e7063e0478775dd9a" + "md5": "2418026a91f287eda7faac9b75d06236" } \ No newline at end of file diff --git a/samples/Prolog/test-prolog.prolog b/samples/Prolog/test-prolog.prolog new file mode 100644 index 00000000..b1b34b67 --- /dev/null +++ b/samples/Prolog/test-prolog.prolog @@ -0,0 +1,12 @@ +-/* Prolog test file */ + -male(john). + -male(peter). + - + -female(vick). + -female(christie). + - + -parents(john, peter, christie). + -parents(vick, peter, christie). + - + -/* X is a brother of Y */ + -brother(X, Y) :- male(X), parents(X, F, M), parents(Y, F, M). diff --git a/samples/Prolog/turing.pl b/samples/Prolog/turing.pl new file mode 100644 index 00000000..a7c36e84 --- /dev/null +++ b/samples/Prolog/turing.pl @@ -0,0 +1,21 @@ +-turing(Tape0, Tape) :- + - perform(q0, [], Ls, Tape0, Rs), + - reverse(Ls, Ls1), + - append(Ls1, Rs, Tape). + - + -perform(qf, Ls, Ls, Rs, Rs) :- !. + -perform(Q0, Ls0, Ls, Rs0, Rs) :- + - symbol(Rs0, Sym, RsRest), + - once(rule(Q0, Sym, Q1, NewSym, Action)), + - action(Action, Ls0, Ls1, [NewSym|RsRest], Rs1), + - perform(Q1, Ls1, Ls, Rs1, Rs). + - + -symbol([], b, []). + -symbol([Sym|Rs], Sym, Rs). + - + -action(left, Ls0, Ls, Rs0, Rs) :- left(Ls0, Ls, Rs0, Rs). + -action(stay, Ls, Ls, Rs, Rs). + -action(right, Ls0, [Sym|Ls0], [Sym|Rs], Rs). + - + -left([], [], Rs0, [b|Rs0]). + -left([L|Ls], Ls, Rs, [L|Rs]).