Skip to main content
added 362 characters in body
Source Link
chux
  • 33.6k
  • 2
  • 38
  • 92

"%z..."

Avoid UB.

Codes use "%zd" with size_t and unsigned.

Use "%zu" with size_t and "%u" with unsigned.

Name space

(Is the code readable?) lexical_analyzer.h introduces types and macros such as SYNTAX_STATE_MACHINE_H, COMMA, State_Transition_Characters, MAX_OPCODE, in a inconsistent manner.

TheName collision avoidance is difficult as naming covers too many naming stylestyles.

Consider a common prefix for all, perhaps lapac_ in lapac.h.

Take care with failed data

Avoid UB. report_lexical_analyzer_test_failure()

When things fail, avoid assuming too much about string data.

I recommend printing string with sentinels such as "<", ">" for clarity as to the start/end of a string which may include white space..

Take better string length care by using snprintf(), etc., than hoping char out_buffer[BUFSIZ]; is big enough.

Simplify verbose code

(Are there any features in the more modern versions of C that could reduce the amount of code?)

// Instead of 22 line original, avoid locale dependencies and shorten.
static bool is_legal_in_hex_number(unsigned char input) {
  return (isxdigit(input) && !isdigit(input)) || (input == 'x' || input == 'X');
}

It is unclear to me why original is_legal_in_hex_number(some_0_to_9_digit) returns false.

Minor

state_machine_unit_test_main.h should include <stdbool.h>

() around macro equations..

// #define SYNTAX_STATE_ARRAY_SIZE    9 + 1
#define SYNTAX_STATE_ARRAY_SIZE    (9 + 1)

"%z..."

Avoid UB.

Codes use "%zd" with size_t and unsigned.

Use "%zu" with size_t and "%u" with unsigned.

Name space

(Is the code readable?) lexical_analyzer.h introduces types and macros such as SYNTAX_STATE_MACHINE_H, COMMA, State_Transition_Characters, MAX_OPCODE, in a inconsistent manner.

The collision avoidance is difficult as naming covers too many naming style.

Consider a common prefix for all, perhaps lapac_ in lapac.h.

Take care with failed data

Avoid UB. report_lexical_analyzer_test_failure()

When things fail, avoid assuming too much about string data.

I recommend printing string with sentinels such as "<", ">" for clarity as to the start/end of a string which may include white space..

Take better string length care by using snprintf(), etc., than hoping char out_buffer[BUFSIZ]; is big enough.

Simplify verbose code

(Are there any features in the more modern versions of C that could reduce the amount of code?)

// Instead of 22 line original, avoid locale dependencies and shorten.
static bool is_legal_in_hex_number(unsigned char input) {
  return (isxdigit(input) && !isdigit(input)) || (input == 'x' || input == 'X');
}

Minor

state_machine_unit_test_main.h should include <stdbool.h>

() around macro equations..

// #define SYNTAX_STATE_ARRAY_SIZE    9 + 1
#define SYNTAX_STATE_ARRAY_SIZE    (9 + 1)

"%z..."

Avoid UB.

Codes use "%zd" with size_t and unsigned.

Use "%zu" with size_t and "%u" with unsigned.

Name space

(Is the code readable?) lexical_analyzer.h introduces types and macros such as SYNTAX_STATE_MACHINE_H, COMMA, State_Transition_Characters, MAX_OPCODE, in a inconsistent manner.

Name collision avoidance is difficult as naming covers too many naming styles.

Consider a common prefix for all, perhaps lapac_ in lapac.h.

Take care with failed data

Avoid UB. report_lexical_analyzer_test_failure()

When things fail, avoid assuming too much about string data.

I recommend printing string with sentinels such as "<", ">" for clarity as to the start/end of a string which may include white space..

Take better string length care by using snprintf(), etc., than hoping char out_buffer[BUFSIZ]; is big enough.

Simplify verbose code

(Are there any features in the more modern versions of C that could reduce the amount of code?)

// Instead of 22 line original, avoid locale dependencies and shorten.
static bool is_legal_in_hex_number(unsigned char input) {
  return (isxdigit(input) && !isdigit(input)) || (input == 'x' || input == 'X');
}

