Example #1
0
IntegerSyntax::IntegerSyntax()
{
    SYNTAX("int");

    sign_ = DEFINE("Sign", RANGE("+-"));

    binNumber_ =
        DEFINE("BinNumber",
            GLUE(
                STRING("0b"),
                REPEAT(1, 256, RANGE('0', '1'))
            )
        );

    octNumber_ =
        DEFINE("OctNumber",
            GLUE(
                CHAR('0'),
                REPEAT(1, 24, RANGE('0', '9'))
            )
        );

    hexNumber_ =
        DEFINE("HexNumber",
            GLUE(
                STRING("0x"),
                REPEAT(1, 20,
                    CHOICE(
                        RANGE('0', '9'),
                        RANGE('a', 'f'),
                        RANGE('A', 'F')
                    )
                )
            )
        );

    decNumber_ =
        DEFINE("DecNumber",
            REPEAT(1, 20,
                RANGE('0', '9')
            )
        );

    literal_ =
        DEFINE("Literal",
            GLUE(
                REPEAT(0, 1, REF("Sign")),
                CHOICE(
                    REF("BinNumber"),
                    REF("OctNumber"),
                    REF("HexNumber"),
                    REF("DecNumber")
                ),
                NOT(RANGE(".eE"))
            )
        );

    ENTRY("Literal");
    LINK();
}
Example #2
0
EscapeSequenceSyntax::EscapeSequenceSyntax()
{
	number_ = DEFINE("number", REPEAT(1, 4, RANGE('0', '9')));
	title_ = DEFINE("title", REPEAT(1, RANGE(32, 255)));
	
	controlSequence_ =
		DEFINE("controlSequence",
			GLUE(
				CHAR(27),
				CHOICE(
					GLUE(
						// csi sequences
						CHAR('['),
						REPEAT(0, 1, RANGE("?>")),
						REPEAT(0, 15,
							GLUE(
								REF("number"),
								REPEAT(0, 1, CHAR(';'))
							)
						),
						RANGE(32, 255)
					),
					GLUE(
						// osc sequences
						CHAR(']'),
						REF("number"),
						CHAR(';'),
						REF("title"),
						CHAR(7)
					),
					GLUE(
						// two or three byte escape sequences
						REPEAT(0, 1,
							// character set selection, etc.
							RANGE("()%")
						),
						// other
						RANGE(33, 127)
					)
				)
			)
		);
	
	ENTRY("controlSequence");
	LINK();
}
Example #3
0
void Mes_V()
{
	ADMUX = (0<<REFS1) | (1<<REFS0) | GLUE(ADC, 0);
	ADC_RUNTIME(&Mes_tmp);
	Vf = Mes_tmp;					//resistor divider scale (7.2 + 11,8) / 7,2 
	Vf = Vf * SOLAR_Vcc / 1023;
	sprintf(bufor,"%.2f",Vf);
	lcd_swrite("V="); lcd_swrite(bufor);
}
ScriptDiscoverySyntax::ScriptDiscoverySyntax(const char *suffix)
{
    DEFINE("FirstLine",
        GLUE(
            STRING("#!"),
            LAZY_REPEAT(OTHER('\n')),
            STRING(suffix)
        )
    );

    ENTRY("FirstLine");
    LINK();
}
Example #5
0
void Mes_I()
{
	ADMUX = (0<<REFS1) | (1<<REFS0) | GLUE(ADC, 2);
	ADC_RUNTIME(&Mes_tmp);

	if (Mes_tmp <= I_flor) //bias for eliminate of minus mA
	{
		I_flor = Mes_tmp;
	}
	If = (Mes_tmp-I_flor)*Factor;
	sprintf(bufor,"%.3f",If);
	lcd_swrite(" I="); lcd_swrite(bufor);
}
Example #6
0
void ADC_ACS712_Calib()
{
	//calibration of I mes
	ADMUX = (0<<REFS1) | (1<<REFS0) | GLUE(ADC, 2);
	_delay_ms(100);
	
	uint8_t i = 0;
	for (i = 0; i < NUM_FOR_MES; i++)
	{
		ADC_RUNTIME(&Mes_tmp);
		I_flor = I_flor + Mes_tmp;
	}
	lcd_clear();
	lcd_home();
	lcd_swrite("I mes cal");
	lcd_gotoxy(0,1);
	_delay_ms(100);
	I_flor = I_flor / NUM_FOR_MES;
	lcd_swrite("ADC 0: "); lcd_iwrite(I_flor);
	
	_delay_ms(2000);
}
Example #7
0
TOK822 *tok822_parse_limit(const char *str, int tok_count_limit)
{
	TOK822 *head;
	TOK822 *tail;
	TOK822 *right;
	TOK822 *first_token;
	TOK822 *last_token;
	TOK822 *tp;
	int     state;

	/*
	 * First, tokenize the string, from left to right. We are not allowed to
	 * throw away any information that we do not understand. With a flat
	 * token list that contains all tokens, we can always convert back to
	 * string form.
	 */
	if ((first_token = tok822_scan_limit(str, &last_token, tok_count_limit)) == 0)
		return (0);

	/*
	 * For convenience, sandwich the token list between two sentinel tokens.
	 */
#define GLUE(left,rite) { left->next = rite; rite->prev = left; }

	head = tok822_alloc(0, (char *) 0);
	GLUE(head, first_token);
	tail = tok822_alloc(0, (char *) 0);
	GLUE(last_token, tail);

	/*
	 * Next step is to transform the token list into a parse tree. This is
	 * done most conveniently from right to left. If there is something that
	 * we do not understand, just leave it alone, don't throw it away. The
	 * address information that we're looking for sits in-between the current
	 * node (tp) and the one called right. Add missing commas on the fly.
	 */
	state = DO_WORD;
	right = tail;
	tp = tail->prev;
	while (tp->type) {
		if (tp->type == TOK822_COMMENT) {	/* move comment to the side */
			MOVE_COMMENT_AND_CONTINUE(tp, right);
		} else if (tp->type == ';') {		/* rh side of named group */
			right = tok822_group(TOK822_ADDR, tp, right, ADD_COMMA);
			state = DO_GROUP | DO_WORD;
		} else if (tp->type == ':' && (state & DO_GROUP) != 0) {
			tp->type = TOK822_STARTGRP;
			(void) tok822_group(TOK822_ADDR, tp, right, NO_MISSING_COMMA);
			SKIP(tp, tp->type != ',');
			right = tp;
			continue;
		} else if (tp->type == '>') {		/* rh side of <route> */
			right = tok822_group(TOK822_ADDR, tp, right, ADD_COMMA);
			SKIP_MOVE_COMMENT(tp, tp->type != '<', right);
			(void) tok822_group(TOK822_ADDR, tp, right, NO_MISSING_COMMA);
			SKIP(tp, tp->type > 0xff || strchr(">;,:", tp->type) == 0);
			right = tp;
			state |= DO_WORD;
			continue;
		} else if (tp->type == TOK822_ATOM || tp->type == TOK822_QSTRING
				|| tp->type == TOK822_DOMLIT) {
			if ((state & DO_WORD) == 0)
				right = tok822_group(TOK822_ADDR, tp, right, ADD_COMMA)->next;
			state &= ~DO_WORD;
		} else if (tp->type == ',') {
			right = tok822_group(TOK822_ADDR, tp, right, NO_MISSING_COMMA);
			state |= DO_WORD;
		} else {
			state |= DO_WORD;
		}
		tp = tp->prev;
	}
	(void) tok822_group(TOK822_ADDR, tp, right, NO_MISSING_COMMA);

	/*
	 * Discard the sentinel tokens on the left and right extremes. Properly
	 * terminate the resulting list.
	 */
	tp = (head->next != tail ? head->next : 0);
	tok822_cut_before(head->next);
	tok822_free(head);
	tok822_cut_before(tail);
	tok822_free(tail);
	return (tp);
}
Example #8
0
WireSyntax::WireSyntax()
{
    SYNTAX("Wire");

    DEFINE_VOID("Comment",
                CHOICE(
                    GLUE(
                        STRING("//"),
                        CHOICE(
                            FIND(AHEAD(CHAR('\n'))),
                            FIND(EOI())
                        )
                    ),
                    GLUE(
                        STRING("/*"),
                        REPEAT(
                            CHOICE(
                                INLINE("Comment"),
                                GLUE(
                                    NOT(STRING("*/")),
                                    ANY()
                                )
                            )
                        ),
                        STRING("*/")
                    )
                )
               );

    DEFINE_VOID("Whitespace",
                REPEAT(
                    CHOICE(
                        RANGE(" \t\n"),
                        INLINE("Comment")
                    )
                )
               );

    DEFINE("Name",
           REPEAT(1, EXCEPT(" \t\n:;"))
          );

    DEFINE("Value",
           CHOICE(
               REF("Atom"),
               REF("Properties"),
               REF("Items")
           )
          );

    DEFINE("Object",
           GLUE(
               REPEAT(0, 1,
                      GLUE(
                          REF("Name"),
                          INLINE("Whitespace"),
                          CHAR(':'),
                          INLINE("Whitespace")
                      )
                     ),
               INLINE("Value")
           )
          );

    DEFINE("Atom",
           REPEAT(
               GLUE(
                   NOT(
                       CHOICE(
                           GLUE(
                               REPEAT(RANGE(" \t")),
                               INLINE("Name"),
                               REPEAT(RANGE(" \t")),
                               CHAR(':')
                           ),
                           GLUE(
                               REPEAT(RANGE(" \t")),
                               RANGE("};,")
                           ),
                           STRING("\n\n")
                       )
                   ),
                   ANY()
               )
           )
          );

    DEFINE("Properties",
           GLUE(
               CHAR('{'),
               INLINE("Whitespace"),
               REPEAT(
                   GLUE(
                       REF("Object"),
                       INLINE("Whitespace"),
                       RANGE(";,"),
                       INLINE("Whitespace")
                   )
               ),
               CHAR('}')
           )
          );

    DEFINE("Items",
           GLUE(
               CHAR('['),
               INLINE("Whitespace"),
               REPEAT(
                   GLUE(
                       REF("Value"),
                       INLINE("Whitespace"),
                       RANGE(";,"),
                       INLINE("Whitespace")
                   )
               ),
               CHAR(']')
           )
          );

    ENTRY("Object");
}
HaxeMessageSyntax::HaxeMessageSyntax()
{
	DEFINE_VOID("SpaceChar", RANGE(" \n\r\t"));
	DEFINE_VOID("Whitespace", REPEAT(INLINE("SpaceChar")));
	
	specialChar_ =
		DEFINE("SpecialChar",
			GLUE(
				CHAR('&'),
				KEYWORD("gt lt"),
				CHAR(';')
			)
		);
	gt_ = keywordByName("gt");
	lt_ = keywordByName("lt");
	
	value_ =
		DEFINE("Value",
			REPEAT(1,
				CHOICE(
					REF("SpecialChar"),
					GLUE(
						NOT(
							GLUE(
								INLINE("Whitespace"),
								CHAR('<')
							)
						),
						ANY()
					)
				)
			)
		);
	
	typeTip_ =
		DEFINE("TypeTip",
			GLUE(
				STRING("<type>"),
				INLINE("Whitespace"),
				REF("Value"),
				INLINE("Whitespace"),
				STRING("</type>")
			)
		);
	
	memberName_ = DEFINE("MemberName", REPEAT(1, OTHER('\"')));
	memberType_ = DEFINE("MemberType", REPEAT(0, 1, INLINE("Value")));
	memberDescription_ = DEFINE("MemberDescription", REPEAT(0, 1, INLINE("Value")));
	
	member_ =
		DEFINE("Member",
			GLUE(
				STRING("<i n=\""),
				REF("MemberName"),
				STRING("\"><t>"),
				REF("MemberType"),
				STRING("</t><d>"),
				REF("MemberDescription"),
				STRING("</d></i>")
			)
		);
	
	membersTip_ =
		DEFINE("MembersTip",
			GLUE(
				STRING("<list>"),
				REPEAT(1,
					GLUE(
						INLINE("Whitespace"),
						REF("Member")
					)
				),
				INLINE("Whitespace"),
				STRING("</list>")
			)
		);
	
	haxeTip_ =
		DEFINE("HaxeTip",
			FIND(
				GLUE(
					INLINE("Whitespace"),
					CHOICE(
						REF("TypeTip"),
						REF("MembersTip")
					),
					INLINE("Whitespace")
				)
			)
		);
	
	ENTRY("HaxeTip");
}