# HG changeset patch # User Nobuyasu Oshiro # Date 1338701287 -32400 # Node ID d6ac7ec2c6a77b39e2af995af7fb862fbbf77797 # Parent 636a4f0cd8f45dd322246c27693e1a7e5e5b8e2f# Parent afa536eef659947e592a0019ee913c112f0088bd merge 5,6 diff -r 636a4f0cd8f4 -r d6ac7ec2c6a7 DPP/Makefile diff -r 636a4f0cd8f4 -r d6ac7ec2c6a7 automaton/a.out Binary file automaton/a.out has changed diff -r 636a4f0cd8f4 -r d6ac7ec2c6a7 automaton/fautomaton1.cbc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/automaton/fautomaton1.cbc Sun Jun 03 14:28:07 2012 +0900 @@ -0,0 +1,107 @@ +/* + * Implementation of the fininte automat by CbC + * This is test program + * + * Finite automaton M. + * M = ({q1,q2},{0,1}, delta, q1, {q2}) + * + * delta = + * |0 1 + * ----------- + * q1|q1 q2 + * q1|q1 q2 + */ + +#include +#include // exit() +#include // strlen() + +__code q1(char *c, int size, int count); +__code q2(char *c, int size, int count); + + +__code print_error() +{ + printf("error\n"); + exit(0); +} + +__code no_recognize() +{ + printf("no recognize\n"); +} + +__code recognize() +{ + printf("recognize\n"); +} + +int _isspace(char c) +{ + return c == ' ' || c == '\t'; +} + +char *skipchar(char *c) +{ + + while(_isspace(*c)) { + c++; + } + + return c; +} + +__code q1(char *c, int size, int count) +{ +// char *ch = skipchar(c); + char *ch = c; + ch++; + count++; + switch(*c) { + case '0': + goto q1(ch, size, count); + break; + case '1': + goto q2(ch, size, count); + break; + default: + if(count >= size) + goto no_recognize(); + else + goto recognize(); + + } + +} + +__code q2(char *c, int size, int count) +{ +// char *ch = skipchar(c); + char *ch = c; + ch++; + count++; + switch(*c) { + case '0': + goto q1(ch, size, count); + break; + case '1': + goto q2(ch, size, count); + break; + default: + if(count >= size) + goto recognize(); + else + goto no_recognize(); + } + +} + + +int main(int argc, char *argv[]) +{ + if(argc == 1 ) goto print_error(); + int size = strlen(argv[1]); + char *c = argv[1]; + goto q1(c, size, 0); + return 0; +} diff -r 636a4f0cd8f4 -r d6ac7ec2c6a7 automaton/test.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/automaton/test.c Sun Jun 03 14:28:07 2012 +0900 @@ -0,0 +1,19 @@ +#include + +int main(int argc, char *argv[]) { + long size = sizeof(argv[1])/sizeof(char); + char *c = argv[0]; + printf("argv[0] = %s\n",argv[0]); + + printf("size = %ld\n",size); + long i; + for(i=0; i