It is unclear to me why original is_legal_in_hex_number(some_0_to_9_digit) returns false.

Minor

state_machine_unit_test_main.h should include <stdbool.h>

() around macro equations..

// #define SYNTAX_STATE_ARRAY_SIZE    9 + 1
#define SYNTAX_STATE_ARRAY_SIZE    (9 + 1)
added 362 characters in body
Source Link
chux
  • 33.6k
  • 2
  • 38
  • 92

"%z..."

Avoid UB.

Codes use "%zd" with size_t and unsigned.

Use "%zu" with size_t and "%u" with unsigned.

Name space

(Is the code readable?) lexical_analyzer.h introduces types and macros such as SYNTAX_STATE_MACHINE_H, COMMA, State_Transition_Characters, MAX_OPCODE, in a inconsistent manner.

The collision avoidance is difficult as naming covers too many naming style.

Consider a common prefix for all, perhaps lapac_ in lapac.h.

Take care with failed data

Avoid UB. report_lexical_analyzer_test_failure()

When things fail, avoid assuming too much about string data.

I recommend printing string with sentinels such as "<", ">" for clarity as to the start/end of a string which may include white space..

Take better string length care by using snprintf(), etc., than hoping char out_buffer[BUFSIZ]; is big enough.

Simplify verbose code

(Are there any features in the more modern versions of C that could reduce the amount of code?)

// Instead of 22 line original, avoid locale dependencies and shorten.
static bool is_legal_in_hex_number(unsigned char input) {
  return (isxdigit(input) && !isdigit(input)) || (input == 'x' || input == 'X');
}

 

Minor

Perhaps more laterstate_machine_unit_test_main.h should include <stdbool.h>

() around macro equations. Even at 1/3 there is much to review.

// #define SYNTAX_STATE_ARRAY_SIZE    9 + 1
#define SYNTAX_STATE_ARRAY_SIZE    (9 + 1)

"%z..."

Avoid UB.

Codes use "%zd" with size_t and unsigned.

Use "%zu" with size_t and "%u" with unsigned.

Name space

(Is the code readable?) lexical_analyzer.h introduces types and macros such as SYNTAX_STATE_MACHINE_H, COMMA, State_Transition_Characters, MAX_OPCODE, in a inconsistent manner.

The collision avoidance is difficult as naming covers too many naming style.

Consider a common prefix for all, perhaps lapac_ in lapac.h.

Take care with failed data

Avoid UB. report_lexical_analyzer_test_failure()

When things fail, avoid assuming too much about string data.

I recommend printing string with sentinels such as "<", ">" for clarity as to the start/end of a string which may include white space..

Take better string length care by using snprintf(), etc., than hoping char out_buffer[BUFSIZ]; is big enough.

Simplify verbose code

(Are there any features in the more modern versions of C that could reduce the amount of code?)

// Instead of 22 line original, avoid locale dependencies and shorten.
static bool is_legal_in_hex_number(unsigned char input) {
  return (isxdigit(input) && !isdigit(input)) || (input == 'x' || input == 'X');
}

 

Perhaps more later. Even at 1/3 there is much to review.

"%z..."

Avoid UB.

Codes use "%zd" with size_t and unsigned.

Use "%zu" with size_t and "%u" with unsigned.

Name space

(Is the code readable?) lexical_analyzer.h introduces types and macros such as SYNTAX_STATE_MACHINE_H, COMMA, State_Transition_Characters, MAX_OPCODE, in a inconsistent manner.

The collision avoidance is difficult as naming covers too many naming style.

Consider a common prefix for all, perhaps lapac_ in lapac.h.

Take care with failed data

Avoid UB. report_lexical_analyzer_test_failure()

When things fail, avoid assuming too much about string data.

I recommend printing string with sentinels such as "<", ">" for clarity as to the start/end of a string which may include white space..

Take better string length care by using snprintf(), etc., than hoping char out_buffer[BUFSIZ]; is big enough.

Simplify verbose code

(Are there any features in the more modern versions of C that could reduce the amount of code?)

