Skip to content

Commit

Permalink
*
Browse files Browse the repository at this point in the history
  • Loading branch information
neauoire committed Dec 14, 2024
1 parent c80fd55 commit e58008b
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 16 deletions.
2 changes: 1 addition & 1 deletion etc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
3c4d <a href='noton.c.txt'>noton.c.txt</a>
16ae <a href='1th.c.txt'>1th.c.txt</a>
3daa <a href='nasu.c.txt'>nasu.c.txt</a>
0de9 <a href='vera.c.txt'>vera.c.txt</a>
0f74 <a href='vera.c.txt'>vera.c.txt</a>
fa1f <a href='left2024.tal.txt'>left2024.tal.txt</a>
053e <a href='line2d.c.txt'>line2d.c.txt</a>
80d6 <a href='dexe.tal.txt'>dexe.tal.txt</a>
Expand Down
39 changes: 27 additions & 12 deletions etc/vera.c.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,36 @@ find_symbol(char *s)
}

static char *
walk_symbol(char *s, int *id)
walk_number(char *s, int *count)
{
int value = 0;
s = walk_ws(s + 1);
while(*s && *s >= '0' && *s <= '9')
value *= 10, value += *s - '0', s++;
*count = value;
return s;
}

static char *
walk_symbol(char *s, int *id, int *count)
{
s = walk_ws(s);
*id = find_symbol(s);
if(*id > -1) {
while(s[0] && s[0] != key && s[0] != ',')
*s++;
while(s[0] && s[0] != key && s[0] != ',' && s[0] != ':')
s++;
if(s[0] == ':')
s = walk_number(s, count);
return s;
}
*_syms = _dict;
while(s[0] && s[0] != key && s[0] != ',') {
while(s[0] && s[0] != key && s[0] != ',' && s[0] != ':') {
*_dict++ = *s++;
if(*s == ' ')
s = walk_ws(s), *_dict++ = ' ';
}
if(s[0] == ':')
s = walk_number(s, count);
trim(_syms);
*_dict++ = 0, *id = _syms - &syms[0], _syms++;
return s;
Expand All @@ -85,11 +100,11 @@ walk_symbol(char *s, int *id)
static char *
walk_rule(char *s)
{
int id, valid = 1;
int id, valid = 1, count = 1;
/* lhs */
while(valid) {
s = walk_symbol(s, &id);
rules[_rules][id]++;
s = walk_symbol(s, &id, &count);
rules[_rules][id] += count;
if(s[0] == ',')
s++, valid = 1;
else
Expand All @@ -102,8 +117,8 @@ walk_rule(char *s)
s = walk_ws(s);
valid = s[0] != key;
while(valid) {
s = walk_symbol(s, &id);
rules[_rules][id + SYM_SZ]++;
s = walk_symbol(s, &id, &count);
rules[_rules][id + SYM_SZ] += count;
if(s[0] == ',')
s++, valid = 1;
else
Expand All @@ -116,9 +131,9 @@ walk_rule(char *s)
static char *
walk_fact(char *s)
{
int id, valid = 1;
int id, valid = 1, count = 1;
while(valid) {
s = walk_symbol(s, &id), acc[id]++;
s = walk_symbol(s, &id, &count), acc[id] += count;
if(s[0] == ',')
s++, valid = 1;
else
Expand Down Expand Up @@ -153,7 +168,7 @@ prinths(int *hs)
int i;
for(i = 0; i < SYM_SZ; i++) {
if(hs[i] > 1)
printf("%s^%d ", syms[i], hs[i]);
printf("%s:%d ", syms[i], hs[i]);
else if(hs[i])
printf("%s, ", syms[i]);
}
Expand Down
9 changes: 8 additions & 1 deletion site/rewriting.html
Original file line number Diff line number Diff line change
Expand Up @@ -848,11 +848,18 @@ <h3>Facts</h3>
a last fact
</pre>

<p>Whitespace only exists to separate the words in a fact, but are not significant when matching facts. These 3 facts are equal:</p>
<p>Whitespace only exists to separate the words in a fact, but are not
significant when matching facts. These 3 facts are equal:</p>
<pre>
|| a new fact, a new fact, a new fact
</pre>

<p>Multiple instances of the same facts can be created by using the colon
character. There are same amount of instances of these two facts:</p>
<pre>
|| a, a, a, a, b:4
</pre>

<h3>Rules</h3>
<p>A <b>rule </b>is made of a left and often a right side, and indicate facts to
remove and replace in the bag.</p>
Expand Down
9 changes: 8 additions & 1 deletion site/vera.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,18 @@ <h3>Facts</h3>
a last fact
</pre>

<p>Whitespace only exists to separate the words in a fact, but are not significant when matching facts. These 3 facts are equal:</p>
<p>Whitespace only exists to separate the words in a fact, but are not
significant when matching facts. These 3 facts are equal:</p>
<pre>
|| a new fact, a new fact, a new fact
</pre>

<p>Multiple instances of the same facts can be created by using the colon
character. There are same amount of instances of these two facts:</p>
<pre>
|| a, a, a, a, b:4
</pre>

<h3>Rules</h3>
<p>A <b>rule </b>is made of a left and often a right side, and indicate facts to
remove and replace in the bag.</p>
Expand Down
9 changes: 8 additions & 1 deletion src/htm/vera.htm
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,18 @@ <h3>Facts</h3>
a last fact
</pre>

<p>Whitespace only exists to separate the words in a fact, but are not significant when matching facts. These 3 facts are equal:</p>
<p>Whitespace only exists to separate the words in a fact, but are not
significant when matching facts. These 3 facts are equal:</p>
<pre>
|| a new fact, a new fact, a new fact
</pre>

<p>Multiple instances of the same facts can be created by using the colon
character. There are same amount of instances of these two facts:</p>
<pre>
|| a, a, a, a, b:4
</pre>

<h3>Rules</h3>
<p>A <b>rule </b>is made of a left and often a right side, and indicate facts to
remove and replace in the bag.</p>
Expand Down

0 comments on commit e58008b

Please sign in to comment.