// Instead of 22 line original, avoid locale dependencies and shorten.
static bool is_legal_in_hex_number(unsigned char input) {
  return (isxdigit(input) && !isdigit(input)) || (input == 'x' || input == 'X');
}

Minor

state_machine_unit_test_main.h should include <stdbool.h>

() around macro equations..

// #define SYNTAX_STATE_ARRAY_SIZE    9 + 1
#define SYNTAX_STATE_ARRAY_SIZE    (9 + 1)
added 362 characters in body
Source Link
chux
  • 33.6k
  • 2
  • 38
  • 92

"%z..."

Avoid UB.

Codes use "%zd" with size_t and unsigned.

Use "%zu" with size_t and "%u" with unsigned.

Name space

(Is the code readable?) lexical_analyzer.h introduces types and macros such as SYNTAX_STATE_MACHINE_H, COMMA, State_Transition_Characters, MAX_OPCODE, in a inconsistent manner.

The collision avoidance is difficult as naming covers too many naming style.

Consider a common prefix for all, perhaps lapac_ in lapac.h.

Take care with failed data

Avoid UB. report_lexical_analyzer_test_failure()

When things fail, avoid assuming too much about string data.

I recommend printing string with sentinels such as "<", ">" for clarity as to the start/end of a string which may include white space..

Take better string length care by using snprintf(), etc., than hoping char out_buffer[BUFSIZ]; is big enough.

Simplify verbose code

(Are there any features in the more modern versions of C that could reduce the amount of code?)

// Instead of 22 line original, avoid locale dependencies and shorten.
static bool is_legal_in_hex_number(unsigned char input) {
  return (isxdigit(input) && !isdigit(input)) || (input == 'x' || input == 'X');
}

Perhaps more later. Even at 1/3 there is much to review.

"%z..."

Avoid UB.

Codes use "%zd" with size_t and unsigned.

Use "%zu" with size_t and "%u" with unsigned.

Name space

(Is the code readable?) lexical_analyzer.h introduces types and macros such as SYNTAX_STATE_MACHINE_H, COMMA, State_Transition_Characters, MAX_OPCODE, in a inconsistent manner.

The collision avoidance is difficult as naming covers too many naming style.

Consider a common prefix for all, perhaps lapac_ in lapac.h.

Take care with failed data

Avoid UB. report_lexical_analyzer_test_failure()

When things fail, avoid assuming too much about string data.

I recommend printing string with sentinels such as "<", ">" for clarity as to the start/end of a string which may include white space..

Take better string length care by using snprintf(), etc., than hoping char out_buffer[BUFSIZ]; is big enough.


Perhaps more later. Even at 1/3 there is much to review.

"%z..."

Avoid UB.

Codes use "%zd" with size_t and unsigned.

Use "%zu" with size_t and "%u" with unsigned.

Name space

(Is the code readable?) lexical_analyzer.h introduces types and macros such as SYNTAX_STATE_MACHINE_H, COMMA, State_Transition_Characters, MAX_OPCODE, in a inconsistent manner.

The collision avoidance is difficult as naming covers too many naming style.

Consider a common prefix for all, perhaps lapac_ in lapac.h.

Take care with failed data

Avoid UB. report_lexical_analyzer_test_failure()

When things fail, avoid assuming too much about string data.

I recommend printing string with sentinels such as "<", ">" for clarity as to the start/end of a string which may include white space..

Take better string length care by using snprintf(), etc., than hoping char out_buffer[BUFSIZ]; is big enough.

Simplify verbose code

(Are there any features in the more modern versions of C that could reduce the amount of code?)

// Instead of 22 line original, avoid locale dependencies and shorten.
static bool is_legal_in_hex_number(unsigned char input) {
  return (isxdigit(input) && !isdigit(input)) || (input == 'x' || input == 'X');
}

Perhaps more later. Even at 1/3 there is much to review.

added 423 characters in body
Source Link
chux
  • 33.6k
  • 2
  • 38
  • 92
Loading
Source Link
chux
  • 33.6k
  • 2
  • 38
  • 92
Loading